predict.fitmixture: Predictions From a "fitmixture" Object

View source: R/predict.fitmixture.R

predict.fitmixtureR Documentation

Predictions From a "fitmixture" Object

Description

Obtain predictions from a fit_mixture() object. If newdata is omitted, predictions are obtained using the underlying model's predict method (predict.coxph(), predict.glm(), or predict.lm()). If newdata is provided, predictions are computed directly from the reconstructed model matrix and estimated coefficients.

Usage

## S3 method for class 'fitmixture'
predict(object, newdata, type, terms = NULL, na.action = na.pass, ...)

Arguments

object

the result of a call to fit_mixture()

newdata

optional new data to obtain predictions for. The original data is used by default.

type

the type of prediction. When newdata is provided: for the "cox" family, the choices are the linear predictor ("lp") and the risk score exp(lp) ("risk"). For the "gaussian" family and all other glm families ("poisson", "binomial", "gamma"), the choices are predictions on the scale of the linear predictors ("link") or the response ("response"). When newdata is omitted, additional types such as "terms" or "expected" may be supported by the underlying predict methods.

terms

the terms when type = "terms". By default, all terms are included. Note: This is only supported when newdata is omitted.

na.action

a function for what to do with missing values in newdata. The default is to predict "NA".

...

for future predict arguments

Value

a vector or matrix of predictions based on arguments specified.

Examples

## commonness score of first and last names used for linkage
mformula <- ~commf + comml
## hand-linked records are considered "safe" matches
safematches <- ifelse(lifem$hndlnk =="Hand-Linked At Some Level", TRUE, FALSE)
## overall mismatch rate in the data set is assumed to be ~ 0.05
mrate <- 0.05
fit <- fit_mixture(age_at_death ~ poly(unit_yob, 3, raw = TRUE), data = lifem,
                   family = "gaussian", mformula, safematches, mrate)

predict(fit)


pldamixture documentation built on Sept. 27, 2026, 5:07 p.m.