predict.textmodel_affinity: Prediction for a fitted affinity textmodel

View source: R/textmodel_affinity.R

predict.textmodel_affinityR Documentation

Prediction for a fitted affinity textmodel

Description

Estimate \theta_i for each document, from a fitted textmodel_affinity object.

Other methods below provide standard ways to extract or compute quantities from predicted textmodel_affinity objects.

Usage

## S3 method for class 'textmodel_affinity'
predict(object, newdata = NULL, level = 0.95, ...)

## S3 method for class 'predict.textmodel_affinity'
coef(object, ...)

## S3 method for class 'predict.textmodel_affinity'
residuals(object, type = c("response", "pearson"), ...)

## S3 method for class 'predict.textmodel_affinity'
rstandard(model, ...)

Arguments

object

a fitted affinity textmodel

newdata

dfm on which prediction should be made

level

probability level for confidence interval width

...

unused

type

see residuals.lm

Value

predict() returns a list of predicted affinity textmodel quantities, containing:

  • coefficients a numeric matrix of affinity estimates (coefficients) for each class (columns) for each document (rows)

  • se a numeric matrix of likelihood standard errors for affinity coefficients each class (columns) for each document (rows)

  • cov an array of covariance matrices for each affinity class, one per document

  • smooth a numeric vector of length two for the smoothing parameters smooth and ref_smooth from textmodel_affinity()

  • newdata a dfm on which prediction has been made

  • train a logical vector indicating which documents were used in training the model

  • level the confidence level for computing standard errors

  • p the p return from textmodel_affinity

  • support logical vector indicating whether a feature was included in computing class affinities

coef() returns a document \times class matrix of class affinities for each document.

residuals() returns a document-by-feature matrix of residuals. resid() is an alias.

rstandard() is a shortcut to return the Pearson residuals.

See Also

influence.predict.textmodel_affinity() for methods of computing the influence of particular features from a predicted textmodel_affinity model.


quanteda.textmodels documentation built on March 31, 2023, 8:09 p.m.