Skip to content

Instantly share code, notes, and snippets.

@druedin
Created November 24, 2012 22:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save druedin/4141622 to your computer and use it in GitHub Desktop.
Save druedin/4141622 to your computer and use it in GitHub Desktop.
Wordscores and Wordfish Analysis
# #################################
# 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment