Learn R Programming

miniLNM (version 0.1.0)

predict,lnm-method: LNM Fitted Probabilities

Description

Given an input dataset, predict the output composition. Specifically, this outputs \(\phi^{-1}(Bx)\), for the inverse log ratio transformation \(\phi^{-1}\) and fitted covariate matrix \(B\).

Usage

# S4 method for lnm
predict(object, newdata = NULL, ...)

Value

A matrix with predictions along rows and outcomes along columns. Rows sum up to one.

Arguments

object

An object of class lnm with fitted parameters \(\hat{B}\) and which we want to use to form predictions on new samples.

newdata

New samples on which to form predictions. Defaults to NULL, in which case predictions are made at the same design points as those used during the original training.

...

Additional keyword arguments, for consistency with R's predict generic (never used).

Examples

Run this code
example_data <- lnm_data(N = 50, K = 10)
xy <- dplyr::bind_cols(example_data[c("X", "y")])
fit <- lnm(
    starts_with("y") ~ starts_with("x"), xy, 
    iter = 25, output_samples = 25
)
head(predict(fit))

Run the code above in your browser using DataLab