logLik.BTM {BTM} | R Documentation |
Get the likelihood how good biterms are fit by the BTM model
## S3 method for class 'BTM' logLik(object, data = terms.BTM(object, type = "biterms")$biterms, ...)
object |
an object of class BTM as returned by |
data |
a data.frame with 2 columns term1 and term2 containing biterms. Defaults to the biterms used to construct the model. |
... |
other arguments not used |
a list with elements
likelihood: a vector with the same number of rows as data
containing the likelihood
of the biterms alongside the BTM model. Calculated as sum(phi[term1, ] * phi[term2, ] * theta)
.
ll
the sum of the log of the biterm likelihoods
library(udpipe) data("brussels_reviews_anno", package = "udpipe") x <- subset(brussels_reviews_anno, language == "nl") x <- subset(x, xpos %in% c("NN", "NNP", "NNS")) x <- x[, c("doc_id", "lemma")] model <- BTM(x, k = 5, iter = 5, trace = TRUE, detailed = TRUE) fit <- logLik(model) fit$ll