Skip to contents

Creates a violin plot visualizing the distribution of final household-level weights, by zone group and for the region as a whole. Useful for visually assessing the spread and outliers in the weighting process.

Steps performed:

  1. Combine zone group and region weights into one data frame for plotting.

  2. Map internal group codes to pretty labels using zone_group_labels.

  3. Build factor levels for plotting, ensuring "Region" appears last if present.

  4. Plot household weights by group as violins, with jittered points for individual households, and log10 x-axis.

Usage

plot_weight_distribution(hh_wide_dt, zone_group_order, max_points = 10000)

Arguments

hh_wide_dt

A data.table containing household weights, from prep_seed_weights. Must have columns "group_name" and "final_weight".

zone_group_order

Character vector specifying the order of zone groups for plotting.

max_points

The maximum number of points to plot. This is used to avoid overplotting.

Value

A ggplot object showing the distribution of household weights by zone group and region.

Examples

# plot_weight_distribution(hh_wide_dt, zone_group_labels, zone_group_order)