ls() weight weight lablr labelr nrow(labelr) names(labelr) names(labelr$data) labelr$data labelr names(labelr) labelr$labelr labelr$toxic setwd("..") q() n summary(toxicity_calibrated) qplot(labelr$toxic,type='hist') names(labelr) labelr$n labelr names(labelr) fbyg gghist(fbyg$weight) hist(fbyg$weight) hist(log(fbyg$weight)) fbyg$weight==1 all(fbyg$weight==1) fbyg$weight[fbyg$weight != 1] fbyg[fbyg$weight != 1] fbyg[,fbyg$weight != 1] fbyg[[fbyg$weight != 1]] fbyg[fbyg$weight != 1,] names(labelr) summary(toxicity_calibrated) toxicity_calibrated val.data names(labelr) labelr$data labelr labelr[data] labelr[data=='yg'] labelr[,data=='yg'] labelr[data=='yg',] labelr[labelr$data=='yg'] labelr[,labelr$data=='yg'] labelr[labelr$data=='yg',] toxicity_calibrated summary(toxicity_calibrated) yg3 yg3[,['toxic','toxic_pred']] yg3 %>% select('toxic','toxic_pred') yg3 |> select('toxic','toxic_pred') names(yg3) yg3[,c('toxic_pred','toxic')] corr(yg3[,c('toxic_pred','toxic')]) cor(yg3[,c('toxic_pred','toxic')]) cor(yg3[,c('toxic_pred','toxic')],na.rm=T) cor(yg3[,c('toxic_pred','toxic')],rm.na=T) ?cor(yg3[,c('toxic_pred','toxic')],use= ?cor cor(yg3[,c('toxic_pred','toxic')],use='all.obs') ?cor cor(yg3[,c('toxic_pred','toxic')],use='complete.obs') cor(yg3[,c('toxic_pred','toxic')],use='complete.obs',method='spearman') ?predict yg3$toxic_pred names(preds) preds preds preds$error preds preds summary(errormod) summary(errormod) summary(preds) names(preds) preds resids qplot(resids) resids ?predict.lm dnorm(1) dnorm(2) dnorm(1) pnorm(1) preds p1 + p2 p1 + p2 p1 p2 preds preds1 <- preds preds1$diff - preds$diff preds1$diff preds1$diff - preds1$diff preds1$diff - preds$diff preds1$diff - preds$diff preds1$diff - preds$diff preds1$diff - preds$diff preds1 preds dnorm(-1) dnorm(1) pnorm(1) pnorm(-1) pnorm(2) pnorm(9) pnorm(6) pnorm(2) dnorm(0.95) qnorm(0.95) qnorm(0.841) fulldata_preds names(yg3) yg3$toxic_feature_1 yg3$toxic_feature_2 yg3 yg3[,.(toxic_pred,toxic_var)] yg3[,.(toxic_pred,toxicity_2_pred_sigma,toxicity_1_pred_sigma)] yg3[,.(toxic_pred,toxicity_2_pred_sigma,toxicity_1_pred_sigma,cov(toxicity_2_pred,toxicity_1_pred))] cov(1,2) cov(c(1),c(3)) cov(c(1),c(3,2)) cov(c(1,1),c(3,2)) cov(c(1,2),c(3,2)) covterm covterm ?cov covterm yg3 yg3[,.(toxic_pred,toxicity_2_pred_sigma,toxicity_1_pred_sigma,cov(toxicity_2_pred,toxicity_1_pred))] yg3[,.(toxic_pred,toxicity_2_pred_sigma,toxicity_1_pred_sigma,toxic_var)] yg3[,.(toxic_pred,toxicity_2_pred_sigma,toxicity_1_pred_sigma,toxic_var,toxic_sd)] yg3 names(yg3) print(sg) print(sg) 1+1 library(stargazer) stargazer(w1,w2,w3,w4,w5,t1,t2,t3,t4,t5, type="text", keep = c("cond1","meantox","cond1:meantox","Constant"), keep.stat=c("n","adj.rsq"), model.numbers = F, dep.var.labels = c("DV = Willingness to comment","DV = Toxicity of YG respondent comments"), covariate.labels = c("Treatment (top comments shown)", "Average toxicity of top comments", "Treatment $\times$ top comments toxicity", "Constant"), add.lines = list(c("Article fixed effects","No","No","No","Yes","Yes","No","No","No","Yes","Yes")), star.cutoffs = c(0.05,0.01,0.005), notes = "Standard errors are clustered at the respondent level.", column.labels = c("(1)","(2)","(3)","(4)","(5)","(6)","(7)","(8)","(9)","(10)"), style = "apsr") q() n yglabels labelr names(labelr) fb names(fb ) fb.comment_id fb['comment_id'] fb[,'comment_id'] labelr[,'comment_id'] names(fb) fb.labeled names(fb.labeled) names(yg) ?amelia yg names(yg) names(yg3) ?rbind nrow(yg3) nrow(yg) yg3[,.(.N),by=.(toxic,fb)] yg3.toimpute names(yg3.toimpute) yg3.toimpute names(yg3.toimpute) names(labelr) nrow(yg3) nrow(labelr) ?merge.data.table labelr is.data.table(labelr) yg3.toimpute overimp.grid overimp.grid ?amelia q() n setwd("presentations/ica_hackathon_2022/") ls() attach(r) example_2_B.plot.df library(ggplot2) example_2_B.plot.df[(variable=='x') && (m < 1000)] example_2_B.plot.df[(variable=='x') && (m < 1000)] theme_set(theme_default()) theme_set(theme_minimal()) theme_set(theme_classic()) example_2_B.plot.df[(variable=='x') && (m < 1000)] example_2_B.plot.df[(variable=='x') && (m < 1000),unique(method)] as.factor update.packages() update.packages() update.packages() cancel plot.df example_2_B.plot.df plot.df example_2_B.plot.df example_2_B.plot.df$method %>% unique example_2_B.plot.df$method |> unique example_2_B.plot.df$method |> uniq unique(example_2_B.plot.df$method) example_2_B.plot.df$method example_2_B.plot.df$method example_2_B.plot.df$method example_2_B.plot.df$method example_2_B.plot.df <- r$example_2_B.plot.df q() n setwd("presentations/ica_hackathon_2022/') setwd("presentations/ica_hackathon_2022/") example_2_B.plot.df$method example_2_B.plot.df$method q() n example_2_B.plot.df$method example_2_B.plot.df$method q() n example_2_B.plot.df$method example_2_B.plot.df$method q() n q() n plot.df plot.df plot.df[,.N,by=.(N,m)] plot.df[,.N,by=.(N,m,method)] plot.df[variable=='x',.N,by=.(N,m,method)] plot.df plot.df[(variable=='x') & (m < 1000) & (!is.na(p.true.in.ci))] plot.df[(variable=='x') & (m != 1000) & (!is.na(p.true.in.ci))] plot.df ?label_wrap_gen install.packages("ggplot2") devtools::install_github("tidyverse/ggplot2") 2 library(ggplot2) ggplot2::version sessioninfo() sessionInfo() q() n sessionInfo() ?scale_x_discrete ?facet_grid plot.df plot.df plot.df[method="2SLS+gmm"] plot.df[method=="2SLS+gmm"] df <- example_2_B.plot.df df q() n plot.df plot.df[m=50] plot.df[m==50] plot.df.example.2[m==50][method=2SLS+gmm] plot.df.example.2[m==50][method==2SLS+gmm] plot.df.example.2[(m==50) & (method==2SLS+gmm)] plot.df.example.2[(m==50) & (method=="2SLS+gmm")] plot.df[m==50] plot.df.example.3 plot.df.example.3 plot.df.example.3[N=25000] plot.df.example.3[N==25000] plot.df plot.df plot.df q() n