A while ago I wrote a step by step guide for using Wordscores in R. I did this as part of the FP7 project SOM, but ended up doing the analyses myself. I have recently posted some code on running Wordscores in R:
# #################################
# WORDSCORES AND WORDFISH ANALYSIS
# #################################
# setup
library(austin)
############################
# GETTING DOCUMENTS IN
############################
a <- wfm("SHORT.1995-2011.csv")
a[0,] # check the party order (header only)
############################
# A. WORDFISH
############################
wordfish(a, dir=c(23, 20), control=list(tol=1e-06, sigma=3, startparams=NULL), verbose=FALSE)
# identification strategy:
# GPS 2003 and SVP 2003
# these are the extremes in the expert survey (moving average or alternative count)
# also they are nicely the Benoit & Laver texts, for which we have some confidence
############################
# B. WORDSCORES
############################
# SET REFERENCES
ref <- c(10,11,15,20,23) # reference texts
vir <- 1:24 # SPS 2011 (short) is empty, thus not included
vir <- vir[-ref] # everything minus the reference texts
r <- getdocs (a, ref)
ws <- classic.wordscores(r, scores=c(5.971929825,1.252631579,4.665789474,9.206140351,0.935087719))
summary(ws)
# PREDICT
v <- getdocs (a, vir)
predict(ws,newdata=v)
I use Will Lowe’s JFreq to get the word frequencies.
One Reply to “Wordscores in R”