From d9d3e47a44ddead1cdf7a649bc0e9849c2219498 Mon Sep 17 00:00:00 2001 From: Nathan TeBlunthuis Date: Sat, 12 Aug 2023 13:09:31 -0700 Subject: [PATCH 1/1] real-data example on raw perspective scores --- civil_comments/03_prob_not_pred.R | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 civil_comments/03_prob_not_pred.R diff --git a/civil_comments/03_prob_not_pred.R b/civil_comments/03_prob_not_pred.R new file mode 100644 index 0000000..8f4a9ab --- /dev/null +++ b/civil_comments/03_prob_not_pred.R @@ -0,0 +1,21 @@ +source('load_perspective_data.R') +source("../simulations/RemembR/R/RemembeR.R") +library(xtable) +change.remember.file("prob_not_pred.RDS") +### to respond to the reviewer show what happens if we don't recode the predictions. + +non_recoded_dv <- lm(toxicity_prob ~ likes * race_disclosed, data=df) +remember(coef(non_recoded_dv), "coef_dv") +remember(diag(vcov(non_recoded_dv)), "se_dv") +remember(xtable(non_recoded_dv),'dv_xtable') + +non_recoded_iv <- glm(race_disclosed ~ likes * toxicity_prob, data=df, family='binomial') +remember(coef(non_recoded_iv), "coef_iv") +remember(diag(vcov(non_recoded_iv)), "se_iv") +remember(xtable(non_recoded_iv),'iv_xtable') + +remember(extract(non_recoded_iv,include.aic=F,include.bic=F,include.nobs=F,include.deviance=F,include.loglik=F),'non_recoded_iv') +remember(extract(non_recoded_dv,include.rsquared=F,include.adjrs=F,include.nobs=F),'non_recoded_dv') +tr <- texreg(list(r$non_recoded_iv, r$non_recoded_dv),custom.model.names=c("Example 1","Example 2"),custom.coef.map=list("(Intercept)"="Intercept","race_disclosedTRUE"="Identity Disclosure","toxicity_prob"="Toxicity Score","likes"="Likes","likes:race_disclosedTRUE"="Likes:Identity Disclosure","likes:toxicity_prob"="Likes:Toxicity Score"),single.row=T,dcolumn=T) +print(tr) +remember(tr, 'texregobj') -- 2.39.5