asmt33

Quarto

Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see https://quarto.org.

Running Code

When you click the Render button a document will be generated that includes both content and the output of embedded code. You can embed code like this:

1 + 1
[1] 2

You can add options to executable code like this

[1] 4

The echo: false option disables the printing of code (only output is displayed).

file_path <- file.choose()

uct <- read.csv(
  file_path,
  stringsAsFactors = FALSE
)

dim(uct)
[1] 250 116
names(uct)
  [1] "gender"                    "payment_type"             
  [3] "payment_size"              "primary_income0"          
  [5] "primary_income1"           "village"                  
  [7] "b_age"                     "b_married"                
  [9] "b_hhsize"                  "b_edu"                    
 [11] "asset_total_ppp0"          "asset_total_ppp1"         
 [13] "cons_nondurable_ppp0"      "cons_nondurable_ppp1"     
 [15] "ent_total_rev_ppp0"        "ent_total_rev_ppp1"       
 [17] "fs_hhfoodindexnew0"        "fs_hhfoodindexnew1"       
 [19] "med_hh_healthindex0"       "med_hh_healthindex1"      
 [21] "ed_index0"                 "ed_index1"                
 [23] "psy_index_z0"              "psy_index_z1"             
 [25] "ih_overall_index_z0"       "ih_overall_index_z1"      
 [27] "asset_livestock_ppp0"      "asset_livestock_ppp1"     
 [29] "asset_cows_ppp0"           "asset_cows_ppp1"          
 [31] "asset_smalllivestock_ppp0" "asset_smalllivestock_ppp1"
 [33] "asset_birds_ppp0"          "asset_birds_ppp1"         
 [35] "asset_furniture_ppp0"      "asset_furniture_ppp1"     
 [37] "asset_ag_ppp0"             "asset_ag_ppp1"            
 [39] "asset_radiotv_ppp0"        "asset_radiotv_ppp1"       
 [41] "asset_trans_ppp0"          "asset_trans_ppp1"         
 [43] "asset_phone_ppp0"          "asset_phone_ppp1"         
 [45] "asset_savings_ppp0"        "asset_savings_ppp1"       
 [47] "asset_land_owned_total0"   "asset_land_owned_total1"  
 [49] "cons_ownfood_ppp_m0"       "cons_ownfood_ppp_m1"      
 [51] "cons_boughtfood_ppp_m0"    "cons_boughtfood_ppp_m1"   
 [53] "cons_cereals_ppp_m0"       "cons_cereals_ppp_m1"      
 [55] "cons_meatfish_ppp_m0"      "cons_meatfish_ppp_m1"     
 [57] "cons_fruitveg_ppp_m0"      "cons_fruitveg_ppp_m1"     
 [59] "cons_dairy_ppp_m0"         "cons_dairy_ppp_m1"        
 [61] "cons_fats_ppp_m0"          "cons_fats_ppp_m1"         
 [63] "cons_sugars_ppp_m0"        "cons_sugars_ppp_m1"       
 [65] "cons_otherfood_ppp_m0"     "cons_otherfood_ppp_m1"    
 [67] "cons_alcohol_ppp_m0"       "cons_alcohol_ppp_m1"      
 [69] "cons_tobacco_ppp_m0"       "cons_tobacco_ppp_m1"      
 [71] "cons_med_total_ppp_m0"     "cons_med_total_ppp_m1"    
 [73] "cons_ed_ppp_m0"            "cons_ed_ppp_m1"           
 [75] "cons_social_ppp_m0"        "cons_social_ppp_m1"       
 [77] "cons_total_ppp0"           "cons_total_ppp1"          
 [79] "psy_cesdscore0"            "psy_cesdscore1"           
 [81] "psy_worries_z0"            "psy_worries_z1"           
 [83] "psy_stressscore_z0"        "psy_stressscore_z1"       
 [85] "psy_hap_z0"                "psy_hap_z1"               
 [87] "psy_sat_z0"                "psy_sat_z1"               
 [89] "psy_trust_z0"              "psy_trust_z1"             
 [91] "psy_locus_z0"              "psy_locus_z1"             
 [93] "psy_scheierscore_z0"       "psy_scheierscore_z1"      
 [95] "psy_rosenbergscore_z0"     "psy_rosenbergscore_z1"    
 [97] "ent_farmprofit_ppp0"       "ent_farmprofit_ppp1"      
 [99] "fs_foodcred_often0"        "fs_foodcred_often1"       
[101] "heighttoage_HH_z0"         "heighttoage_HH_z1"        
[103] "weighttoage_HH_z0"         "weighttoage_HH_z1"        
[105] "armcirctoage_HH_z0"        "armcirctoage_HH_z1"       
[107] "med_child_healthindex0"    "med_child_healthindex1"   
[109] "ed_schoolattend0"          "ed_schoolattend1"         
[111] "fin_loansout_ppp0"         "fin_loansout_ppp1"        
[113] "durable_investment0"       "durable_investment1"      
[115] "nondurable_investment0"    "nondurable_investment1"   
table(uct$payment_type)

 control lump sum  monthly 
     157       46       47 
uct$treatment <- ifelse(
  uct$payment_type == "control",
  "Control",
  "UCT"
)

uct$treatment <- factor(
  uct$treatment,
  levels = c("Control", "UCT")
)

table(uct$treatment)

Control     UCT 
    157      93 
uct$asset_change <-
  uct$asset_total_ppp1 -
  uct$asset_total_ppp0
colSums(
  is.na(
    uct[c(
      "payment_type",
      "asset_total_ppp0",
      "asset_total_ppp1",
      "asset_change"
    )]
  )
)
    payment_type asset_total_ppp0 asset_total_ppp1     asset_change 
               0                0                0                0 
aggregate(
  asset_change ~ treatment,
  data = uct,
  FUN = function(x) {
    c(
      n = length(x),
      mean = mean(x),
      sd = sd(x),
      median = median(x),
      minimum = min(x),
      maximum = max(x)
    )
  }
)
  treatment asset_change.n asset_change.mean asset_change.sd
1   Control       157.0000          215.4057        370.9055
2       UCT        93.0000          409.9797        537.7460
  asset_change.median asset_change.minimum asset_change.maximum
1            145.0000            -732.1048            1633.1736
2            362.3630           -1751.6474            1477.1260
tapply(uct$asset_change, uct$treatment, length)
Control     UCT 
    157      93 
tapply(uct$asset_change, uct$treatment, mean)
 Control      UCT 
215.4057 409.9797 
tapply(uct$asset_change, uct$treatment, sd)
 Control      UCT 
370.9055 537.7460 
tapply(uct$asset_change, uct$treatment, median)
Control     UCT 
145.000 362.363 
par(mfrow = c(2, 2))

hist(
  uct$asset_change[uct$treatment == "Control"],
  main = "Control group",
  xlab = "Change in assets"
)

qqnorm(
  uct$asset_change[uct$treatment == "Control"],
  main = "Control Q-Q plot"
)
qqline(
  uct$asset_change[uct$treatment == "Control"],
  col = "red"
)

hist(
  uct$asset_change[uct$treatment == "UCT"],
  main = "UCT group",
  xlab = "Change in assets"
)

qqnorm(
  uct$asset_change[uct$treatment == "UCT"],
  main = "UCT Q-Q plot"
)
qqline(
  uct$asset_change[uct$treatment == "UCT"],
  col = "red"
)

par(mfrow = c(1, 1))
aggregate(
  asset_total_ppp0 ~ treatment,
  data = uct,
  FUN = mean
)
  treatment asset_total_ppp0
1   Control         194.9054
2       UCT         420.0682
t.test(
  asset_total_ppp0 ~ treatment,
  data = uct,
  var.equal = FALSE
)

    Welch Two Sample t-test

data:  asset_total_ppp0 by treatment
t = -4.2316, df = 127.14, p-value = 4.407e-05
alternative hypothesis: true difference in means between group Control and group UCT is not equal to 0
95 percent confidence interval:
 -330.4546 -119.8711
sample estimates:
mean in group Control     mean in group UCT 
             194.9054              420.0682 
welch_test <- t.test(
  asset_change ~ treatment,
  data = uct,
  alternative = "two.sided",
  var.equal = FALSE,
  conf.level = 0.95
)

welch_test

    Welch Two Sample t-test

data:  asset_change by treatment
t = -3.082, df = 144.4, p-value = 0.002463
alternative hypothesis: true difference in means between group Control and group UCT is not equal to 0
95 percent confidence interval:
 -319.35558  -69.79233
sample estimates:
mean in group Control     mean in group UCT 
             215.4057              409.9797 
mean_control <- mean(
  uct$asset_change[uct$treatment == "Control"]
)

mean_uct <- mean(
  uct$asset_change[uct$treatment == "UCT"]
)

difference <- mean_uct - mean_control

ci_uct_minus_control <-
  -rev(welch_test$conf.int)

mean_control
[1] 215.4057
mean_uct
[1] 409.9797
difference
[1] 194.574
ci_uct_minus_control
[1]  69.79233 319.35558
boxplot(
  asset_change ~ treatment,
  data = uct,
  col = c("lightblue", "wheat"),
  outline = FALSE,
  main = "Change in Total Household Assets by Transfer Group",
  xlab = "Transfer group",
  ylab = "Change in total household assets (PPP)"
)

set.seed(2026)

stripchart(
  asset_change ~ treatment,
  data = uct,
  method = "jitter",
  vertical = TRUE,
  add = TRUE,
  pch = 16,
  cex = 0.6,
  col = rgb(0, 0, 0, 0.35)
)

points(
  x = c(1, 2),
  y = c(mean_control, mean_uct),
  pch = 18,
  cex = 1.5,
  col = "darkred"
)

png(
  "UCT_asset_change.png",
  width = 1800,
  height = 1200,
  res = 200
)

boxplot(
  asset_change ~ treatment,
  data = uct,
  col = c("lightblue", "wheat"),
  outline = FALSE,
  main = "Change in Total Household Assets by Transfer Group",
  xlab = "Transfer group",
  ylab = "Change in total household assets (PPP)"
)

set.seed(2026)

stripchart(
  asset_change ~ treatment,
  data = uct,
  method = "jitter",
  vertical = TRUE,
  add = TRUE,
  pch = 16,
  cex = 0.6,
  col = rgb(0, 0, 0, 0.35)
)

points(
  c(1, 2),
  c(mean_control, mean_uct),
  pch = 18,
  cex = 1.5,
  col = "darkred"
)

dev.off()
png 
  2 
getwd()
[1] "C:/AssumptionsResource"