-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.qmd
391 lines (275 loc) · 10.7 KB
/
index.qmd
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
---
pagetitle: "DeclareDesign"
toc: false
page-layout: full
section-divs: false
anchor-sections: false
css: index.css
execute:
message: false
error: false
warning: false
cache: true
code-overflow: wrap
---
::: {.grid .align-items-center}
::: {.g-col-12 .g-col-md-6}
<p class="hdr1">Declare and diagnose your research design</p>
<p class="hdr2">DeclareDesign is a set of software tools to plan, implement, analyze, and communicate about empirical research</p>
<br>
::: {.grid}
::: {.g-col-12 .g-col-lg-4 .text-center}
[Get Started](getting-started/){.btn-action-primary .btn-action .btn .btn-success .btn-lg role="button"}
:::
::: {.g-col-12 .g-col-lg-4 .text-center}
[Software](/r/declaredesign/){.btn-action-primary .btn-action .btn .btn-success .btn-lg role="button"}
:::
::: {.g-col-12 .g-col-lg-4 .text-center}
[Read Book](https://book.declaredesign.org){.btn-action-primary .btn-action .btn .btn-success .btn-lg role="button"}
:::
:::
:::
::: {.g-col-12 .g-col-md-6}
[![](https://book.declaredesign.org/figures/cover.jpg){width=80% fig-id="img-border"}](https://book.declaredesign.org)
:::
:::
<!-- Figure 5.1 / MIDA -->
## MIDA framework for describing research designs
::: {.grid .align-items-center}
::: {.g-col-12 .g-col-md-8}
![](static/mida.svg){width=80% fig-id="img-border"}
:::
::: {.g-col-12 .g-col-md-4}
The MIDA framework describes the four elements of any empirical research design:
- **Model:** the worlds you consider
- **Inquiry:** the question you ask
- **Data strategy:** sampling, treatment assignment, and measurement procedures
- **Answer strategy:** estimation, testing, interpretation, and visualization procedures
Read [Chapter 5](https://book.declaredesign.org/declaration-diagnosis-redesign/declaring-designs.html) of *Research Design in the Social Sciences* to learn how these four research design elements connect to reality and simulations that can be used to plan and improve research designs.
:::
:::
<!-- tabset -->
## Declare-Diagnose-Redesign algorithm for designing research
* **Declare** designs in code following the MIDA framework.
* **Diagnose** declared designs through Monte Carlo simulation to learn their properties, such as bias and power.
* **Redesign** data and answer strategy features to optimize designs under logistical, financial, and ethical constraints.
Here is an illustration of using DeclareDesign for a two-arm randomized trial:
::: {.panel-tabset}
## 1. Declare
::: {.grid}
::: {.g-col-12 .g-col-md-6}
```{r, echo = FALSE, message = FALSE}
library(tidyverse)
library(knitr)
```
```{r}
library(DeclareDesign)
sample_size <- 100
# Declare a two-arm trial in code
two_arm_trial <-
declare_model(N = sample_size,
U = rnorm(N),
potential_outcomes(Y ~ 0.2 * Z + U)) +
declare_inquiry(ATE = mean(Y_Z_1 - Y_Z_0)) +
declare_assignment(Z = complete_ra(N, prob = 0.5)) +
declare_measurement(Y = reveal_outcomes(Y ~ Z)) +
declare_estimator(Y ~ Z, inquiry = "ATE")
```
:::
::: {.g-col-12 .g-col-md-6}
```{r, eval = FALSE}
# Draw a simulated dataset
draw_data(two_arm_trial)
```
```{r, echo = FALSE}
draw_data(two_arm_trial) |>
head(3) |>
kable(digits = 2)
```
```{r, eval = FALSE}
# Obtain a simulated estimate and estimand
run_design(two_arm_trial)
```
```{r, echo = FALSE}
run_design(two_arm_trial) |>
select(estimate, std.error, p.value, inquiry, estimand) |>
kable(digits = 2)
```
:::
:::
## 2. Diagnose
::: {.grid}
::: {.g-col-12 .g-col-md-6}
```{r, eval = FALSE}
# Simulate the research design 500 times and
# summarize the simulations
diagnosis <- diagnose_design(two_arm_trial, sims = 500)
tidy(diagnosis)
```
```{r, echo = FALSE}
diagnosis <- diagnose_design(two_arm_trial)
tidy(diagnosis) |>
select(diagnosand, estimate, std.error) |>
kable(digits = 3, row.names = FALSE)
```
:::
::: {.g-col-12 .g-col-md-6}
```{r, eval = FALSE}
library(ggplot2)
# Visualize simulated sampling distribution
ggplot(data = get_simulations(diagnosis),
aes(x = estimate)) +
geom_histogram()
```
```{r dev.args = list(bg = 'transparent')}
#| fig.width: 4
#| fig.height: 3
#| echo: false
sims <- diagnosis |> get_simulations()
diagnosands <- diagnosis |> get_diagnosands()
ggplot(sims, aes(estimate)) +
geom_histogram(color = NA, fill = "#72B4F3", bins = 30) +
geom_vline(
data = diagnosands,
aes(xintercept = mean_estimate),
color = gray(0.1),
lty = "dashed"
) +
geom_vline(
data = diagnosands,
aes(xintercept = mean_estimand),
color = "#C6227F",
lwd = 1.25
) +
annotate(
"text",
x = diagnosands$mean_estimand + 0.025,
y = 50,
hjust = 0,
label = "Estimand",
color = "#C6227F"
) +
annotate(
"text",
x = diagnosands$mean_estimate - 0.025,
y = 50,
hjust = 1,
label = "Average estimate",
color = gray(0.1)
) +
labs(x = "Simulation sampling distribution of estimator", y = "Density") +
theme_minimal()
```
:::
:::
## 3. Redesign
::: {.grid}
::: {.g-col-12 .g-col-md-6}
```{r, eval = FALSE}
# Redesign over sample size and calculate power
diagnosis <-
two_arm_trial |>
redesign(sample_size = c(250, 500, 750, 1000, 1250)) |>
diagnose_designs() |>
tidy() |>
filter(diagnosand == "power")
# Visualize power curve over sample sizes
ggplot(diagnosis, aes(sample_size, estimate)) +
geom_point() +
geom_line()
```
:::
::: {.g-col-12 .g-col-md-6}
```{r dev.args = list(bg = 'transparent')}
#| fig.width: 6
#| fig.height: 3
#| echo: false
#| code-overflow: wrap
designs_ss <-
two_arm_trial |>
redesign(sample_size = c(250, 500, 750, 1000, 1250))
diagnosis_ss <-
diagnose_design(designs_ss,
sims = 500)
diagnosands <-
diagnosis_ss |>
tidy() |>
filter(diagnosand == "power")
ggplot(diagnosands, aes(sample_size, estimate)) +
geom_ribbon(aes(ymin = conf.low, ymax = conf.high), fill = "#72B4F3", color = NA) +
geom_point() +
geom_line() +
geom_hline(yintercept = 0.8, color = "#C6227F", linewidth = 1, lty = "dashed") +
annotate("text", x = 800, y = 0.75, label = "80% power target", hjust = 0) +
labs(x = "Sample size", y = "Statistical power") +
theme_minimal()
```
:::
:::
:::
<!-- grid of content -->
## Library of common research designs
The MIDA framework can accomodate observational and experimental, descriptive and causal, qualitative and quantitative research designs. Part III of *Research Design in the Social Sciences* illustrates the framework for these common designs.
::: {.grid}
::: {.g-col-12 .g-col-md-6 .g-col-lg-4}
### Observational designs for descriptive inference
[Simple random sampling](https://book.declaredesign.org/library/observational-descriptive.html#simple-random-sampling)<br />
[Cluster random sampling](https://book.declaredesign.org/library/observational-descriptive.html#sec-ch15s2)<br />
[Multi-level regression and poststratification](https://book.declaredesign.org/library/observational-descriptive.html#sec-ch15s3)<br />
[Index creation](https://book.declaredesign.org/library/observational-descriptive.html#index-creation)
:::
::: {.g-col-12 .g-col-md-6 .g-col-lg-4}
### Observational designs for causal inference
[Process tracing](https://book.declaredesign.org/library/observational-causal.html#sec-ch16s1)<br />
[Selection-on-observables](https://book.declaredesign.org/library/observational-causal.html#sec-ch16s2)<br />
[Difference-in-differences](https://book.declaredesign.org/library/observational-causal.html#sec-ch16s3)<br />
[Instrumental variables](https://book.declaredesign.org/library/observational-causal.html#sec-ch16s4)<br />
[Regression discontinuity designs](https://book.declaredesign.org/library/observational-causal.html#sec-ch16s5)
:::
::: {.g-col-12 .g-col-md-6 .g-col-lg-4}
### Experimental designs for descriptive inference
[Audit experiments](https://book.declaredesign.org/library/experimental-descriptive.html#audit-experiments)<br />
[List experiments](https://book.declaredesign.org/library/experimental-descriptive.html#list-experiments)<br />
[Conjoint experiments](https://book.declaredesign.org/library/experimental-descriptive.html#sec-ch17s3)<br />
[Behavioral games](https://book.declaredesign.org/library/experimental-descriptive.html#behavioral-games)
:::
::: {.g-col-12 .g-col-md-6 .g-col-lg-4}
### Experimental designs for causal inference
[Two-arm randomized experiments](https://book.declaredesign.org/library/experimental-causal.html#sec-ch18s1)<br />
[Block-randomized experiments](https://book.declaredesign.org/library/experimental-causal.html#block-randomized-experiments)<br />
[Cluster-randomized experiments](https://book.declaredesign.org/library/experimental-causal.html#sec-ch18s3)<br />
[Subgroup designs](https://book.declaredesign.org/library/experimental-causal.html#sec-ch18s4)<br />
[Factorial experiments](https://book.declaredesign.org/library/experimental-causal.html#sec-ch18s5)<br />
[Encouragement designs](https://book.declaredesign.org/library/experimental-causal.html#sec-ch18s6)<br />
[Placebo-controlled experiments](https://book.declaredesign.org/library/experimental-causal.html#sec-ch18s7)<br />
[Stepped-wedge experiments](https://book.declaredesign.org/library/experimental-causal.html#stepped-wedge-experiments)<br />
[Randomized saturation experiments](https://book.declaredesign.org/library/experimental-causal.html#sec-ch18s9)<br />
[Experiments over networks](https://book.declaredesign.org/library/experimental-causal.html#sec-ch18s10)
:::
::: {.g-col-12 .g-col-md-6 .g-col-lg-4}
### Complex designs
[Discovery using causal forests](https://book.declaredesign.org/library/complex.html#discovery-using-causal-forests)<br />
[Structural estimation](https://book.declaredesign.org/library/complex.html#sec-ch19s2)<br />
[Meta-analysis](https://book.declaredesign.org/library/complex.html#sec-ch19s3)<br />
[Multi-site studies](https://book.declaredesign.org/library/complex.html#multi-site-studies)
:::
:::
<!-- take action -->
<br/><br/>
::: {.grid .align-items-center}
::: {.g-col-12 .g-col-lg-2 .g-col-md-4 .g-start-lg-2 .text-center}
[Get Started](/getting-started/){.btn-action-primary .btn-action .btn .btn-success .btn-lg role="button"}
:::
::: {.g-col-12 .g-col-lg-2 .g-col-md-4 .text-center}
[Software](/r/declaredesign/){.btn-action-primary .btn-action .btn .btn-success .btn-lg role="button"}
:::
::: {.g-col-12 .g-col-lg-2 .g-col-md-4 .text-center}
[Read Book](https://book.declaredesign.org){.btn-action-primary .btn-action .btn .btn-success .btn-lg role="button"}
:::
::: {.g-col-12 .g-col-lg-2 .g-start-md-3 .g-col-md-4 .text-center}
[Read Blog](/blog){.btn-action-primary .btn-action .btn .btn-success .btn-lg role="button"}
:::
::: {.g-col-12 .g-col-lg-2 .g-col-md-4 .text-center}
[About](/about){.btn-action-primary .btn-action .btn .btn-success .btn-lg role="button"}
:::
:::