Last chance! 50% off unlimited learning
Sale ends in
simple_triplet_matrix
of phrase counts indexed by speaker-rows and phrase-columns.matrix
containing the associated repshare
and common scores [cs1,cs2]
, as well as speaker
characteristics: party
(`R'epublican, `D'emocrat, or `I'ndependent), state
, and chamber
(`H'ouse or `S'enate).Taddy (2012), Multinomial Inverse Regression for Text Analysis.
Taddy (2012), On Estimation and Selection for Topic Models.
data(congress109)
## Bivariate sentiment factors (roll-call vote common scores)
fitCS <- mnlm(congress109Counts, congress109Ideology[,6:7], bins=5, penalty=c(4,1/2))
## plot the fit
plot(fitCS, log='xy', boxwex=.2)
## plot the inverse regression reduction
par(mfrow=c(1,2))
plot(fitCS, type="reduction", v=congress109Ideology$repshare, xlab="Republican Vote-Share",
covar=1, pch=21, bg=c(4,3,2)[congress109Ideology$party], main="1st common score")
plot(fitCS, type="reduction", v=congress109Ideology$repshare, xlab="Republican Vote-Share",
covar=2, pch=21, bg=c(4,3,2)[congress109Ideology$party], main="2nd common score")
## example usage of the predict method
predict(fitCS, type="reduction", newdata=congress109Counts[c(68,388),])
predict(fitCS, type="response", newdata=congress109Ideology[c(68,388),6:7])[,c(995,997)]
## example usage of summary method
summary(fitCS, y=congress109Ideology$repshare)
## Fit topic model (use lower tol for true convergence)
par(mfrow=c(1,1))
tpx <- topics(congress109Counts, K=10, tol=100)
plot(tpx, group=congress109Ideology$party=="R", col=c(4,2), labels=c("Dem","GOP"))
summary(tpx)
Run the code above in your browser using DataLab