data(race)
set.seed(1)
# Calculate list experiment difference in means
diff.in.means.results <- ictreg(y ~ 1, data = race,
treat = "treat", J=3, method = "lm")
summary(diff.in.means.results)
# Fit linear regression
# Replicates Table 1 Columns 1-2 Imai (2011); note that age is divided by 10
lm.results <- ictreg(y ~ south + age + male + college, data = race,
treat = "treat", J=3, method = "lm")
summary(lm.results)
# Fit two-step non-linear least squares regression
# Replicates Table 1 Columns 3-4 Imai (2011); note that age is divided by 10
nls.results <- ictreg(y ~ south + age + male + college, data = race,
treat = "treat", J=3, method = "nls")
summary(nls.results)
if (FALSE) {
# Fit EM algorithm ML model with constraint
# Replicates Table 1 Columns 5-6, Imai (2011); note that age is divided by 10
ml.constrained.results <- ictreg(y ~ south + age + male + college, data = race,
treat = "treat", J=3, method = "ml",
overdispersed = FALSE, constrained = TRUE)
summary(ml.constrained.results)
# Fit EM algorithm ML model with no constraint
# Replicates Table 1 Columns 7-10, Imai (2011); note that age is divided by 10
ml.unconstrained.results <- ictreg(y ~ south + age + male + college, data = race,
treat = "treat", J=3, method = "ml",
overdispersed = FALSE, constrained = FALSE)
summary(ml.unconstrained.results)
# Fit EM algorithm ML model for multiple sensitive items
# Replicates Table 3 in Blair and Imai (2010)
multi.results <- ictreg(y ~ male + college + age + south + south:age, treat = "treat",
J = 3, data = multi, method = "ml",
multi.condition = "level")
summary(multi.results)
# Fit standard design ML model
# Replicates Table 7 Columns 1-2 in Blair and Imai (2010)
noboundary.results <- ictreg(y ~ age + college + male + south, treat = "treat",
J = 3, data = affirm, method = "ml",
overdispersed = FALSE)
summary(noboundary.results)
# Fit standard design ML model with ceiling effects alone
# Replicates Table 7 Columns 3-4 in Blair and Imai (2010)
ceiling.results <- ictreg(y ~ age + college + male + south, treat = "treat",
J = 3, data = affirm, method = "ml", fit.start = "nls",
ceiling = TRUE, ceiling.fit = "bayesglm",
ceiling.formula = ~ age + college + male + south)
summary(ceiling.results)
# Fit standard design ML model with floor effects alone
# Replicates Table 7 Columns 5-6 in Blair and Imai (2010)
floor.results <- ictreg(y ~ age + college + male + south, treat = "treat",
J = 3, data = affirm, method = "ml", fit.start = "glm",
floor = TRUE, floor.fit = "bayesglm",
floor.formula = ~ age + college + male + south)
summary(floor.results)
# Fit standard design ML model with floor and ceiling effects
# Replicates Table 7 Columns 7-8 in Blair and Imai (2010)
both.results <- ictreg(y ~ age + college + male + south, treat = "treat",
J = 3, data = affirm, method = "ml",
floor = TRUE, ceiling = TRUE,
floor.fit = "bayesglm", ceiling.fit = "bayesglm",
floor.formula = ~ age + college + male + south,
ceiling.formula = ~ age + college + male + south)
summary(both.results)
# Response error models (Blair, Imai, and Chou 2018)
top.coded.error <- ictreg(
y ~ age + college + male + south, treat = "treat",
J = 3, data = race, method = "ml", error = "topcoded")
uniform.error <- ictreg(
y ~ age + college + male + south, treat = "treat",
J = 3, data = race, method = "ml", error = "topcoded")
# Robust models, which constrain sensitive item proportion
# to difference-in-means estimate
robust.ml <- ictreg(
y ~ age + college + male + south, treat = "treat",
J = 3, data = affirm, method = "ml", robust = TRUE)
robust.nls <- ictreg(
y ~ age + college + male + south, treat = "treat",
J = 3, data = affirm, method = "nls", robust = TRUE)
}
Run the code above in your browser using DataLab