Description Usage Arguments Details Value Author(s) References See Also Examples
Predict function for Topic Models
1 2 |
object |
An output object from the |
newcounts |
An |
loglhd |
Whether or not to calculate and return |
... |
Additional arguments to the undocumented internal |
Under the default mixed-membership topic model, this function uses sequential quadratic programming to fit topic weights Ω for new documents.
Estimates for each new ω_i are, conditional on object$theta
,
MAP in the (K-1)-dimensional logit transformed parameter space.
The output is an nrow(newcounts)
by object$K
matrix of document topic weights, or a list with including these weights as W
and the log likelihood as L
.
Matt Taddy mataddy@gmail.com
Taddy (2012), On Estimation and Selection for Topic Models. http://arxiv.org/abs/1109.4518
topics, plot.topics, summary.topics, congress109
1 2 3 4 5 6 7 8 9 10 11 | ## Simulate some data
omega <- t(rdir(500, rep(1/10,10)))
theta <- rdir(10, rep(1/1000,1000))
Q <- omega%*%t(theta)
counts <- matrix(ncol=1000, nrow=500)
totals <- rpois(500, 200)
for(i in 1:500){ counts[i,] <- rmultinom(1, size=totals[i], prob=Q[i,]) }
## predict omega given theta
W <- predict.topics( theta, counts )
plot(W, omega, pch=21, bg=8)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.