This document shows some things researchers may wish to add to their
preanalysis plans using design declaration and diagnosis.
Setup
library(DeclareDesign)
library(tidyverse)
library(texreg)
library(knitr)
set.seed(343)
Declare the Design
sample_size <- 100
effect_size <- 0.5
number_treated <- 50
two_arm_design <-
# M: Model
declare_model(
N = sample_size,
U = rnorm(N),
potential_outcomes(Y ~ effect_size * Z + U)
) +
# I: Inquiry
declare_inquiry(ATE = mean(Y_Z_1 - Y_Z_0)) +
# D: Data Strategy
declare_assignment(Z = complete_ra(N, m = number_treated)) +
declare_measurement(Y = reveal_outcomes(Y ~ Z)) +
# A: Answer Strategy
declare_estimator(Y ~ Z, .method = lm_robust, estimand = "ATE")
Mock Regression Table
fit <- lm_robust(Y ~ treatment, data = one_run)
htmlreg(
fit,
custom.coef.names = c("Intercept", "Treatment"),
include.ci = FALSE,
include.rmse = FALSE,
include.adjrs = FALSE,
stars = 0.05,
custom.note = "%stars. HC2 robust standard errors are in parentheses.",
caption = "Average Treatment Effect (Simulated Data)",
caption.above = TRUE,
doctype = FALSE
)
Average Treatment Effect (Simulated Data)
|
Model 1
|
Intercept
|
0.09
|
|
(0.13)
|
Treatment
|
0.12
|
|
(0.17)
|
R2
|
0.01
|
Num. obs.
|
100
|
*p < 0.05. HC2 robust standard errors are in parentheses.
|
Diagnosis
diagnosis <- diagnose_design(two_arm_design)
reshape_diagnosis(diagnosis, select = "Power") %>%
kable()
two_arm_design |
ATE |
estimator |
Y |
Z |
500 |
0.67 |
|
|
|
|
|
|
(0.02) |