affinity: Internal function to fit the likelihood scaling mixture...

View source: R/textmodel_affinity.R

affinityR Documentation

Internal function to fit the likelihood scaling mixture model.

Description

Ken recommends you use textmodel_affinity() instead.

Usage

affinity(p, x, smooth = 0.5, verbose = FALSE)

Arguments

p

word likelihoods within classes, estimated from training data

x

term-document matrix for document(s) to be scaled

smooth

a misnamed smoothing parameter, either a scalar or a vector equal in length to the number of documents

Value

a list containing:

  • coefficients point estimates of theta

  • se (likelihood) standard error of theta

  • cov covariance matrix

  • smooth values of the smoothing parameter

  • support logical indicating if the feature was included

Author(s)

Patrick Perry

Examples

p <- matrix(c(c(5/6, 0, 1/6), c(0, 4/5, 1/5)), nrow = 3,
            dimnames = list(c("A", "B", "C"), NULL))
theta <- c(.2, .8)
q <- drop(p %*% theta)
x <- 2 * q
(fit <- affinity(p, x))

quanteda.textmodels documentation built on Sept. 11, 2024, 8:19 p.m.