-
Notifications
You must be signed in to change notification settings - Fork 111
/
thomas_exercise_solutions.Rmd
139 lines (105 loc) · 3.85 KB
/
thomas_exercise_solutions.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
---
title: "Aid with Dignity"
author: "Psych 251"
date: "11/13/2020"
output: html_document
---
# Introduction
We're reproducing some data from Thomas et al. (2020), "Toward a science of delivering aid with dignity: Experimental evidence and local forecasts from Kenya."
[Catherine is a student and former TA in the course.]
In particular, we'll focus on Study 1: Experimental Impacts of Aid Narratives on Recipients.
The idea is to reproduce the basic effects of treatment that they saw, in particular, people who got a cash transfer heard that it was from either 1) a community empowerment organization, 2) a poverty alleviation organization, or 3) an individual empowerment organization. Com (condition 1) and Ind (codition 3) recipients were found to watch more business education videos, and reported greater self efficacy and mobility and less stigma.
Data from: [https://www.pnas.org/content/117/27/15546]()
Repository: [https://osf.io/v3cr4/]()
This is an example of a pretty nicely organized repository that includes a readme, a great codebook, all code and data, etc.
```{r}
library(tidyverse)
load("data/KenyaData.RData")
```
Key variables are `treat` (treatment condition), `vid.num`, and various psychological treatments. We'll focus on self-efficacy.
Let's make the appropriate composite for self-efficacy, copied from their code:
```{r}
scale.means = function (df, ..., na.rm=FALSE) {
vars = unlist(list(...))
mean_vars = rowMeans(df[,vars], na.rm=na.rm)
return(mean_vars)
}
for (var in c(k1_df$sel.con, k1_df$sel.pers, k1_df$sel.com,
k1_df$sel.prob, k1_df$sel.bett)) {
var[var < 0] <- NA
}
k1_df$sel.score.avg <- scale.means(k1_df, "sel.con", "sel.pers", "sel.com",
"sel.prob", "sel.bett", na.rm = T)
k1_df$sel.score <- scale(k1_df$sel.con) + scale(k1_df$sel.pers) +
scale(k1_df$sel.com) + scale(k1_df$sel.prob) + scale(k1_df$sel.bett)
k1_df$sel.score.z <- scale(k1_df$sel.score)
```
# Descriptives
Always good to make a histogram of the dependent variables (`sel.score` and `vid.num`)! Use facets, fills, etc. to try and explore how these relate to treatment.
```{r}
ggplot(k1_df, aes(x = vid.num)) +
geom_histogram() +
facet_wrap(~treat)
```
```{r}
ggplot(k1_df, aes(x = sel.score.avg)) +
geom_histogram(binwidth = .25) +
facet_wrap(~treat)
```
# Reproduce main analysis
Reproduce the behavioral result that `vid.num` is influenced by `treat`! (Figure 1a in the paper).
```{r}
k1_df %>%
group_by(treat) %>%
summarise(mean_vids = mean(vid.num),
se_vids = sd(vid.num) / sqrt(n()),
n = n()) %>%
ggplot(aes(x = treat, y = mean_vids)) +
geom_pointrange(aes(ymin = mean_vids - se_vids, ymax = mean_vids + se_vids))
```
Same for `sel.score`.
```{r}
k1_df %>%
group_by(treat) %>%
summarise(mean_sel = mean(sel.score.avg),
se_sel = sd(sel.score.avg) / sqrt(n()),
n = n()) %>%
ggplot(aes(x = treat, y = mean_sel)) +
geom_pointrange(aes(ymin = mean_sel - se_sel, ymax = mean_sel + se_sel))
```
# Exploratory analysis
Consider exploratory analysis of demographic variables and how they relate to outcomes.
* `soc.fem` = gender
* `soc.age` = age
* `ses.unemployed` = employment
* `soc.sav` = savings > 1000ksh
* `soc.inc` = income
Some examples, e.g. age:
```{r}
ggplot(k1_df,
aes(x = soc.age, y = sel.score.avg)) +
geom_point() +
geom_smooth(method = "lm") +
facet_wrap(~treat)
```
```{r}
ggplot(k1_df,
aes(x = soc.age, y = vid.num)) +
geom_jitter(height = .1, width = 0) +
geom_smooth(method = "lm") +
facet_wrap(~treat)
```
Income.
```{r}
ggplot(k1_df,
aes(x = soc.inc, y = sel.score.avg)) +
geom_point() +
geom_smooth(method = "lm")
```
```{r}
ggplot(k1_df,
aes(x = soc.inc, y = vid.num)) +
geom_jitter(height = .1, width = 0) +
geom_smooth(method = "lm") +
facet_wrap(~treat)
```