logLik.BTM: Get the likelihood of biterms in a BTM model

View source: R/btm.R

logLik.BTMR Documentation

Get the likelihood of biterms in a BTM model

Description

Get the likelihood how good biterms are fit by the BTM model

Usage

## S3 method for class 'BTM'
logLik(object, data = terms.BTM(object, type = "biterms")$biterms, ...)

Arguments

object

an object of class BTM as returned by BTM

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

Value

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

See Also

BTM, predict.BTM, terms.BTM

Examples


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


BTM documentation built on Feb. 16, 2023, 10:14 p.m.