This script takes the main dataset df_final.rds
and
produces the results of selected tests conducted for different
covariate-defined subgroups and the differences of the estimates across
subgroups. It also implements Romano-Wolf corrections.
Note: Pre-survey outcomes are post-treatment in the case of accuracy nudge tests, so those subgroups are not included.
options(warn=-1)
options(scipen=999)
suppressMessages(library(estimatr))
suppressMessages(library(stats))
suppressMessages(library(tidyverse))
suppressMessages(library(rmarkdown))
suppressMessages(library(tictoc))
suppressMessages(library(stargazer))
suppressMessages(library(ggpattern))
suppressMessages(library(doParallel))
suppressMessages(library(mltools))
suppressMessages(library(data.table))
suppressMessages(library(RItools))
suppressMessages(library(stringr))
suppressMessages(library(grf))
suppressMessages(library(multcomp))
nrCores = detectCores()
cl = makeCluster(nrCores)
registerDoParallel(cl)
clusterEvalQ(cl, {suppressMessages(library(estimatr))
suppressMessages(library(stats))
suppressMessages(library(tidyverse))
suppressMessages(library(rmarkdown))
suppressMessages(library(multcomp))})
## [[1]]
## [1] "multcomp" "TH.data" "MASS" "survival" "mvtnorm" "rmarkdown"
## [7] "lubridate" "forcats" "stringr" "dplyr" "purrr" "readr"
## [13] "tidyr" "tibble" "ggplot2" "tidyverse" "estimatr" "stats"
## [19] "graphics" "grDevices" "utils" "datasets" "methods" "base"
##
## [[2]]
## [1] "multcomp" "TH.data" "MASS" "survival" "mvtnorm" "rmarkdown"
## [7] "lubridate" "forcats" "stringr" "dplyr" "purrr" "readr"
## [13] "tidyr" "tibble" "ggplot2" "tidyverse" "estimatr" "stats"
## [19] "graphics" "grDevices" "utils" "datasets" "methods" "base"
##
## [[3]]
## [1] "multcomp" "TH.data" "MASS" "survival" "mvtnorm" "rmarkdown"
## [7] "lubridate" "forcats" "stringr" "dplyr" "purrr" "readr"
## [13] "tidyr" "tibble" "ggplot2" "tidyverse" "estimatr" "stats"
## [19] "graphics" "grDevices" "utils" "datasets" "methods" "base"
##
## [[4]]
## [1] "multcomp" "TH.data" "MASS" "survival" "mvtnorm" "rmarkdown"
## [7] "lubridate" "forcats" "stringr" "dplyr" "purrr" "readr"
## [13] "tidyr" "tibble" "ggplot2" "tidyverse" "estimatr" "stats"
## [19] "graphics" "grDevices" "utils" "datasets" "methods" "base"
##
## [[5]]
## [1] "multcomp" "TH.data" "MASS" "survival" "mvtnorm" "rmarkdown"
## [7] "lubridate" "forcats" "stringr" "dplyr" "purrr" "readr"
## [13] "tidyr" "tibble" "ggplot2" "tidyverse" "estimatr" "stats"
## [19] "graphics" "grDevices" "utils" "datasets" "methods" "base"
##
## [[6]]
## [1] "multcomp" "TH.data" "MASS" "survival" "mvtnorm" "rmarkdown"
## [7] "lubridate" "forcats" "stringr" "dplyr" "purrr" "readr"
## [13] "tidyr" "tibble" "ggplot2" "tidyverse" "estimatr" "stats"
## [19] "graphics" "grDevices" "utils" "datasets" "methods" "base"
##
## [[7]]
## [1] "multcomp" "TH.data" "MASS" "survival" "mvtnorm" "rmarkdown"
## [7] "lubridate" "forcats" "stringr" "dplyr" "purrr" "readr"
## [13] "tidyr" "tibble" "ggplot2" "tidyverse" "estimatr" "stats"
## [19] "graphics" "grDevices" "utils" "datasets" "methods" "base"
##
## [[8]]
## [1] "multcomp" "TH.data" "MASS" "survival" "mvtnorm" "rmarkdown"
## [7] "lubridate" "forcats" "stringr" "dplyr" "purrr" "readr"
## [13] "tidyr" "tibble" "ggplot2" "tidyverse" "estimatr" "stats"
## [19] "graphics" "grDevices" "utils" "datasets" "methods" "base"
##
## [[9]]
## [1] "multcomp" "TH.data" "MASS" "survival" "mvtnorm" "rmarkdown"
## [7] "lubridate" "forcats" "stringr" "dplyr" "purrr" "readr"
## [13] "tidyr" "tibble" "ggplot2" "tidyverse" "estimatr" "stats"
## [19] "graphics" "grDevices" "utils" "datasets" "methods" "base"
##
## [[10]]
## [1] "multcomp" "TH.data" "MASS" "survival" "mvtnorm" "rmarkdown"
## [7] "lubridate" "forcats" "stringr" "dplyr" "purrr" "readr"
## [13] "tidyr" "tibble" "ggplot2" "tidyverse" "estimatr" "stats"
## [19] "graphics" "grDevices" "utils" "datasets" "methods" "base"
##
## [[11]]
## [1] "multcomp" "TH.data" "MASS" "survival" "mvtnorm" "rmarkdown"
## [7] "lubridate" "forcats" "stringr" "dplyr" "purrr" "readr"
## [13] "tidyr" "tibble" "ggplot2" "tidyverse" "estimatr" "stats"
## [19] "graphics" "grDevices" "utils" "datasets" "methods" "base"
# Computes standard errors of a given continuous variable or one-hot binary variable, respectively #
se_cont = function(x, na.rm=FALSE) {
if (na.rm) x <- na.omit(x)
sqrt(var(x)/length(x))}
se_binary = function(x, na.rm=FALSE) {
if (na.rm) x <- na.omit(x)
sqrt(mean(x)*(1-mean(x))/length(x))}
# Adds the level 'missing' to factor variables #
addmissing = function(x){
if(is.factor(x)) return(factor(x, levels=c(levels(x), "missing")))
return(x)}
# This function takes the main csv as input and outputs a list of dataframes used to conduct the different tests in the analysis #
# It also has the option to apply filtering by attention check status #
pre_processing = function(data,att_check="all"){
# Family 1 subsets to posts that were shared in the pre, then looks at the misinfo counterparts in post #
course_tests_data = data[data$type == "Base posts" & data$pre_post == "pre",]
course_tests_data$share_post = NA
course_tests_data$type_post = NA
#course_tests_data$accuracy_score_post = NA
# non_counterparts subsets to all misinfo posts in the pre and misinfo posts that are not counterparts in the post
non_counterparts_data = data[data$type != "Base posts" & data$pre_post == "pre",]
# Identify who shared 0, 1, 2 or 3 base posts in the pre #
groups = aggregate(share~user,course_tests_data,sum)
colnames(groups) = c("user","group")
course_tests_data = left_join(course_tests_data,groups,by="user")
# Followup preprocessing #
followup_course_tests_data = data[!is.na(data$att_check_followup) & data$type == "Base posts" & data$pre_post == "post",]
followup_course_tests_data$share_followup = NA
followup_course_tests_data$type_followup = NA
followup_course_tests_data$Q4 = NA
followup_course_tests_data$Q5 = NA
# Identify who shared 0, 1, 2 or 3 base posts in the post #
groups_followup = aggregate(share~user,followup_course_tests_data,sum)
colnames(groups_followup) = c("user","group")
followup_course_tests_data = left_join(followup_course_tests_data,groups_followup,by="user")
# For each user #
for (u in unique(course_tests_data$user)){
# Take the vector of facts that were seen in the pre as base #
F = course_tests_data$fact[course_tests_data$user == u]
# Add the non-counterpart posts to that data #
non_counterparts_data = rbind(non_counterparts_data,data[data$user == u & data$type != "Base posts" & data$pre_post == "post" & !data$fact %in% F,])
# For each of these facts #
for (f in F){
# Take the sharing decision of the misinfo counterpart in the post #
course_tests_data$share_post[course_tests_data$user == u & course_tests_data$fact == f] = data$share[data$user == u & data$fact == f & data$pre_post == "post"]
# Take the post type of the misinfo counterpart in the post #
course_tests_data$type_post[course_tests_data$user == u & course_tests_data$fact == f] = data$type[data$user == u & data$fact == f & data$pre_post == "post"]
# Take the post type of the misinfo counterpart in the post #
#course_tests_data$accuracy_score_post[course_tests_data$user == u & course_tests_data$fact == f] = data$accuracy_score[data$user == u & data$fact == f & data$pre_post == "post"]
}
F = followup_course_tests_data$fact[followup_course_tests_data$user == u]
# Extract reflective questions #
followup_course_tests_data$Q4[followup_course_tests_data$user == u] = main_data$reflective_4.contain_course_keyword[main_data$user == u & main_data$order == 1]
followup_course_tests_data$Q5[followup_course_tests_data$user == u] = main_data$reflective_5.contain_course_keyword[main_data$user == u & main_data$order == 1]
# For each of these facts #
for (f in F){
# Take the sharing decision of the misinfo counterpart in the followup #
followup_course_tests_data$share_followup[followup_course_tests_data$user == u & followup_course_tests_data$fact == f] = data$share[data$user == u & data$fact == f & data$pre_post == "followup"]
# Take the post type of the misinfo counterpart in the post #
followup_course_tests_data$type_followup[followup_course_tests_data$user == u & followup_course_tests_data$fact == f] = data$type[data$user == u & data$fact == f & data$pre_post == "followup"]}}
# Main Outcome #
course_tests_data_final = aggregate(share_post~user*group*treatment*accuracy*att_check_pre*att_check_post,course_tests_data[course_tests_data$share == 1,],mean)
#course_tests_data_final$accuracy_score_post = aggregate(accuracy_score_post~user)[,2]
course_tests_data_by_type_final = aggregate(share_post~user*type_post*treatment*accuracy*att_check_pre*att_check_post,course_tests_data[course_tests_data$share == 1,],mean)
#course_tests_data_by_type_final$accuracy_score_post = aggregate(accuracy_score_post~user*type_post,course_tests_data[course_tests_data$share == 1,],mean)[,3]
# Followup Outcome #
followup_course_tests_data_final = aggregate(share_followup~user*group*treatment*priming*att_check_pre*att_check_post*att_check_followup,followup_course_tests_data[followup_course_tests_data$share == 1,],mean)
followup_course_tests_data_by_type_final = aggregate(share_followup~user*treatment*type_followup*att_check_pre*att_check_post*att_check_followup,followup_course_tests_data[followup_course_tests_data$share == 1,],mean)
# Followup text outcomes #
followup_course_text_tests_data_final = aggregate(Q4~user*group*treatment*priming*att_check_pre*att_check_post*att_check_followup,followup_course_tests_data,mean)
colnames(followup_course_text_tests_data_final)[8] = "Q4"
followup_course_text_tests_data_final$Q5 = aggregate(Q5~user*group*treatment*priming*att_check_pre*att_check_post*att_check_followup,followup_course_tests_data,mean)[,8]
# Opposite Outcome #
# Aggregate at the user level by computing averages #
opposite_tests_data_final = aggregate(share_post~user*group*treatment*accuracy*att_check_pre*att_check_post,course_tests_data[course_tests_data$share == 0,],mean) # Subset to those facts that were not shared in the pre (as base) #
#opposite_tests_data_final$accuracy_score_post = aggregate(accuracy_score~user,course_tests_data[course_tests_data$share == 0,],mean)[,2]
# Non-corresponding Outcome #
non_counterparts_data_final = aggregate(share~user*treatment*accuracy*att_check_pre*att_check_post,non_counterparts_data[non_counterparts_data$pre_post=="pre",],mean)
colnames(non_counterparts_data_final)[6] = "pre"
non_counterparts_data_final$post = aggregate(share~user*treatment*accuracy*att_check_pre*att_check_post,non_counterparts_data[non_counterparts_data$pre_post=="post",],mean)[,6]
non_counterparts_data_final$diff = non_counterparts_data_final$post - non_counterparts_data_final$pre
# Outcomes using all misinfo posts #
# Sharing #
all_posts_data_final = aggregate(share~user*treatment*accuracy*att_check_pre*att_check_post,data[data$type!="Base posts" & data$pre_post=="pre",],mean)
colnames(all_posts_data_final)[6] = "share_pre"
all_posts_data_final$share_post = aggregate(share~user*treatment*accuracy*att_check_pre*att_check_post,data[data$type!="Base posts" & data$pre_post=="post",],mean)[,6]
all_posts_data_final$share_diff = all_posts_data_final$share_post - all_posts_data_final$share_pre
# Discernment #
all_posts_data_final$disc_pre = aggregate(disc_score~user*treatment*accuracy*att_check_pre*att_check_post,data[data$pre_post=="pre",],sum)[,6]
all_posts_data_final$disc_post = aggregate(disc_score~user*treatment*accuracy*att_check_pre*att_check_post,data[data$pre_post=="post",],sum)[,6]
all_posts_data_final$disc_diff = all_posts_data_final$disc_post - all_posts_data_final$disc_pre
# Accuracy Discernment #
all_posts_data_final$acc_disc_pre = aggregate(acc_disc_score~user*treatment*accuracy*att_check_pre*att_check_post,data[data$pre_post=="pre",],sum)[,6]
all_posts_data_final$acc_disc_post = aggregate(acc_disc_score~user*treatment*accuracy*att_check_pre*att_check_post,data[data$pre_post=="post",],sum)[,6]
all_posts_data_final$acc_disc_diff = all_posts_data_final$acc_disc_post - all_posts_data_final$acc_disc_pre
# Adding 'course' variable #
course_tests_data_final$course = ifelse(course_tests_data_final$treatment == "No-course Baseline","control",
ifelse(course_tests_data_final$treatment %in% c("Reasoning","Emotions","Combo"),"treatment",NA))
course_tests_data_by_type_final$course = ifelse(course_tests_data_by_type_final$treatment == "No-course Baseline","control",
ifelse(course_tests_data_by_type_final$treatment %in% c("Reasoning","Emotions","Combo"),"treatment",NA))
followup_course_tests_data_final$course = ifelse(followup_course_tests_data_final$treatment == "No-course Baseline","control",
ifelse(followup_course_tests_data_final$treatment %in% c("Reasoning","Emotions","Combo"),"treatment",NA))
followup_course_tests_data_by_type_final$course = ifelse(followup_course_tests_data_by_type_final$treatment == "No-course Baseline","control",
ifelse(followup_course_tests_data_by_type_final$treatment %in% c("Reasoning","Emotions","Combo"),"treatment",NA))
followup_course_text_tests_data_final$course = ifelse(followup_course_text_tests_data_final$treatment == "No-course Baseline","control",
ifelse(followup_course_text_tests_data_final$treatment %in% c("Reasoning","Emotions","Combo"),"treatment",NA))
opposite_tests_data_final$course = ifelse(opposite_tests_data_final$treatment == "No-course Baseline","control",
ifelse(opposite_tests_data_final$treatment %in% c("Reasoning","Emotions","Combo"),"treatment",NA))
non_counterparts_data_final$course = ifelse(non_counterparts_data_final$treatment == "No-course Baseline","control",
ifelse(non_counterparts_data_final$treatment %in% c("Reasoning","Emotions","Combo"),"treatment",NA))
all_posts_data_final$course = ifelse(all_posts_data_final$treatment == "No-course Baseline","control",
ifelse(all_posts_data_final$treatment %in% c("Reasoning","Emotions","Combo"),"treatment",NA))
# Apply attention check filter as specified #
if(att_check == "passed"){
return(list("course_tests_data_final"=course_tests_data_final[course_tests_data_final$att_check_pre=="1" & course_tests_data_final$att_check_post=="1",],
"course_tests_data_by_type_final" = course_tests_data_by_type_final[course_tests_data_by_type_final$att_check_pre=="1" & course_tests_data_by_type_final$att_check_post=="1",],
"followup_course_tests_data_final" = followup_course_tests_data_final[followup_course_tests_data_final$att_check_pre=="1" & followup_course_tests_data_final$att_check_post=="1" &followup_course_tests_data_final$att_check_followup=="1",],
"followup_course_tests_data_by_type_final" = followup_course_tests_data_by_type_final[followup_course_tests_data_by_type_final$att_check_pre=="1" & followup_course_tests_data_by_type_final$att_check_post=="1" &followup_course_tests_data_by_type_final$att_check_followup=="1",],
"followup_course_text_tests_data_final" = followup_course_text_tests_data_final[followup_course_tests_data_final$att_check_pre=="1" & followup_course_tests_data_final$att_check_post=="1" &followup_course_tests_data_final$att_check_followup=="1",],
"opposite_tests_data_final" = opposite_tests_data_final[opposite_tests_data_final$att_check_pre=="1" & opposite_tests_data_final$att_check_post=="1",],
"non_counterparts_data_final" = non_counterparts_data_final[non_counterparts_data_final$att_check_pre=="1" & non_counterparts_data_final$att_check_post=="1",],
"all_posts_data_final" = all_posts_data_final[all_posts_data_final$att_check_pre=="1" & all_posts_data_final$att_check_post=="1",]))}
if(att_check == "not_passed"){
return(list("course_tests_data_final"=course_tests_data_final[course_tests_data_final$att_check_pre=="0" & course_tests_data_final$att_check_post=="0",],
"course_tests_data_by_type_final" = course_tests_data_by_type_final[course_tests_data_by_type_final$att_check_pre=="0" & course_tests_data_by_type_final$att_check_post=="0",],
"followup_course_tests_data_final" = followup_course_tests_data_final[followup_course_tests_data_final$att_check_pre=="0" & followup_course_tests_data_final$att_check_post=="0" &followup_course_tests_data_final$att_check_followup=="0",],
"followup_course_tests_data_by_type_final" = followup_course_tests_data_by_type_final[followup_course_tests_data_by_type_final$att_check_pre=="0" & followup_course_tests_data_by_type_final$att_check_post=="0" &followup_course_tests_data_by_type_final$att_check_followup=="0",],
"followup_course_text_tests_data_final" = followup_course_text_tests_data_final[followup_course_tests_data_final$att_check_pre=="0" & followup_course_tests_data_final$att_check_post=="0" &followup_course_tests_data_final$att_check_followup=="0",],
"opposite_tests_data_final" = opposite_tests_data_final[opposite_tests_data_final$att_check_pre=="0" & opposite_tests_data_final$att_check_post=="0",],
"non_counterparts_data_final" = non_counterparts_data_final[non_counterparts_data_final$att_check_pre=="0" & non_counterparts_data_final$att_check_post=="0",],
"all_posts_data_final" = all_posts_data_final[all_posts_data_final$att_check_pre=="0" & all_posts_data_final$att_check_post=="0",]))}
if(att_check == "all"){
return(list("course_tests_data_final"=course_tests_data_final,
"course_tests_data_by_type_final" = course_tests_data_by_type_final,
"followup_course_tests_data_final" = followup_course_tests_data_final,
"followup_course_text_tests_data_final" = followup_course_text_tests_data_final,
"followup_course_tests_data_by_type_final" = followup_course_tests_data_by_type_final,
"opposite_tests_data_final" = opposite_tests_data_final,
"non_counterparts_data_final" = non_counterparts_data_final,
"all_posts_data_final" = all_posts_data_final))}
}
data = read_rds("../../intermediate_outcomes/intermediate_data_wide.rds")
data$social_media_share_above_40 = data$social_media_share_40_60 + data$social_media_share_60_80 + data$social_media_share_80_100
# Create vectors with names and display names of covariates by type to use later #
covariates_continuous = c("age","social_media_hours","base_rate_pre","base_total_acc_score_pre",
"misinfo_pre","misinfo_total_acc_score_pre")
covariates_categorical = c("gender_Man","education_High_school_or_less","marital_Married_or_in_a_domestic_partnership",
"location_Mostly_rural","religion_Christian","religiosity_Attends",
"social_media_share_above_40","att_check_pre")
subgroups_all = covariates_categorical
# Add percentile based subgroups (for continuous covariates #
for (cov in covariates_continuous){
percs = ntile(data[,cov],4)
data$med = factor(ifelse(!is.na(percs) & (percs == 1 | percs == 2),"M1",
ifelse(!is.na(percs) & (percs == 3 | percs == 4),"M2",NA)))
# data_covs$quart = factor(ifelse(!is.na(percs) & percs == 1,"Q1",
# ifelse(!is.na(percs) & percs == 2,NA, # Replace NA with Q2 as desired #
# ifelse(!is.na(percs) & percs == 3,NA, # Replace NA with Q3 as desired #
# ifelse(!is.na(percs) & percs == 4,"Q4",NA)))))
colnames(data)[ncol(data)] = paste(cov,c("_med"),sep="")
subgroups_all = c(subgroups_all,paste(cov,c("_med"),sep=""))}
# Reorder subgroups #
subgroups_all = c(subgroups_all[startsWith(subgroups_all,"age")],subgroups_all[!startsWith(subgroups_all,"age")])
subgroups_all = c(subgroups_all[!startsWith(subgroups_all,"social_media") & !startsWith(subgroups_all,"share_pre") & !startsWith(subgroups_all,"acc_disc_score_pre") & !startsWith(subgroups_all,"att_check")],
subgroups_all[startsWith(subgroups_all,"social_media_hours")],subgroups_all[startsWith(subgroups_all,"social_media_share")],
subgroups_all[startsWith(subgroups_all,"share_pre")], subgroups_all[startsWith(subgroups_all,"acc_disc")],subgroups_all[startsWith(subgroups_all,"att_check")])
# Mutate subgroup variables to factor #
data[,subgroups_all] = lapply(data[,subgroups_all], as.factor)
# Add treatment indicators for each test #
data$treatment_6 = recode(data$treatment,"Reasoning"="1","Emotions" = "no","Combo" = "no","No-course Baseline" = "no","Facts Baseline" = "0")
data$treatment_7 = recode(data$treatment,"Reasoning"="no","Emotions" = "1","Combo" = "no","No-course Baseline" = "no","Facts Baseline" = "0")
data$treatment_8 = recode(data$treatment,"Reasoning"="no","Emotions" = "no","Combo" = "1","No-course Baseline" = "no","Facts Baseline" = "0")
data$treatment_9 = recode(data$treatment,"Reasoning"="no","Emotions" = "no","Combo" = "no","No-course Baseline" = "0","Facts Baseline" = "1")
data$treatment_10 = recode(data$treatment,"Reasoning"="1","Emotions" = "0","Combo" = "no","No-course Baseline" = "no","Facts Baseline" = "no")
data$treatment_11 = recode(data$treatment,"Reasoning"="1","Emotions" = "no","Combo" = "0","No-course Baseline" = "no","Facts Baseline" = "no")
data$treatment_12 = recode(data$treatment,"Reasoning"="no","Emotions" = "1","Combo" = "0","No-course Baseline" = "no","Facts Baseline" = "no")
data[,startsWith(colnames(data),"treatment_") & !startsWith(colnames(data),"treatment_end")] = sapply(data[,startsWith(colnames(data),"treatment_") & !startsWith(colnames(data),"treatment_end")],function(x){na_if(x,"no")})
# Pre-allocate dataframe #
subgroup_results = data.frame(matrix(NA,0,6))
#pre_subgroup_results = data.frame(matrix(NA,0,6))
tests_of_interest <- c(7, 8, 12)
# Compute each test for each of the defined subgroups #
# Iterate over desired tests #
for (test in tests_of_interest){
# Create a temporary dataframe #
by_test_subgroup_results = data.frame(matrix(NA,0,6))
# Iterate over subgroups #
for (cov in subgroups_all){
# Create the formula so that the treatment effects for each subgroup are included in the regression, and not the diff-in-diff #
form = formula(paste("misinfo_diff ~ 0 + treatment_",test,"*", cov," - treatment_",test,sep=""))
# Linear model to estimate treatment effects by subgroup #
model = lm_robust(form,data)
# Quasipoisson model to estimate treatment effects as a percentage of the baseline by subgroup (Poisson model assumes equality of mean and variance, this breaks it) #
#model_perc = glm(form, family = 'quasipoisson', data)
# Extract output from the regressions #
baselines = coef(summary(model))[!startsWith(rownames(coef(summary(model))),"treatment"),][,1]
coefs = coef(summary(model))[startsWith(rownames(coef(summary(model))),"treatment"),][,1:4]
# Add number of observations by subgroup #
obs = table(data[cov])
# Define the diff-in-diff coefficients as required by multcomp package #
coefs = cbind(baselines,coefs,obs)
rownames(coefs) = paste("treatment_",test,"1:",rownames(coefs),sep="")
colnames(coefs) = NULL
hyp_names = combn(rownames(coefs),2)
# Iterate over differences in subgroups #
hyps = c()
for (h in 1:ncol(hyp_names)){
hyps = c(hyps,paste(hyp_names[1,h],"-",hyp_names[2,h],"= 0"))}
# Extract results and fill the dataframe #
comps = summary(glht(model, hyps),test=adjusted("none"))
#comps2 = summary(glht(model_perc, hyps),test=adjusted("none"))
comps_results = cbind(NA,comps$test$coefficients,comps$test$sigma,comps$test$tstat,comps$test$pvalues,NA)
rownames(comps_results) = paste(rownames(comps_results),"_lev",sep="")
#comps2_results = cbind(NA,comps2$test$coefficients,comps2$test$sigma,comps2$test$tstat,comps2$test$pvalues,NA)
#rownames(comps2_results) = paste(rownames(comps2_results),"_perc",sep="")
by_test_subgroup_results = rbind(by_test_subgroup_results, coefs, comps_results
#,comps2_results
)}
rownames(by_test_subgroup_results) = paste("test_",test,str_replace_all(rownames(by_test_subgroup_results),paste("treatment_",test,"1",sep=""),""),sep="")
subgroup_results = rbind(subgroup_results ,by_test_subgroup_results)}
# by_test_subgroup_results = data.frame(matrix(NA,0,6))
# for (cov in pre_subgroups){
# form = formula(paste("share_pre ~ 0+",cov,sep=""))
# model = lm_robust(form,pre_data)
# hyp_names = combn(rownames(coef(summary(model))),2)
# hyps = c()
# for (h in 1:ncol(hyp_names)){
# hyps = c(hyps,paste(hyp_names[1,h],"-",hyp_names[2,h],"= 0"))}
# comps = summary(glht(model, hyps),test=adjusted("none"))
# comps_results = cbind(NA,comps$test$coefficients,comps$test$sigma,comps$test$tstat,comps$test$pvalues,NA)
# by_test_subgroup_results = rbind(by_test_subgroup_results, comps_results)
# rownames(by_test_subgroup_results) = paste("test_",test,":",rownames(by_test_subgroup_results),sep="")
# pre_subgroup_results = rbind(pre_subgroup_results,by_test_subgroup_results)}
# Rename columns after stacking #
colnames(subgroup_results) = c("baseline","estimate","std.err","ts","p_val","obs")
#colnames(pre_subgroup_results) = c("baseline","estimate","std.err","ts","p_val","obs")
# Construct confidence intervals taking into account one and two-sided tests #
subgroup_results$CI_low = ifelse(is.na(subgroup_results$obs),subgroup_results$estimate - 1.96*subgroup_results$std.err,-Inf)
subgroup_results$CI_upp = ifelse(is.na(subgroup_results$obs),subgroup_results$estimate + 1.96*subgroup_results$std.err,subgroup_results$estimate + 1.64*subgroup_results$std.err)
subgroup_results$CI_low[startsWith(rownames(subgroup_results),"test_10")] = subgroup_results$estimate[startsWith(rownames(subgroup_results),"test_10")] - 1.96*subgroup_results$std.err[startsWith(rownames(subgroup_results),"test_10")]
subgroup_results$CI_low[startsWith(rownames(subgroup_results),"test_11")] = subgroup_results$estimate[startsWith(rownames(subgroup_results),"test_11")] - 1.96*subgroup_results$std.err[startsWith(rownames(subgroup_results),"test_11")]
subgroup_results$CI_low[startsWith(rownames(subgroup_results),"test_12")] = subgroup_results$estimate[startsWith(rownames(subgroup_results),"test_12")] - 1.96*subgroup_results$std.err[startsWith(rownames(subgroup_results),"test_12")]
#pre_subgroup_results$CI_low = pre_subgroup_results$estimate - 1.96*pre_subgroup_results$std.err
#pre_subgroup_results$CI_upp = pre_subgroup_results$estimate + 1.96*pre_subgroup_results$std.err
write.csv(subgroup_results, "tables/misinfo_diff_subgroup.csv")
This part of the script applies the Romano-Wolf correction. Even though it is parallelized, it takes a long time. Please look at https://docs.iza.org/dp12845.pdf for references.
# Since we have two-sided tests along with one-sided tests, we need to adapt the two-sided statistics accordingly: #
# Identify the tests that are two sided #
two_sided = rownames(subgroup_results)[!is.infinite(subgroup_results$CI_low)]
# We create the dataframes with the results separately by hypothesis involving differences in levels, differences in percentage changes, and treatment effect by subgroups #
sorted_orig_lev = subgroup_results[endsWith(rownames(subgroup_results),"lev"),]
#sorted_orig_perc = subgroup_results[endsWith(rownames(subgroup_results),"perc"),]
sorted_orig_single = subgroup_results[!endsWith(rownames(subgroup_results),"lev") & ! endsWith(rownames(subgroup_results),"perc"),]
# We check if we reject the null hypothesis using the unadjusted p-values
alpha = 0.05
sorted_orig_lev$reject = sorted_orig_lev$p_val < alpha
#sorted_orig_perc$reject = sorted_orig_perc$p_val < alpha
sorted_orig_single$reject = sorted_orig_single$p_val < alpha
# We adapt the t-statistic of the two-sided tests:
sorted_orig_lev[rownames(sorted_orig_lev) %in% two_sided,"ts"] = -abs(sorted_orig_lev[rownames(sorted_orig_lev) %in% two_sided,"ts"])
#sorted_orig_perc[rownames(sorted_orig_perc) %in% two_sided,"ts"] = -abs(sorted_orig_perc[rownames(sorted_orig_perc) %in% two_sided,"ts"])
sorted_orig_single[rownames(sorted_orig_single) %in% two_sided,"ts"] = -abs(sorted_orig_single[rownames(sorted_orig_single) %in% two_sided,"ts"])
# We sort the hypotheses by the size of the original t-statistic #
sorted_orig_lev = sorted_orig_lev[order(sorted_orig_lev$ts),]
#sorted_orig_perc = sorted_orig_perc[order(sorted_orig_perc$ts),]
sorted_orig_single = sorted_orig_single[order(sorted_orig_single$ts),]
# Now that we have what we need, we can implement Romano-Wolf correction #
# We need to bootstrap the sample B times (this essentially means sample with replacement keeping n constant) and compute #
# the "null statistics" of each hypothesis we are testing for each bootstrapped sample. These require three elements: #
# 1) the original estimates --we already got those-- #
# 2) the same estimates but computed from the bootstrapped sample #
# 3) the standard errors from 2 #
B = 1000
num_hyp_lev = nrow(sorted_orig_lev)
#num_hyp_perc = nrow(sorted_orig_perc)
num_hyp_single = nrow(sorted_orig_single)
RW = function(b){
# We sample with replacement the indices which will make up our bootstrap sample #
idx = sample(1:nrow(data),nrow(data),TRUE)
boot_data = data[idx,]
# We repeat exactly the same procedure as before to get the bootstrap estimates and standard errors #
boot_subgroup_results = data.frame(matrix(NA,nrow=0,ncol=2))
for (test in tests_of_interest){
boot_by_test_subgroup_results = data.frame(matrix(NA,0,2))
for (cov in subgroups_all){
form = formula(paste("misinfo_diff ~ 0 + treatment_",test,"*", cov," - treatment_",test,sep=""))
model = lm_robust(form,boot_data)
#model_perc = glm(form, family = 'quasipoisson', boot_data)
coefs = coef(summary(model))[startsWith(rownames(coef(summary(model))),"treatment"),][,1:2]
colnames(coefs) = NULL
hyp_names = combn(rownames(coefs),2)
hyps = c()
for (h in 1:ncol(hyp_names)){
hyps = c(hyps,paste(hyp_names[1,h],"-",hyp_names[2,h],"= 0"))}
comps = summary(glht(model, hyps),test=adjusted("none"))
#comps2 = summary(glht(model_perc, hyps),test=adjusted("none"))
comps_results = cbind(comps$test$coefficients,comps$test$sigma)
rownames(comps_results) = paste(rownames(comps_results),"_lev",sep="")
#comps2_results = cbind(comps2$test$coefficients,comps2$test$sigma)
#rownames(comps2_results) = paste(rownames(comps2_results),"_perc",sep="")
boot_by_test_subgroup_results = rbind(boot_by_test_subgroup_results, coefs, comps_results
#, comps2_results
)}
rownames(boot_by_test_subgroup_results) = paste("test_",test,str_replace_all(rownames(boot_by_test_subgroup_results),paste("treatment_",test,"1",sep=""),""),sep="")
boot_subgroup_results = rbind(boot_subgroup_results,boot_by_test_subgroup_results)}
colnames(boot_subgroup_results) = c("estimate","std.err")
# The null statistic is computed by subtracting the original estimate from the bootstrap sample and dividing #
# by the standard error of the bootstraped estimate #
# Remember the absolute value since we are testing a two-sided hypothesis #
# Also, note that we sort the columns of the bootstrapped statistics by the order of significance as required by RW #
Bs_lev = (boot_subgroup_results[rownames(sorted_orig_lev),"estimate"] - sorted_orig_lev$estimate)/boot_subgroup_results[rownames(sorted_orig_lev),"std.err"]
#Bs_perc = (boot_subgroup_results[rownames(sorted_orig_perc),"estimate"] - sorted_orig_perc$estimate)/boot_subgroup_results[rownames(sorted_orig_perc),"std.err"]
Bs_single = (boot_subgroup_results[rownames(sorted_orig_single),"estimate"] - sorted_orig_single$estimate)/boot_subgroup_results[rownames(sorted_orig_single),"std.err"]
return(rbind(Bs_lev,
#Bs_perc,
Bs_single))}
# Run the RW function using parallelization #
start_time <- Sys.time()
set.seed(777)
boot_output = foreach(b = 1:B) %dopar% RW(b)
bootstrapped_statistics = do.call(rbind.data.frame, boot_output)
end_time <- Sys.time()
end_time - start_time
## Time difference of 22.47259 secs
# Convert the output to dataframes #
bootstrapped_statistics_lev = bootstrapped_statistics[startsWith(rownames(bootstrapped_statistics),"Bs_lev"),1:nrow(sorted_orig_lev)]
#bootstrapped_statistics_perc = bootstrapped_statistics[startsWith(rownames(bootstrapped_statistics),"Bs_perc"),1:nrow(sorted_orig_perc)]
bootstrapped_statistics_single = bootstrapped_statistics[startsWith(rownames(bootstrapped_statistics),"Bs_single"),1:nrow(sorted_orig_single)]
# Important, we keep the order of the sorted set of hypotheses #
colnames(bootstrapped_statistics_lev) = rownames(sorted_orig_lev)
#colnames(bootstrapped_statistics_perc) = rownames(sorted_orig_perc)
colnames(bootstrapped_statistics_single) = rownames(sorted_orig_single)
# We adapt the t-statistics of the two-sided tests:
bootstrapped_statistics_lev[rownames(sorted_orig_lev) %in% two_sided] = -abs(bootstrapped_statistics_lev[rownames(sorted_orig_lev) %in% two_sided])
#bootstrapped_statistics_perc[rownames(sorted_orig_perc) %in% two_sided] = -abs(bootstrapped_statistics_perc[rownames(sorted_orig_perc) %in% two_sided])
bootstrapped_statistics_single[rownames(sorted_orig_single) %in% two_sided] = -abs(bootstrapped_statistics_single[rownames(sorted_orig_single) %in% two_sided])
# Now we compute the "max" statistics and the empirical quantiles #
min_stats_lev = data.frame(matrix(NA,B,num_hyp_lev))
colnames(min_stats_lev) = colnames(bootstrapped_statistics_lev)
for (h in 1:(num_hyp_lev-1)){
min_stats_lev[,h] = apply(bootstrapped_statistics_lev[,h:num_hyp_lev], MARGIN=1, FUN=min)}
min_stats_lev[,num_hyp_lev] = bootstrapped_statistics_lev[,num_hyp_lev]
# Now we compute the "max" statistics and the empirical quantiles #
# min_stats_perc = data.frame(matrix(NA,B,num_hyp_perc))
# colnames(min_stats_perc) = colnames(bootstrapped_statistics_perc)
# for (h in 1:(num_hyp_perc-1)){
# min_stats_perc[,h] = apply(bootstrapped_statistics_perc[,h:num_hyp_perc], MARGIN=1, FUN=min)}
# min_stats_perc[,num_hyp_perc] = bootstrapped_statistics_perc[,num_hyp_perc]
# Now we compute the "max" statistics and the empirical quantiles #
min_stats_single = data.frame(matrix(NA,B,num_hyp_single))
colnames(min_stats_single) = colnames(bootstrapped_statistics_single)
for (h in 1:(num_hyp_single-1)){
min_stats_single[,h] = apply(bootstrapped_statistics_single[,h:num_hyp_single], MARGIN=1, FUN=min)}
min_stats_single[,num_hyp_single] = bootstrapped_statistics_single[,num_hyp_single]
# And the empirical quantiles given the significance level #
Cs_lev = unname(apply(min_stats_lev, MARGIN=2, FUN=quantile, probs=c(alpha)))
# And the empirical quantiles given the significance level #
#Cs_perc = unname(apply(min_stats_perc, MARGIN=2, FUN=quantile, probs=c(alpha)))
# And the empirical quantiles given the significance level #
Cs_single = unname(apply(min_stats_single, MARGIN=2, FUN=quantile, probs=c(alpha)))
# And finally we run the rejection algorithm
sorted_orig_lev$adjust_rejected = NA
# R will index the hypothesis we need to test at each round
R = 1
# r will be the counter of rejected hypotheses at each round
r = Inf
# The while loop stops if no hypotheses are rejected in a round or if we reject all.
while (r > 0 & R <= num_hyp_lev){
# We compare the original t-statistics of the hypotheses we haven't tested at each round with the quantiles
sorted_orig_lev$adjust_rejected[R:num_hyp_lev] = (sorted_orig_lev$ts[R:num_hyp_lev] < Cs_lev[R])
r = sum(sorted_orig_lev$adjust_rejected[R:num_hyp_lev])
R = r + R}
# # And finally we run the rejection algorithm
# sorted_orig_perc$adjust_rejected = NA
# # R will index the hypothesis we need to test at each round
# R = 1
# # r will be the counter of rejected hypotheses at each round
# r = Inf
# # The while loop stops if no hypotheses are rejected in a round or if we reject all.
# while (r > 0 & R <= num_hyp_perc){
# # We compare the original t-statistics of the hypotheses we haven't tested at each round with the quantiles
# sorted_orig_perc$adjust_rejected[R:num_hyp_perc] = (sorted_orig_perc$ts[R:num_hyp_perc] < Cs_perc[R])
# r = sum(sorted_orig_perc$adjust_rejected[R:num_hyp_perc])
# R = r + R}
# And finally we run the rejection algorithm
sorted_orig_single$adjust_rejected = NA
# R will index the hypothesis we need to test at each round
R = 1
# r will be the counter of rejected hypotheses at each round
r = Inf
# The while loop stops if no hypotheses are rejected in a round or if we reject all.
while (r > 0 & R <= num_hyp_single){
# We compare the original t-statistics of the hypotheses we haven't tested at each round with the quantiles
sorted_orig_single$adjust_rejected[R:num_hyp_single] = (sorted_orig_single$ts[R:num_hyp_single] < Cs_single[R])
r = sum(sorted_orig_single$adjust_rejected[R:num_hyp_single])
R = r + R}
# We can also compute the adjusted p-values
sorted_orig_lev$p_val_RW = NA
sorted_orig_lev$p_val_RW[1] = (sum(min_stats_lev[,1]<=sorted_orig_lev$ts[1])+1)/(B+1)
for (h in 2:num_hyp_lev){
sorted_orig_lev$p_val_RW[h] = max((sum(min_stats_lev[,h]<=sorted_orig_lev$ts[h])+1)/(B+1), sorted_orig_lev$p_val_RW[h-1])}
# # We can also compute the adjusted p-values
# sorted_orig_perc$p_val_RW = NA
# sorted_orig_perc$p_val_RW[1] = (sum(min_stats_perc[,1]<=sorted_orig_perc$ts[1])+1)/(B+1)
# for (h in 2:num_hyp_perc){
# sorted_orig_perc$p_val_RW[h] = max((sum(min_stats_perc[,h]<=sorted_orig_perc$ts[h])+1)/(B+1), sorted_orig_perc$p_val_RW[h-1])}
# We can also compute the adjusted p-values
sorted_orig_single$p_val_RW = NA
sorted_orig_single$p_val_RW[1] = (sum(min_stats_single[,1]<=sorted_orig_single$ts[1])+1)/(B+1)
for (h in 2:num_hyp_single){
sorted_orig_single$p_val_RW[h] = max((sum(min_stats_single[,h]<=sorted_orig_single$ts[h])+1)/(B+1), sorted_orig_single$p_val_RW[h-1])}
#Compare them to Bonferroni's and Holm's p-values (note that the minimum p-value in RW is 1/(B+1))
sorted_orig_lev$p_val_bonf = p.adjust(sorted_orig_lev$p_val,"bonferroni")
sorted_orig_lev$p_val_holm = p.adjust(sorted_orig_lev$p_val,"holm")
# # Compare them to Bonferroni's p-values (note that the minimum p-value in RW is 1/(B+1))
# sorted_orig_perc$p_val_bonf = p.adjust(sorted_orig_perc$p_val,"bonferroni")
# sorted_orig_perc$p_val_holm = p.adjust(sorted_orig_perc$p_val,"holm")
# Compare them to Bonferroni's p-values (note that the minimum p-value in RW is 1/(B+1))
sorted_orig_single$p_val_bonf = p.adjust(sorted_orig_single$p_val,"bonferroni")
sorted_orig_single$p_val_holm = p.adjust(sorted_orig_single$p_val,"holm")
# Stack results #
final = rbind(sorted_orig_lev,
#sorted_orig_perc,
sorted_orig_single)
# Filter columns #
final_subgroup_results = final[rownames(final),c("obs","baseline","estimate","std.err","CI_low","CI_upp","p_val","p_val_holm","p_val_RW")]
# Extract the name of the tests #
tests = rownames(final_subgroup_results)
tests
## [1] "test_7:misinfo_pre_medM1 - :misinfo_pre_medM2_lev"
## [2] "test_7:base_rate_pre_medM1 - :base_rate_pre_medM2_lev"
## [3] "test_7:misinfo_total_acc_score_pre_medM1 - :misinfo_total_acc_score_pre_medM2_lev"
## [4] "test_8:misinfo_pre_medM1 - :misinfo_pre_medM2_lev"
## [5] "test_8:base_rate_pre_medM1 - :base_rate_pre_medM2_lev"
## [6] "test_7:base_total_acc_score_pre_medM1 - :base_total_acc_score_pre_medM2_lev"
## [7] "test_8:att_check_pre0 - :att_check_pre1_lev"
## [8] "test_12:att_check_pre0 - :att_check_pre1_lev"
## [9] "test_8:base_total_acc_score_pre_medM1 - :base_total_acc_score_pre_medM2_lev"
## [10] "test_12:misinfo_pre_medM1 - :misinfo_pre_medM2_lev"
## [11] "test_12:misinfo_total_acc_score_pre_medM1 - :misinfo_total_acc_score_pre_medM2_lev"
## [12] "test_7:social_media_share_above_400 - :social_media_share_above_401_lev"
## [13] "test_8:location_Mostly_rural0 - :location_Mostly_rural1_lev"
## [14] "test_8:misinfo_total_acc_score_pre_medM1 - :misinfo_total_acc_score_pre_medM2_lev"
## [15] "test_8:education_High_school_or_less0 - :education_High_school_or_less1_lev"
## [16] "test_12:education_High_school_or_less0 - :education_High_school_or_less1_lev"
## [17] "test_12:location_Mostly_rural0 - :location_Mostly_rural1_lev"
## [18] "test_12:age_medM1 - :age_medM2_lev"
## [19] "test_7:gender_Man0 - :gender_Man1_lev"
## [20] "test_12:social_media_share_above_400 - :social_media_share_above_401_lev"
## [21] "test_12:base_rate_pre_medM1 - :base_rate_pre_medM2_lev"
## [22] "test_8:gender_Man0 - :gender_Man1_lev"
## [23] "test_7:age_medM1 - :age_medM2_lev"
## [24] "test_12:base_total_acc_score_pre_medM1 - :base_total_acc_score_pre_medM2_lev"
## [25] "test_8:social_media_hours_medM1 - :social_media_hours_medM2_lev"
## [26] "test_8:social_media_share_above_400 - :social_media_share_above_401_lev"
## [27] "test_7:marital_Married_or_in_a_domestic_partnership0 - :marital_Married_or_in_a_domestic_partnership1_lev"
## [28] "test_12:social_media_hours_medM1 - :social_media_hours_medM2_lev"
## [29] "test_8:religion_Christian0 - :religion_Christian1_lev"
## [30] "test_8:marital_Married_or_in_a_domestic_partnership0 - :marital_Married_or_in_a_domestic_partnership1_lev"
## [31] "test_8:age_medM1 - :age_medM2_lev"
## [32] "test_12:religion_Christian0 - :religion_Christian1_lev"
## [33] "test_8:religiosity_Attends0 - :religiosity_Attends1_lev"
## [34] "test_12:marital_Married_or_in_a_domestic_partnership0 - :marital_Married_or_in_a_domestic_partnership1_lev"
## [35] "test_7:social_media_hours_medM1 - :social_media_hours_medM2_lev"
## [36] "test_12:gender_Man0 - :gender_Man1_lev"
## [37] "test_7:att_check_pre0 - :att_check_pre1_lev"
## [38] "test_12:religiosity_Attends0 - :religiosity_Attends1_lev"
## [39] "test_7:religiosity_Attends0 - :religiosity_Attends1_lev"
## [40] "test_7:religion_Christian0 - :religion_Christian1_lev"
## [41] "test_7:location_Mostly_rural0 - :location_Mostly_rural1_lev"
## [42] "test_7:education_High_school_or_less0 - :education_High_school_or_less1_lev"
## [43] "test_7:misinfo_pre_medM2"
## [44] "test_7:base_rate_pre_medM2"
## [45] "test_7:religion_Christian1"
## [46] "test_7:religiosity_Attends1"
## [47] "test_7:misinfo_total_acc_score_pre_medM2"
## [48] "test_7:base_total_acc_score_pre_medM2"
## [49] "test_8:religion_Christian1"
## [50] "test_7:social_media_share_above_401"
## [51] "test_7:education_High_school_or_less0"
## [52] "test_8:religiosity_Attends1"
## [53] "test_8:misinfo_pre_medM2"
## [54] "test_8:base_rate_pre_medM2"
## [55] "test_8:education_High_school_or_less0"
## [56] "test_7:location_Mostly_rural0"
## [57] "test_8:att_check_pre0"
## [58] "test_7:age_medM1"
## [59] "test_7:marital_Married_or_in_a_domestic_partnership0"
## [60] "test_8:base_total_acc_score_pre_medM2"
## [61] "test_8:social_media_share_above_401"
## [62] "test_7:gender_Man1"
## [63] "test_7:att_check_pre0"
## [64] "test_8:marital_Married_or_in_a_domestic_partnership0"
## [65] "test_7:social_media_hours_medM1"
## [66] "test_8:misinfo_total_acc_score_pre_medM2"
## [67] "test_7:social_media_hours_medM2"
## [68] "test_8:social_media_hours_medM2"
## [69] "test_7:att_check_pre1"
## [70] "test_7:gender_Man0"
## [71] "test_8:age_medM2"
## [72] "test_8:gender_Man1"
## [73] "test_8:location_Mostly_rural0"
## [74] "test_7:age_medM2"
## [75] "test_8:location_Mostly_rural1"
## [76] "test_8:gender_Man0"
## [77] "test_8:age_medM1"
## [78] "test_7:marital_Married_or_in_a_domestic_partnership1"
## [79] "test_7:location_Mostly_rural1"
## [80] "test_8:misinfo_total_acc_score_pre_medM1"
## [81] "test_8:social_media_hours_medM1"
## [82] "test_8:marital_Married_or_in_a_domestic_partnership1"
## [83] "test_7:education_High_school_or_less1"
## [84] "test_7:base_total_acc_score_pre_medM1"
## [85] "test_7:social_media_share_above_400"
## [86] "test_8:social_media_share_above_400"
## [87] "test_7:misinfo_total_acc_score_pre_medM1"
## [88] "test_8:base_total_acc_score_pre_medM1"
## [89] "test_8:misinfo_pre_medM1"
## [90] "test_8:att_check_pre1"
## [91] "test_8:base_rate_pre_medM1"
## [92] "test_7:base_rate_pre_medM1"
## [93] "test_7:misinfo_pre_medM1"
## [94] "test_8:education_High_school_or_less1"
## [95] "test_7:religiosity_Attends0"
## [96] "test_12:att_check_pre1"
## [97] "test_8:religiosity_Attends0"
## [98] "test_7:religion_Christian0"
## [99] "test_12:misinfo_total_acc_score_pre_medM2"
## [100] "test_12:misinfo_pre_medM2"
## [101] "test_12:education_High_school_or_less1"
## [102] "test_12:location_Mostly_rural0"
## [103] "test_12:age_medM1"
## [104] "test_12:social_media_share_above_401"
## [105] "test_8:religion_Christian0"
## [106] "test_12:base_rate_pre_medM2"
## [107] "test_12:base_total_acc_score_pre_medM2"
## [108] "test_12:social_media_hours_medM1"
## [109] "test_12:religiosity_Attends1"
## [110] "test_12:religion_Christian1"
## [111] "test_12:misinfo_pre_medM1"
## [112] "test_12:att_check_pre0"
## [113] "test_12:misinfo_total_acc_score_pre_medM1"
## [114] "test_12:gender_Man0"
## [115] "test_12:marital_Married_or_in_a_domestic_partnership1"
## [116] "test_12:gender_Man1"
## [117] "test_12:marital_Married_or_in_a_domestic_partnership0"
## [118] "test_12:religion_Christian0"
## [119] "test_12:location_Mostly_rural1"
## [120] "test_12:social_media_hours_medM2"
## [121] "test_12:social_media_share_above_400"
## [122] "test_12:base_total_acc_score_pre_medM1"
## [123] "test_12:education_High_school_or_less0"
## [124] "test_12:age_medM2"
## [125] "test_12:base_rate_pre_medM1"
## [126] "test_12:religiosity_Attends0"
# Adjust the name of the tests for display purposes #
tests = str_replace_all(tests, ":", "")
tests = str_replace_all(tests, "test_10", "Test 10: ")
tests = str_replace_all(tests, "test_11", "Test 11: ")
tests = str_replace_all(tests, "test_12", "Test 12: ")
tests = str_replace_all(tests, "test_6", "Test 6: ")
tests = str_replace_all(tests, "test_7", "Test 7: ")
tests = str_replace_all(tests, "test_8", "Test 8: ")
tests = str_replace_all(tests, "test_9", "Test 9: ")
tests = str_replace_all(tests, "_medM1", "Below median")
tests = str_replace_all(tests, "_medM2", "Above median")
tests = str_replace_all(tests, "att_check_pre0", "Fail AC")
tests = str_replace_all(tests, "att_check_pre1", "Pass AC")
tests = str_replace_all(tests, "gender_Man0", "Gender: Woman")
tests = str_replace_all(tests, "gender_Man1", "Gender: Man")
tests = str_replace_all(tests, "education_High_school_or_less0", "Education: More than High School")
tests = str_replace_all(tests, "education_High_school_or_less1", "Education: High School or Less")
tests = str_replace_all(tests, "base_rate_pre", "Base Rate Pre ")
tests = str_replace_all(tests, "misinfo_pre", "Misinfo Rate Pre ")
tests = str_replace_all(tests, "base_total_acc_score_pre", "Base Acc Score Pre ")
tests = str_replace_all(tests, "misinfo_total_acc_score_pre", "Misinfo Acc Score Pre ")
tests = str_replace_all(tests, "High school or less1", "High School or Less")
tests = str_replace_all(tests, "marital_Married_or_in_a_domestic_partnership1", "Married ")
tests = str_replace_all(tests, "marital_Married_or_in_a_domestic_partnership0", "Non-Married ")
tests = str_replace_all(tests, "location_Mostly_rural0", "Location: Non Rural ")
tests = str_replace_all(tests, "location_Mostly_rural1", "Location: Mostly Rural ")
tests = str_replace_all(tests, "religion_Christian0", "Religion: Non-Christian ")
tests = str_replace_all(tests, "religion_Christian1", "Religion: Christian ")
tests = str_replace_all(tests, "religiosity_Attends0", "Religiosity: Does not attend ")
tests = str_replace_all(tests, "religiosity_Attends1", "Religiosity: Attends ")
tests = str_replace_all(tests, "social_media_share_above_400", "Prop. of content shared below 40% ")
tests = str_replace_all(tests, "social_media_share_above_401", "Prop. of content shared above 40% ")
tests = str_replace_all(tests, "age", "Age: ")
tests = str_replace_all(tests, "social_media_hours", "Hrs/day on social media: ")
tests = str_replace_all(tests, "share_pre_all", "Pre-survey sharing: ")
tests = str_replace_all(tests, "share_pre_misinfo", "Pre-survey misinfo sharing: ")
tests = str_replace_all(tests, "acc_disc_score_pre", "Pre-survey accuracy disc. score: ")
tests = str_replace_all(tests, "att_check_group", "Pre-survey attention checks: ")
tests = str_replace_all(tests, "zero", "0-20%")
tests = str_replace_all(tests, "twenty", "20-40%")
tests = str_replace_all(tests, "forty", "40-60%")
tests = str_replace_all(tests, "sixty", "60-80%")
tests = str_replace_all(tests, "eighty", "80-100%")
tests = str_replace_all(tests, "no", "None")
tests = str_replace_all(tests, "one", "One")
tests = str_replace_all(tests, "all", "All")
tests = str_replace_all(tests, "NOnet", "not")
tests = str_replace_all(tests, "_", " ")
tests
## [1] "Test 7: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev"
## [2] "Test 7: Base Rate Pre Below median - Base Rate Pre Above median lev"
## [3] "Test 7: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev"
## [4] "Test 8: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev"
## [5] "Test 8: Base Rate Pre Below median - Base Rate Pre Above median lev"
## [6] "Test 7: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev"
## [7] "Test 8: Fail AC - Pass AC lev"
## [8] "Test 12: Fail AC - Pass AC lev"
## [9] "Test 8: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev"
## [10] "Test 12: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev"
## [11] "Test 12: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev"
## [12] "Test 7: Prop. of content shared below 40% - Prop. of content shared above 40% lev"
## [13] "Test 8: Location: Non Rural - Location: Mostly Rural lev"
## [14] "Test 8: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev"
## [15] "Test 8: Education: More than High School - Education: High School or Less lev"
## [16] "Test 12: Education: More than High School - Education: High School or Less lev"
## [17] "Test 12: Location: Non Rural - Location: Mostly Rural lev"
## [18] "Test 12: Age: Below median - Age: Above median lev"
## [19] "Test 7: Gender: Woman - Gender: Man lev"
## [20] "Test 12: Prop. of content shared below 40% - Prop. of content shared above 40% lev"
## [21] "Test 12: Base Rate Pre Below median - Base Rate Pre Above median lev"
## [22] "Test 8: Gender: Woman - Gender: Man lev"
## [23] "Test 7: Age: Below median - Age: Above median lev"
## [24] "Test 12: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev"
## [25] "Test 8: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev"
## [26] "Test 8: Prop. of content shared below 40% - Prop. of content shared above 40% lev"
## [27] "Test 7: Non-Married - Married lev"
## [28] "Test 12: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev"
## [29] "Test 8: Religion: Non-Christian - Religion: Christian lev"
## [30] "Test 8: Non-Married - Married lev"
## [31] "Test 8: Age: Below median - Age: Above median lev"
## [32] "Test 12: Religion: Non-Christian - Religion: Christian lev"
## [33] "Test 8: Religiosity: Does not attend - Religiosity: Attends lev"
## [34] "Test 12: Non-Married - Married lev"
## [35] "Test 7: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev"
## [36] "Test 12: Gender: Woman - Gender: Man lev"
## [37] "Test 7: Fail AC - Pass AC lev"
## [38] "Test 12: Religiosity: Does not attend - Religiosity: Attends lev"
## [39] "Test 7: Religiosity: Does not attend - Religiosity: Attends lev"
## [40] "Test 7: Religion: Non-Christian - Religion: Christian lev"
## [41] "Test 7: Location: Non Rural - Location: Mostly Rural lev"
## [42] "Test 7: Education: More than High School - Education: High School or Less lev"
## [43] "Test 7: Misinfo Rate Pre Above median"
## [44] "Test 7: Base Rate Pre Above median"
## [45] "Test 7: Religion: Christian "
## [46] "Test 7: Religiosity: Attends "
## [47] "Test 7: Misinfo Acc Score Pre Above median"
## [48] "Test 7: Base Acc Score Pre Above median"
## [49] "Test 8: Religion: Christian "
## [50] "Test 7: Prop. of content shared above 40% "
## [51] "Test 7: Education: More than High School"
## [52] "Test 8: Religiosity: Attends "
## [53] "Test 8: Misinfo Rate Pre Above median"
## [54] "Test 8: Base Rate Pre Above median"
## [55] "Test 8: Education: More than High School"
## [56] "Test 7: Location: Non Rural "
## [57] "Test 8: Fail AC"
## [58] "Test 7: Age: Below median"
## [59] "Test 7: Non-Married "
## [60] "Test 8: Base Acc Score Pre Above median"
## [61] "Test 8: Prop. of content shared above 40% "
## [62] "Test 7: Gender: Man"
## [63] "Test 7: Fail AC"
## [64] "Test 8: Non-Married "
## [65] "Test 7: Hrs/day on social media: Below median"
## [66] "Test 8: Misinfo Acc Score Pre Above median"
## [67] "Test 7: Hrs/day on social media: Above median"
## [68] "Test 8: Hrs/day on social media: Above median"
## [69] "Test 7: Pass AC"
## [70] "Test 7: Gender: Woman"
## [71] "Test 8: Age: Above median"
## [72] "Test 8: Gender: Man"
## [73] "Test 8: Location: Non Rural "
## [74] "Test 7: Age: Above median"
## [75] "Test 8: Location: Mostly Rural "
## [76] "Test 8: Gender: Woman"
## [77] "Test 8: Age: Below median"
## [78] "Test 7: Married "
## [79] "Test 7: Location: Mostly Rural "
## [80] "Test 8: Misinfo Acc Score Pre Below median"
## [81] "Test 8: Hrs/day on social media: Below median"
## [82] "Test 8: Married "
## [83] "Test 7: Education: High School or Less"
## [84] "Test 7: Base Acc Score Pre Below median"
## [85] "Test 7: Prop. of content shared below 40% "
## [86] "Test 8: Prop. of content shared below 40% "
## [87] "Test 7: Misinfo Acc Score Pre Below median"
## [88] "Test 8: Base Acc Score Pre Below median"
## [89] "Test 8: Misinfo Rate Pre Below median"
## [90] "Test 8: Pass AC"
## [91] "Test 8: Base Rate Pre Below median"
## [92] "Test 7: Base Rate Pre Below median"
## [93] "Test 7: Misinfo Rate Pre Below median"
## [94] "Test 8: Education: High School or Less"
## [95] "Test 7: Religiosity: Does not attend "
## [96] "Test 12: Pass AC"
## [97] "Test 8: Religiosity: Does not attend "
## [98] "Test 7: Religion: Non-Christian "
## [99] "Test 12: Misinfo Acc Score Pre Above median"
## [100] "Test 12: Misinfo Rate Pre Above median"
## [101] "Test 12: Education: High School or Less"
## [102] "Test 12: Location: Non Rural "
## [103] "Test 12: Age: Below median"
## [104] "Test 12: Prop. of content shared above 40% "
## [105] "Test 8: Religion: Non-Christian "
## [106] "Test 12: Base Rate Pre Above median"
## [107] "Test 12: Base Acc Score Pre Above median"
## [108] "Test 12: Hrs/day on social media: Below median"
## [109] "Test 12: Religiosity: Attends "
## [110] "Test 12: Religion: Christian "
## [111] "Test 12: Misinfo Rate Pre Below median"
## [112] "Test 12: Fail AC"
## [113] "Test 12: Misinfo Acc Score Pre Below median"
## [114] "Test 12: Gender: Woman"
## [115] "Test 12: Married "
## [116] "Test 12: Gender: Man"
## [117] "Test 12: Non-Married "
## [118] "Test 12: Religion: Non-Christian "
## [119] "Test 12: Location: Mostly Rural "
## [120] "Test 12: Hrs/day on social media: Above median"
## [121] "Test 12: Prop. of content shared below 40% "
## [122] "Test 12: Base Acc Score Pre Below median"
## [123] "Test 12: Education: More than High School"
## [124] "Test 12: Age: Above median"
## [125] "Test 12: Base Rate Pre Below median"
## [126] "Test 12: Religiosity: Does not attend "
# Rename the dataframe with the results #
rownames(final_subgroup_results) = tests
# Store the results #
saveRDS(final_subgroup_results,"subgroup_analysis_misinfo_diff.RDS")
write.csv(final_subgroup_results, "tables/misinfo_diff_subgroup_RW.csv")
# Snapshot of diff-in-diff by increasing p-value #
diff = final_subgroup_results[is.na(final_subgroup_results$obs),]
round(diff[order(diff$p_val_RW),],4)
## obs
## Test 7: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev NA
## Test 7: Base Rate Pre Below median - Base Rate Pre Above median lev NA
## Test 7: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev NA
## Test 8: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev NA
## Test 8: Base Rate Pre Below median - Base Rate Pre Above median lev NA
## Test 7: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev NA
## Test 8: Fail AC - Pass AC lev NA
## Test 12: Fail AC - Pass AC lev NA
## Test 8: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev NA
## Test 12: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev NA
## Test 12: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev NA
## Test 7: Prop. of content shared below 40% - Prop. of content shared above 40% lev NA
## Test 8: Location: Non Rural - Location: Mostly Rural lev NA
## Test 8: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev NA
## Test 8: Education: More than High School - Education: High School or Less lev NA
## Test 12: Education: More than High School - Education: High School or Less lev NA
## Test 12: Location: Non Rural - Location: Mostly Rural lev NA
## Test 12: Age: Below median - Age: Above median lev NA
## Test 7: Gender: Woman - Gender: Man lev NA
## Test 12: Prop. of content shared below 40% - Prop. of content shared above 40% lev NA
## Test 12: Base Rate Pre Below median - Base Rate Pre Above median lev NA
## Test 8: Gender: Woman - Gender: Man lev NA
## Test 7: Age: Below median - Age: Above median lev NA
## Test 12: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev NA
## Test 8: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev NA
## Test 8: Prop. of content shared below 40% - Prop. of content shared above 40% lev NA
## Test 7: Non-Married - Married lev NA
## Test 12: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev NA
## Test 8: Religion: Non-Christian - Religion: Christian lev NA
## Test 8: Non-Married - Married lev NA
## Test 8: Age: Below median - Age: Above median lev NA
## Test 12: Religion: Non-Christian - Religion: Christian lev NA
## Test 8: Religiosity: Does not attend - Religiosity: Attends lev NA
## Test 12: Non-Married - Married lev NA
## Test 7: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev NA
## Test 12: Gender: Woman - Gender: Man lev NA
## Test 7: Fail AC - Pass AC lev NA
## Test 12: Religiosity: Does not attend - Religiosity: Attends lev NA
## Test 7: Religiosity: Does not attend - Religiosity: Attends lev NA
## Test 7: Religion: Non-Christian - Religion: Christian lev NA
## Test 7: Location: Non Rural - Location: Mostly Rural lev NA
## Test 7: Education: More than High School - Education: High School or Less lev NA
## baseline
## Test 7: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev NA
## Test 7: Base Rate Pre Below median - Base Rate Pre Above median lev NA
## Test 7: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev NA
## Test 8: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev NA
## Test 8: Base Rate Pre Below median - Base Rate Pre Above median lev NA
## Test 7: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev NA
## Test 8: Fail AC - Pass AC lev NA
## Test 12: Fail AC - Pass AC lev NA
## Test 8: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev NA
## Test 12: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev NA
## Test 12: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev NA
## Test 7: Prop. of content shared below 40% - Prop. of content shared above 40% lev NA
## Test 8: Location: Non Rural - Location: Mostly Rural lev NA
## Test 8: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev NA
## Test 8: Education: More than High School - Education: High School or Less lev NA
## Test 12: Education: More than High School - Education: High School or Less lev NA
## Test 12: Location: Non Rural - Location: Mostly Rural lev NA
## Test 12: Age: Below median - Age: Above median lev NA
## Test 7: Gender: Woman - Gender: Man lev NA
## Test 12: Prop. of content shared below 40% - Prop. of content shared above 40% lev NA
## Test 12: Base Rate Pre Below median - Base Rate Pre Above median lev NA
## Test 8: Gender: Woman - Gender: Man lev NA
## Test 7: Age: Below median - Age: Above median lev NA
## Test 12: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev NA
## Test 8: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev NA
## Test 8: Prop. of content shared below 40% - Prop. of content shared above 40% lev NA
## Test 7: Non-Married - Married lev NA
## Test 12: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev NA
## Test 8: Religion: Non-Christian - Religion: Christian lev NA
## Test 8: Non-Married - Married lev NA
## Test 8: Age: Below median - Age: Above median lev NA
## Test 12: Religion: Non-Christian - Religion: Christian lev NA
## Test 8: Religiosity: Does not attend - Religiosity: Attends lev NA
## Test 12: Non-Married - Married lev NA
## Test 7: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev NA
## Test 12: Gender: Woman - Gender: Man lev NA
## Test 7: Fail AC - Pass AC lev NA
## Test 12: Religiosity: Does not attend - Religiosity: Attends lev NA
## Test 7: Religiosity: Does not attend - Religiosity: Attends lev NA
## Test 7: Religion: Non-Christian - Religion: Christian lev NA
## Test 7: Location: Non Rural - Location: Mostly Rural lev NA
## Test 7: Education: More than High School - Education: High School or Less lev NA
## estimate
## Test 7: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev 0.1229
## Test 7: Base Rate Pre Below median - Base Rate Pre Above median lev 0.1075
## Test 7: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev 0.0841
## Test 8: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev 0.0750
## Test 8: Base Rate Pre Below median - Base Rate Pre Above median lev 0.0803
## Test 7: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev 0.0742
## Test 8: Fail AC - Pass AC lev -0.0599
## Test 12: Fail AC - Pass AC lev 0.0561
## Test 8: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev 0.0533
## Test 12: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev 0.0479
## Test 12: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev 0.0510
## Test 7: Prop. of content shared below 40% - Prop. of content shared above 40% lev 0.0453
## Test 8: Location: Non Rural - Location: Mostly Rural lev 0.0369
## Test 8: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev 0.0331
## Test 8: Education: More than High School - Education: High School or Less lev -0.0383
## Test 12: Education: More than High School - Education: High School or Less lev 0.0385
## Test 12: Location: Non Rural - Location: Mostly Rural lev -0.0365
## Test 12: Age: Below median - Age: Above median lev -0.0304
## Test 7: Gender: Woman - Gender: Man lev -0.0309
## Test 12: Prop. of content shared below 40% - Prop. of content shared above 40% lev 0.0280
## Test 12: Base Rate Pre Below median - Base Rate Pre Above median lev 0.0272
## Test 8: Gender: Woman - Gender: Man lev -0.0256
## Test 7: Age: Below median - Age: Above median lev -0.0211
## Test 12: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev 0.0208
## Test 8: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev 0.0183
## Test 8: Prop. of content shared below 40% - Prop. of content shared above 40% lev 0.0173
## Test 7: Non-Married - Married lev 0.0167
## Test 12: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev -0.0127
## Test 8: Religion: Non-Christian - Religion: Christian lev 0.0232
## Test 8: Non-Married - Married lev 0.0102
## Test 8: Age: Below median - Age: Above median lev 0.0093
## Test 12: Religion: Non-Christian - Religion: Christian lev -0.0215
## Test 8: Religiosity: Does not attend - Religiosity: Attends lev -0.0151
## Test 12: Non-Married - Married lev 0.0065
## Test 7: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev 0.0056
## Test 12: Gender: Woman - Gender: Man lev -0.0053
## Test 7: Fail AC - Pass AC lev -0.0039
## Test 12: Religiosity: Does not attend - Religiosity: Attends lev 0.0094
## Test 7: Religiosity: Does not attend - Religiosity: Attends lev -0.0056
## Test 7: Religion: Non-Christian - Religion: Christian lev 0.0017
## Test 7: Location: Non Rural - Location: Mostly Rural lev 0.0004
## Test 7: Education: More than High School - Education: High School or Less lev 0.0001
## std.err
## Test 7: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev 0.0199
## Test 7: Base Rate Pre Below median - Base Rate Pre Above median lev 0.0218
## Test 7: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev 0.0213
## Test 8: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev 0.0203
## Test 8: Base Rate Pre Below median - Base Rate Pre Above median lev 0.0219
## Test 7: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev 0.0220
## Test 8: Fail AC - Pass AC lev 0.0219
## Test 12: Fail AC - Pass AC lev 0.0227
## Test 8: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev 0.0219
## Test 12: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev 0.0203
## Test 12: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev 0.0220
## Test 7: Prop. of content shared below 40% - Prop. of content shared above 40% lev 0.0221
## Test 8: Location: Non Rural - Location: Mostly Rural lev 0.0234
## Test 8: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev 0.0215
## Test 8: Education: More than High School - Education: High School or Less lev 0.0249
## Test 12: Education: More than High School - Education: High School or Less lev 0.0257
## Test 12: Location: Non Rural - Location: Mostly Rural lev 0.0245
## Test 12: Age: Below median - Age: Above median lev 0.0227
## Test 7: Gender: Woman - Gender: Man lev 0.0233
## Test 12: Prop. of content shared below 40% - Prop. of content shared above 40% lev 0.0231
## Test 12: Base Rate Pre Below median - Base Rate Pre Above median lev 0.0225
## Test 8: Gender: Woman - Gender: Man lev 0.0229
## Test 7: Age: Below median - Age: Above median lev 0.0219
## Test 12: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev 0.0228
## Test 8: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev 0.0220
## Test 8: Prop. of content shared below 40% - Prop. of content shared above 40% lev 0.0226
## Test 7: Non-Married - Married lev 0.0237
## Test 12: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev 0.0228
## Test 8: Religion: Non-Christian - Religion: Christian lev 0.0513
## Test 8: Non-Married - Married lev 0.0238
## Test 8: Age: Below median - Age: Above median lev 0.0218
## Test 12: Religion: Non-Christian - Religion: Christian lev 0.0526
## Test 8: Religiosity: Does not attend - Religiosity: Attends lev 0.0482
## Test 12: Non-Married - Married lev 0.0246
## Test 7: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev 0.0220
## Test 12: Gender: Woman - Gender: Man lev 0.0238
## Test 7: Fail AC - Pass AC lev 0.0220
## Test 12: Religiosity: Does not attend - Religiosity: Attends lev 0.0541
## Test 7: Religiosity: Does not attend - Religiosity: Attends lev 0.0463
## Test 7: Religion: Non-Christian - Religion: Christian lev 0.0488
## Test 7: Location: Non Rural - Location: Mostly Rural lev 0.0230
## Test 7: Education: More than High School - Education: High School or Less lev 0.0249
## CI_low
## Test 7: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev 0.0838
## Test 7: Base Rate Pre Below median - Base Rate Pre Above median lev 0.0647
## Test 7: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev 0.0424
## Test 8: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev 0.0353
## Test 8: Base Rate Pre Below median - Base Rate Pre Above median lev 0.0374
## Test 7: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev 0.0311
## Test 8: Fail AC - Pass AC lev -0.1029
## Test 12: Fail AC - Pass AC lev 0.0115
## Test 8: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev 0.0103
## Test 12: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev 0.0082
## Test 12: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev 0.0079
## Test 7: Prop. of content shared below 40% - Prop. of content shared above 40% lev 0.0020
## Test 8: Location: Non Rural - Location: Mostly Rural lev -0.0091
## Test 8: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev -0.0090
## Test 8: Education: More than High School - Education: High School or Less lev -0.0871
## Test 12: Education: More than High School - Education: High School or Less lev -0.0119
## Test 12: Location: Non Rural - Location: Mostly Rural lev -0.0845
## Test 12: Age: Below median - Age: Above median lev -0.0749
## Test 7: Gender: Woman - Gender: Man lev -0.0765
## Test 12: Prop. of content shared below 40% - Prop. of content shared above 40% lev -0.0172
## Test 12: Base Rate Pre Below median - Base Rate Pre Above median lev -0.0169
## Test 8: Gender: Woman - Gender: Man lev -0.0704
## Test 7: Age: Below median - Age: Above median lev -0.0640
## Test 12: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev -0.0237
## Test 8: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev -0.0247
## Test 8: Prop. of content shared below 40% - Prop. of content shared above 40% lev -0.0269
## Test 7: Non-Married - Married lev -0.0298
## Test 12: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev -0.0574
## Test 8: Religion: Non-Christian - Religion: Christian lev -0.0774
## Test 8: Non-Married - Married lev -0.0364
## Test 8: Age: Below median - Age: Above median lev -0.0335
## Test 12: Religion: Non-Christian - Religion: Christian lev -0.1246
## Test 8: Religiosity: Does not attend - Religiosity: Attends lev -0.1096
## Test 12: Non-Married - Married lev -0.0417
## Test 7: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev -0.0375
## Test 12: Gender: Woman - Gender: Man lev -0.0520
## Test 7: Fail AC - Pass AC lev -0.0470
## Test 12: Religiosity: Does not attend - Religiosity: Attends lev -0.0966
## Test 7: Religiosity: Does not attend - Religiosity: Attends lev -0.0965
## Test 7: Religion: Non-Christian - Religion: Christian lev -0.0940
## Test 7: Location: Non Rural - Location: Mostly Rural lev -0.0448
## Test 7: Education: More than High School - Education: High School or Less lev -0.0487
## CI_upp
## Test 7: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev 0.1620
## Test 7: Base Rate Pre Below median - Base Rate Pre Above median lev 0.1503
## Test 7: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev 0.1258
## Test 8: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev 0.1147
## Test 8: Base Rate Pre Below median - Base Rate Pre Above median lev 0.1232
## Test 7: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev 0.1172
## Test 8: Fail AC - Pass AC lev -0.0170
## Test 12: Fail AC - Pass AC lev 0.1006
## Test 8: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev 0.0963
## Test 12: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev 0.0876
## Test 12: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev 0.0941
## Test 7: Prop. of content shared below 40% - Prop. of content shared above 40% lev 0.0887
## Test 8: Location: Non Rural - Location: Mostly Rural lev 0.0828
## Test 8: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev 0.0752
## Test 8: Education: More than High School - Education: High School or Less lev 0.0104
## Test 12: Education: More than High School - Education: High School or Less lev 0.0889
## Test 12: Location: Non Rural - Location: Mostly Rural lev 0.0114
## Test 12: Age: Below median - Age: Above median lev 0.0142
## Test 7: Gender: Woman - Gender: Man lev 0.0148
## Test 12: Prop. of content shared below 40% - Prop. of content shared above 40% lev 0.0733
## Test 12: Base Rate Pre Below median - Base Rate Pre Above median lev 0.0714
## Test 8: Gender: Woman - Gender: Man lev 0.0193
## Test 7: Age: Below median - Age: Above median lev 0.0218
## Test 12: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev 0.0654
## Test 8: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev 0.0613
## Test 8: Prop. of content shared below 40% - Prop. of content shared above 40% lev 0.0615
## Test 7: Non-Married - Married lev 0.0632
## Test 12: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev 0.0319
## Test 8: Religion: Non-Christian - Religion: Christian lev 0.1238
## Test 8: Non-Married - Married lev 0.0568
## Test 8: Age: Below median - Age: Above median lev 0.0521
## Test 12: Religion: Non-Christian - Religion: Christian lev 0.0817
## Test 8: Religiosity: Does not attend - Religiosity: Attends lev 0.0795
## Test 12: Non-Married - Married lev 0.0546
## Test 7: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev 0.0487
## Test 12: Gender: Woman - Gender: Man lev 0.0413
## Test 7: Fail AC - Pass AC lev 0.0392
## Test 12: Religiosity: Does not attend - Religiosity: Attends lev 0.1155
## Test 7: Religiosity: Does not attend - Religiosity: Attends lev 0.0852
## Test 7: Religion: Non-Christian - Religion: Christian lev 0.0974
## Test 7: Location: Non Rural - Location: Mostly Rural lev 0.0455
## Test 7: Education: More than High School - Education: High School or Less lev 0.0489
## p_val
## Test 7: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev 0.0000
## Test 7: Base Rate Pre Below median - Base Rate Pre Above median lev 0.0000
## Test 7: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev 0.0001
## Test 8: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev 0.0002
## Test 8: Base Rate Pre Below median - Base Rate Pre Above median lev 0.0002
## Test 7: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev 0.0007
## Test 8: Fail AC - Pass AC lev 0.0062
## Test 12: Fail AC - Pass AC lev 0.0136
## Test 8: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev 0.0151
## Test 12: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev 0.0181
## Test 12: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev 0.0203
## Test 7: Prop. of content shared below 40% - Prop. of content shared above 40% lev 0.0404
## Test 8: Location: Non Rural - Location: Mostly Rural lev 0.1158
## Test 8: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev 0.1231
## Test 8: Education: More than High School - Education: High School or Less lev 0.1231
## Test 12: Education: More than High School - Education: High School or Less lev 0.1346
## Test 12: Location: Non Rural - Location: Mostly Rural lev 0.1355
## Test 12: Age: Below median - Age: Above median lev 0.1813
## Test 7: Gender: Woman - Gender: Man lev 0.1849
## Test 12: Prop. of content shared below 40% - Prop. of content shared above 40% lev 0.2247
## Test 12: Base Rate Pre Below median - Base Rate Pre Above median lev 0.2272
## Test 8: Gender: Woman - Gender: Man lev 0.2643
## Test 7: Age: Below median - Age: Above median lev 0.3355
## Test 12: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev 0.3595
## Test 8: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev 0.4038
## Test 8: Prop. of content shared below 40% - Prop. of content shared above 40% lev 0.4426
## Test 7: Non-Married - Married lev 0.4819
## Test 12: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev 0.5756
## Test 8: Religion: Non-Christian - Religion: Christian lev 0.6512
## Test 8: Non-Married - Married lev 0.6682
## Test 8: Age: Below median - Age: Above median lev 0.6712
## Test 12: Religion: Non-Christian - Religion: Christian lev 0.6833
## Test 8: Religiosity: Does not attend - Religiosity: Attends lev 0.7550
## Test 12: Non-Married - Married lev 0.7918
## Test 7: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev 0.7998
## Test 12: Gender: Woman - Gender: Man lev 0.8233
## Test 7: Fail AC - Pass AC lev 0.8598
## Test 12: Religiosity: Does not attend - Religiosity: Attends lev 0.8618
## Test 7: Religiosity: Does not attend - Religiosity: Attends lev 0.9032
## Test 7: Religion: Non-Christian - Religion: Christian lev 0.9716
## Test 7: Location: Non Rural - Location: Mostly Rural lev 0.9878
## Test 7: Education: More than High School - Education: High School or Less lev 0.9958
## p_val_holm
## Test 7: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev 0.0000
## Test 7: Base Rate Pre Below median - Base Rate Pre Above median lev 0.0000
## Test 7: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev 0.0031
## Test 8: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev 0.0083
## Test 8: Base Rate Pre Below median - Base Rate Pre Above median lev 0.0092
## Test 7: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev 0.0271
## Test 8: Fail AC - Pass AC lev 0.2241
## Test 12: Fail AC - Pass AC lev 0.4770
## Test 8: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev 0.5117
## Test 12: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev 0.5969
## Test 12: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev 0.6487
## Test 7: Prop. of content shared below 40% - Prop. of content shared above 40% lev 1.0000
## Test 8: Location: Non Rural - Location: Mostly Rural lev 1.0000
## Test 8: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev 1.0000
## Test 8: Education: More than High School - Education: High School or Less lev 1.0000
## Test 12: Education: More than High School - Education: High School or Less lev 1.0000
## Test 12: Location: Non Rural - Location: Mostly Rural lev 1.0000
## Test 12: Age: Below median - Age: Above median lev 1.0000
## Test 7: Gender: Woman - Gender: Man lev 1.0000
## Test 12: Prop. of content shared below 40% - Prop. of content shared above 40% lev 1.0000
## Test 12: Base Rate Pre Below median - Base Rate Pre Above median lev 1.0000
## Test 8: Gender: Woman - Gender: Man lev 1.0000
## Test 7: Age: Below median - Age: Above median lev 1.0000
## Test 12: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev 1.0000
## Test 8: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev 1.0000
## Test 8: Prop. of content shared below 40% - Prop. of content shared above 40% lev 1.0000
## Test 7: Non-Married - Married lev 1.0000
## Test 12: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev 1.0000
## Test 8: Religion: Non-Christian - Religion: Christian lev 1.0000
## Test 8: Non-Married - Married lev 1.0000
## Test 8: Age: Below median - Age: Above median lev 1.0000
## Test 12: Religion: Non-Christian - Religion: Christian lev 1.0000
## Test 8: Religiosity: Does not attend - Religiosity: Attends lev 1.0000
## Test 12: Non-Married - Married lev 1.0000
## Test 7: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev 1.0000
## Test 12: Gender: Woman - Gender: Man lev 1.0000
## Test 7: Fail AC - Pass AC lev 1.0000
## Test 12: Religiosity: Does not attend - Religiosity: Attends lev 1.0000
## Test 7: Religiosity: Does not attend - Religiosity: Attends lev 1.0000
## Test 7: Religion: Non-Christian - Religion: Christian lev 1.0000
## Test 7: Location: Non Rural - Location: Mostly Rural lev 1.0000
## Test 7: Education: More than High School - Education: High School or Less lev 1.0000
## p_val_RW
## Test 7: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev 0.0010
## Test 7: Base Rate Pre Below median - Base Rate Pre Above median lev 0.0010
## Test 7: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev 0.0060
## Test 8: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev 0.0140
## Test 8: Base Rate Pre Below median - Base Rate Pre Above median lev 0.0140
## Test 7: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev 0.0250
## Test 8: Fail AC - Pass AC lev 0.1978
## Test 12: Fail AC - Pass AC lev 0.3616
## Test 8: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev 0.3766
## Test 12: Misinfo Rate Pre Below median - Misinfo Rate Pre Above median lev 0.4216
## Test 12: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev 0.4525
## Test 7: Prop. of content shared below 40% - Prop. of content shared above 40% lev 0.6693
## Test 8: Location: Non Rural - Location: Mostly Rural lev 0.9481
## Test 8: Misinfo Acc Score Pre Below median - Misinfo Acc Score Pre Above median lev 0.9481
## Test 8: Education: More than High School - Education: High School or Less lev 0.9481
## Test 12: Education: More than High School - Education: High School or Less lev 0.9610
## Test 12: Location: Non Rural - Location: Mostly Rural lev 0.9610
## Test 12: Age: Below median - Age: Above median lev 0.9840
## Test 7: Gender: Woman - Gender: Man lev 0.9840
## Test 12: Prop. of content shared below 40% - Prop. of content shared above 40% lev 0.9910
## Test 12: Base Rate Pre Below median - Base Rate Pre Above median lev 0.9910
## Test 8: Gender: Woman - Gender: Man lev 0.9930
## Test 7: Age: Below median - Age: Above median lev 0.9980
## Test 12: Base Acc Score Pre Below median - Base Acc Score Pre Above median lev 1.0000
## Test 8: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev 1.0000
## Test 8: Prop. of content shared below 40% - Prop. of content shared above 40% lev 1.0000
## Test 7: Non-Married - Married lev 1.0000
## Test 12: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev 1.0000
## Test 8: Religion: Non-Christian - Religion: Christian lev 1.0000
## Test 8: Non-Married - Married lev 1.0000
## Test 8: Age: Below median - Age: Above median lev 1.0000
## Test 12: Religion: Non-Christian - Religion: Christian lev 1.0000
## Test 8: Religiosity: Does not attend - Religiosity: Attends lev 1.0000
## Test 12: Non-Married - Married lev 1.0000
## Test 7: Hrs/day on social media: Below median - Hrs/day on social media: Above median lev 1.0000
## Test 12: Gender: Woman - Gender: Man lev 1.0000
## Test 7: Fail AC - Pass AC lev 1.0000
## Test 12: Religiosity: Does not attend - Religiosity: Attends lev 1.0000
## Test 7: Religiosity: Does not attend - Religiosity: Attends lev 1.0000
## Test 7: Religion: Non-Christian - Religion: Christian lev 1.0000
## Test 7: Location: Non Rural - Location: Mostly Rural lev 1.0000
## Test 7: Education: More than High School - Education: High School or Less lev 1.0000
final_subgroup_results[grepl("Gender",rownames(final_subgroup_results)),]
## obs baseline estimate
## Test 7: Gender: Woman - Gender: Man lev NA NA -0.030865210
## Test 8: Gender: Woman - Gender: Man lev NA NA -0.025550949
## Test 12: Gender: Woman - Gender: Man lev NA NA -0.005314261
## Test 7: Gender: Man 5679 -0.07122222 -0.102909757
## Test 7: Gender: Woman 3005 -0.07824032 -0.133774968
## Test 8: Gender: Man 5679 -0.07122222 -0.092395912
## Test 8: Gender: Woman 3005 -0.07824032 -0.117946861
## Test 12: Gender: Woman 3005 -0.19618718 -0.015828107
## Test 12: Gender: Man 5679 -0.16361813 -0.010513845
## std.err CI_low CI_upp
## Test 7: Gender: Woman - Gender: Man lev 0.02327937 -0.07649277 0.01476235
## Test 8: Gender: Woman - Gender: Man lev 0.02288921 -0.07041380 0.01931190
## Test 12: Gender: Woman - Gender: Man lev 0.02379965 -0.05196157 0.04133305
## Test 7: Gender: Man 0.01343758 -Inf -0.08087212
## Test 7: Gender: Woman 0.01900948 -Inf -0.10259943
## Test 8: Gender: Man 0.01366455 -Inf -0.06998605
## Test 8: Gender: Woman 0.01836289 -Inf -0.08783172
## Test 12: Gender: Woman 0.01916527 -0.05339204 0.01560294
## Test 12: Gender: Man 0.01411083 -0.03817107 0.01262792
## p_val
## Test 7: Gender: Woman - Gender: Man lev 0.1848856296571577129
## Test 8: Gender: Woman - Gender: Man lev 0.2642988391806231352
## Test 12: Gender: Woman - Gender: Man lev 0.8233085725013202794
## Test 7: Gender: Man 0.0000000000000240105
## Test 7: Gender: Woman 0.0000000000023340190
## Test 8: Gender: Man 0.0000000000158955877
## Test 8: Gender: Woman 0.0000000001513730360
## Test 12: Gender: Woman 0.4089305630094587363
## Test 12: Gender: Man 0.4562660498288942934
## p_val_holm p_val_RW
## Test 7: Gender: Woman - Gender: Man lev 1.000000000000000000 0.984015984
## Test 8: Gender: Woman - Gender: Man lev 1.000000000000000000 0.993006993
## Test 12: Gender: Woman - Gender: Man lev 1.000000000000000000 1.000000000
## Test 7: Gender: Man 0.000000000001560683 0.000999001
## Test 7: Gender: Woman 0.000000000133039085 0.000999001
## Test 8: Gender: Man 0.000000000874257325 0.000999001
## Test 8: Gender: Woman 0.000000007720024835 0.000999001
## Test 12: Gender: Woman 1.000000000000000000 0.986013986
## Test 12: Gender: Man 1.000000000000000000 0.992007992