Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
create_tables.R 9.36 KiB
library(choiceTools)

dir.create("Tables/mxl")
dir.create("Tables/logit")
dir.create("Tables/ols/")


list_ols <- list("(Intercept)" = "Intercept", "as.factor(Treatment_A)Treated" = "Treated", "as.factor(Treatment_A)Vol_Treated" = "Vol. Treated",
                 "as.factor(Treatment_C)No Info 2" = "No Info 2", "as.factor(Treatment_C)No Video 1" = "Text 1",
                 "as.factor(Treatment_C)No Video 2" = "Text 2", "as.factor(Treatment_C)Video 1" = "Video 1",
                 "as.factor(Treatment_C)Video 2" = "Video 2", "Z_Mean_NR" = "NR-Index", "as.factor(Gender)2" = "Female",
                 "Age_mean" = "Age", "QFIncome" = "Income", "Uni_degree" = "University Degree")

# Manipulation check
texreg(l=list(ols_percentage_correct_A,  ols_percentage_correct_control_A, ols_percentage_correct_C, ols_percentage_correct_control_C),
       custom.model.names = c("Case A", "with Controls", "Case B", "with Controls"),
       custom.header = list("Dependent Variable: Percentage of correct quiz statements" = 1:4),
       custom.coef.map = list_ols,  stars = c(0.01, 0.05, 0.1), float.pos="tb", 
       custom.note = "%stars. Standard errors in parentheses.",
       label = "tab:mani",
       caption = "Results of OLS on percentage of correct quiz statements.",
       file="Tables/ols/manipulation.tex")


# Net interview time 
texreg(l=list(ols_time_spent_A,  ols_time_spent_control_A, ols_time_spent_C,  ols_time_spent_control_C),
       custom.model.names = c("Case A", "with Controls", "Case B", "with Controls"),
       custom.header = list("Dependent variable: Net interview time" = 1:4),
       custom.coef.map = list_ols,  stars = c(0.01, 0.05, 0.1), float.pos="tb",
       custom.note = "%stars. Standard errors in parentheses.",
       label = "tab:net_int",
       caption = "Results of OLS on net interview time.",
       file="Tables/ols/interviewtime.tex")


# CC Time
texreg(l=list(ols_time_cc_A,  ols_time_cc_control_A, ols_time_cc_C,  ols_time_cc_control_C),
       custom.model.names = c("Case A", "with Controls", "Case B", "with Controls"),
       custom.header = list("Dependent variable: Mean choice card time" = 1:4),
       custom.coef.map = list_ols,  stars = c(0.01, 0.05, 0.1), float.pos="tb",
       custom.note = "%stars. Standard errors in parentheses.",
       label = "tab:cctime",
       caption = "Results of OLS on mean choice card time.",
       file="Tables/ols/cctime.tex")

# Consequentiality
texreg(l=list(conseq_model_A, conseq_model_control_A, conseq_model_C, conseq_model_control_C),
       custom.model.names = c("Case A", "with Controls", "Case B", "with Controls"),
       custom.header = list("Dependent variable: Consequentiality score" = 1:4),
       custom.coef.map = list_ols,  stars = c(0.01, 0.05, 0.1), float.pos="tb",
       custom.note = "%stars. Standard errors in parentheses.",
       label = "tab:conseq",
       caption = "Results of OLS on consequentiality score.",
       file="Tables/ols/consequentiality.tex")

# Opt Out
texreg(l=list(ols_opt_out_A, ols_opt_out_control_A, ols_opt_out_C, ols_opt_out_control_C),
       custom.model.names = c("Case A", "with Controls", "Case B", "with Controls"),
       custom.header = list("Dependent variable: Number of opt-out choices" = 1:4),
       custom.coef.map = list_ols,  stars = c(0.01, 0.05, 0.1), float.pos="tb",
       custom.note = "%stars. Standard errors in parentheses.",
       label = "tab:optout",
       caption = "Results of OLS on number of opt-out choices.",
       file="Tables/ols/optout.tex")

# NR
texreg(l=list(nr_model_treat_A),
       custom.model.names = c("OLS regression"),
       custom.header = list("Dependent variable: NR-Index" = 1),
       custom.coef.map = list("(Intercept)" = "Intercept", "as.factor(Treatment_A)Treated" = "Treated", "as.factor(Treatment_A)Vol_Treated" = "Vol. Treated",
                              "as.factor(Treatment_C)No Info 2" = "No Info 2", "as.factor(Treatment_C)No Video 1" = "Text 1",
                              "as.factor(Treatment_C)No Video 2" = "Text 2", "as.factor(Treatment_C)Video 1" = "Video 1",
                              "as.factor(Treatment_C)Video 2" = "Video 2", "Z_Mean_NR" = "NR-Index", "as.factor(Gender)2" = "Female",
                              "Age_mean" = "Age", "QFIncome" = "Income", "Uni_degree" = "University Degree", "Kids_Dummy" = "Children",
                              "Naturalness_SQ" = "Naturalness SQ", "WalkingDistance_SQ" = "Walking Distance SQ"),
       stars = c(0.01, 0.05, 0.1), float.pos="tb",
       custom.note = "%stars. Standard errors in parentheses.",
       label = "tab:nr_ols",
       caption = "Results of OLS on the NR-index.",
       file="Tables/ols/nr_ols.tex")

#### Logit #####

texreg(l=list(logit_choice_treat_uni), stars = c(0.01, 0.05, 0.1), float.pos="tb",
       custom.model.names = c("Logit regression"),
       custom.header = list("Dependent variable: Voluntary Information Access" = 1),
       custom.coef.map = list_ols, custom.note = "%stars. Standard errors in parentheses.",
       label = "tab:logit_vt",
       caption = "Results of logit regression on the access of optional information.",
       file="Tables/logit/chose_treatment.tex")


##### MXL #######

### Baseline case A
case_A <- quicktexregapollo(mxl_wtp_case_a_rentINT)

coef_names <- case_A@coef.names 
coef_names <- sub("^(mu_)(.*)(_T|_VT)$", "\\2\\3", coef_names)
coef_names[4] <- "mu_ASC_sq"
case_A@coef.names <- coef_names

case_A_cols <- map(c("^mu_", "^sig_", "_T$", "_VT$"), subcoef, case_A)

texreg(c(case_A_cols[1], remGOF(case_A_cols[2:4])),
       custom.coef.map = list("natural" = "Naturalness", "walking" = "Walking Distance", "rent" = "Rent",
                              "ASC_sq" = "ASC SQ", "_natural" = "Naturalness", "nat" = "Naturalness",
                              "wd" = "Walking Distance", "asc" = "ASC SQ"),
       custom.model.names = c("Mean", "SD", "Treated", "Voluntary Treated"), custom.note = "%stars. Robust standard errors in parentheses.",
       stars = c(0.01, 0.05, 0.1), float.pos="tb", 
       label = "tab:mxl_A",
       caption = "Results of mixed logit model with treatment interactions for Case A.",
       file="Tables/mxl/case_A_rent_INT.tex")

### Baseline case C
case_C <- quicktexregapollo(mxl_wtp_case_c_rentINT)

coef_names <- case_C@coef.names 
coef_names <- sub("^(mu_)(.*)(1|2|info)$", "\\2\\3", coef_names)
coef_names[4] <- "mu_ASC_sq"
case_C@coef.names <- coef_names


case_C_cols <- map(c("^mu_", "^sig_", "_vid1$", "_vid2$", "_nv1$", "_nv2$", "_no_info$"), subcoef, case_C)

texreg(c(case_C_cols[1], remGOF(case_C_cols[2:7])),
       custom.coef.map = list("natural" = "Naturalness", "walking" = "Walking Distance", "rent" = "Rent",
                              "ASC_sq" = "ASC SQ", "_natural" = "Naturalness", "nat" = "Naturalness",
                              "wd" = "Walking Distance", "asc" = "ASC SQ",
                              "ASC_sq_info" = "ASC SQ", "rent_info" = "Rent", "nat_info" = "Naturalness", "walking_info" = "Walking Distance"),
       custom.model.names = c("Mean", "SD", "Video 1", "Video 2", "Text 1", "Text 2", "No Info"), custom.note = "%stars. Robust standard errors in parentheses.",
       stars = c(0.01, 0.05, 0.1), float.pos="tb",
       label = "tab:mxl_C",
       caption = "Results of mixed logit model with treatment interactions for Case B.",
       file="Tables/mxl/case_C_rent_INT.tex")

### Rent NR model case C
case_C_NR <- quicktexregapollo(mxl_wtp_NR_case_c_rentINT)

coef_names <- case_C_NR@coef.names 
coef_names <- sub("^(mu_)(.*)(1|2|info|NR)$", "\\2\\3", coef_names)
coef_names[4] <- "mu_ASC_sq"
case_C_NR@coef.names <- coef_names


case_C_cols_NR <- map(c("^mu_", "^sig_", "_vid1$", "_vid2$", "_nv1$", "_nv2$", "_no_info$", "_NR$"), subcoef, case_C_NR)

texreg(c(case_C_cols_NR[1], remGOF(case_C_cols_NR[2:8])),
       custom.coef.map = list("natural" = "Naturalness", "walking" = "Walking Distance", "rent" = "Rent",
                              "ASC_sq" = "ASC SQ", "_natural" = "Naturalness", "nat" = "Naturalness",
                              "wd" = "Walking Distance", "asc" = "ASC SQ",
                              "ASC_sq_info" = "ASC SQ", "rent_info" = "Rent", "nat_info" = "Naturalness", "walking_info" = "Walking Distance"),
       custom.model.names = c("Mean", "SD", "Video 1", "Video 2", "Text 1", "Text 2", "No Info", "NR"), custom.note = "%stars. Robust standard errors in parentheses.",
       stars = c(0.01, 0.05, 0.1), float.pos="tb",
       label = "tab:mxl_NR",
       caption = "Results of mixed logit model with treatment and NR-index interactions for Case B.",
       file="Tables/mxl/case_C_rent_INT_NR.tex")
# Main model
# texreg(l=list(mxl_wtp_case_a_rentINT),
#        custom.coef.map = list("mu_natural" = "Naturalness", "mu_walking" = "Walking Distance", "mu_rent" = "Rent",
#                               "ASC_sq" = "ASC SQ", "sig_natural" = "Naturalness SD", "sig_walking" = "Walking Distance SD",
#                               "sig_rent" = "Rent SD", "sig_ASC_sq" = "ASC SD",
#                               "mu_nat_T" = "Naturalness X Treated", "mu_wd_T" = "Walking Distance X Treated", "mu_rent_T" = "Rent X Treated",
#                               "mu_asc_T" = "ASC X Treated", "mu_nat_VT" = "Naturalness X Vol. Treated",  "mu_wd_VT" = "Walking Distance X Vol. Treated",  
#                               "mu_rent_VT" = "Rent X Vol. Treated", "mu_asc_VT" = "ASC X Vol. Treated"), 
#        stars = c(0.01, 0.05, 0.1), override.se = mxl_wtp_case_a_rentINT$robse, file="Tables/mxl/case_A_rent_INT.tex")