Sahel Prepare data for sahel_ggcoefs()
sahel_prep_ggcoefs.Rd
This function prepares the coefficient information saved post regression workflow in Stata and makes them ready for plotting.
Usage
sahel_prep_ggcoefs(
data,
variables = c("consum_2_day_eq_ppp", "consum_2_day_ppp", "food_2_day_eq_ppp",
"food_2_day_ppp", "food_2_day_g_ppp", "food_2_day_g_eq_ppp", "food_2_g_d",
"FIES_rvrs_raw"),
var_labels = c("Daily Cons.\n Ad. Equiv.", "Daily Consumption",
"Daily Food Cons.\n Ad. Equiv", "Daily Food Cons.",
"Gifted Daily Food\n Cons. Ad. Equiv", "Gifted Daily\n Food Cons.",
"Consumed Gifted\n Food {0,1}", "Food Security"),
measure = "avg",
model_number = 1
)
Arguments
- data
A data frame filled with regression output from Stata.
- variables
A character vector of variable names to plot.
- var_labels
A chacater vector of corresponding variable names.
- measure
A string indicating the measure to plot e.g.
"avg", b
- model_number
Some dataframes have a mht_family variable indicating the model type number. Select the model you want to plot by passing it the corresponding number.
Examples
# Don't forget to mount the data if using the actual data
# prodregs <-
# haven::read_dta(r"(U:\fu2_MRT\05_Regstats\fu2_MRT_regstats_hh_prod.dta)")
# Example with simulated data
set.seed(1234)
prodregs <- fabricatr::fabricate(N = 8,
var_name = c("consum_2_day_eq_ppp",
"consum_2_day_ppp",
"food_2_day_eq_ppp",
"food_2_day_ppp",
"food_2_day_g_ppp",
"food_2_day_g_eq_ppp",
"food_2_g_d",
"FIES_rvrs_raw"),
b0 = 0,
b1 = rnorm(N, 0, 1),
b2 = rnorm(N, 0, 1),
b3 = rnorm(N, 0, 1),
avg0 = rnorm(N, 7, 1),
avg1 = rnorm(N, 8, 1),
avg2 = rnorm(N, 9, 1),
avg3 = rnorm(N, 10, 1),
se0 = rnorm(N, 0, 1),
se1 = rnorm(N, 0, 1),
se2 = rnorm(N, 0, 1),
se3 = rnorm(N, 0, 1),
ci95_0 = rnorm(N, 2, 1),
ci95_1 = rnorm(N, 2, 1),
ci95_2 = rnorm(N, 2, 1),
ci95_3 = rnorm(N, 2, 1),
p0 = rnorm(N, 0.8, 0.5),
p1 = rnorm(N, 0.8, 0.5),
p2 = rnorm(N, 0.8, 0.5),
p3 = rnorm(N, 0.8, 0.5),
mht_family = 1) |>
dplyr::select(-ID)
sahel_prep_ggcoefs(prodregs)
#> # A tibble: 32 × 7
#> var_name mht_family Variable.x Value.x Treatment Variable.y Value.y
#> <fct> <dbl> <chr> <dbl> <fct> <chr> <dbl>
#> 1 "Daily Cons.\n Ad… 1 ci95_0 NA Control avg0 6.31
#> 2 "Daily Cons.\n Ad… 1 ci95_1 0.865 Psychoso… avg1 7.29
#> 3 "Daily Cons.\n Ad… 1 ci95_2 1.17 Cash avg2 10.4
#> 4 "Daily Cons.\n Ad… 1 ci95_3 0.890 Full avg3 9.48
#> 5 "Daily Consumptio… 1 ci95_0 NA Control avg0 5.55
#> 6 "Daily Consumptio… 1 ci95_1 2.88 Psychoso… avg1 7.50
#> 7 "Daily Consumptio… 1 ci95_2 2.17 Cash avg2 7.93
#> 8 "Daily Consumptio… 1 ci95_3 2.85 Full avg3 9.50
#> 9 "Daily Food Cons.… 1 ci95_0 NA Control avg0 7.57
#> 10 "Daily Food Cons.… 1 ci95_1 2.97 Psychoso… avg1 6.37
#> # ℹ 22 more rows