data(congress109)
## Inverse Regression Sentiment Modeling
fit <- mnlm(congress109Counts, congress109Ideology[,6:7], normalize=TRUE, bins=10)
par(mfrow=c(1,2))
plot(fit, 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(fit, 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(fit, type="reduction", newdata=congress109Counts[c(68,388),])
predict(fit, type="response", newdata=congress109Ideology[c(68,388),6:7])[,c(995,997)]
## example usage of summary method
summary(fit, y=congress109Ideology$repshare)
## A small topic model
par(mfrow=c(1,1))
tpx <- topics(congress109Counts, K=15)
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