From: Nathan TeBlunthuis Date: Sat, 12 Aug 2023 20:09:31 +0000 (-0700) Subject: real-data example on raw perspective scores X-Git-Url: https://code.communitydata.science/ml_measurement_error_public.git/commitdiff_plain/d9d3e47a44ddead1cdf7a649bc0e9849c2219498?ds=inline;hp=c1dbbfd0dd88defca0ce00425910757e436284ad real-data example on raw perspective scores --- 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')