# NOT RUN {
ie_dfm <- dfm(data_corpus_irishbudget2010)
doclab <- apply(docvars(data_corpus_irishbudget2010, c("name", "party")),
1, paste, collapse = " ")
## wordscores
refscores <- c(rep(NA, 4), -1, 1, rep(NA, 8))
ws <- textmodel_wordscores(ie_dfm, refscores, smooth = 1)
# plot estimated word positions
textplot_scale1d(ws, highlighted = c("minister", "have", "our", "budget"))
# plot estimated document positions
textplot_scale1d(predict(ws), doclabels = doclab,
groups = docvars(data_corpus_irishbudget2010, "party"))
## wordfish
wf <- textmodel_wordfish(dfm(data_corpus_irishbudget2010), dir = c(6,5))
# plot estimated document positions
textplot_scale1d(wf, doclabels = doclab)
textplot_scale1d(wf, doclabels = doclab,
groups = docvars(data_corpus_irishbudget2010, "party"))
# plot estimated word positions
textplot_scale1d(wf, margin = "features",
highlighted = c("government", "global", "children",
"bank", "economy", "the", "citizenship",
"productivity", "deficit"))
## correspondence analysis
ca <- textmodel_ca(ie_dfm)
# plot estimated document positions
textplot_scale1d(ca, margin = "documents",
doclabels = doclab,
groups = docvars(data_corpus_irishbudget2010, "party"))
# }
Run the code above in your browser using DataLab