Learn R Programming

LEGIT (version 1.4.1)

predict.IMLEGIT: Predictions of IMLEGIT fits

Description

Predictions of IMLEGIT fits.

Usage

# S3 method for IMLEGIT
predict(object, data, latent_var, ...)

Value

Returns a vector with the predicted values.

Arguments

object

An object of class "IMLEGIT", usually, a result of a call to IMLEGIT.

data

data.frame of the dataset to be used.

latent_var

list of data.frame. The elements of the list are the datasets used to construct each latent variable. For interpretability and proper convergence, not using the same variable in more than one latent variable is highly recommended. It is recommended to set names to the list elements to prevent confusion because otherwise, the latent variables will be named L1, L2, ...

...

Further arguments passed to or from other methods.

Examples

Run this code
train = example_2way(250, 1, seed=777)
test = example_2way(100, 1, seed=666)
fit = IMLEGIT(train$data, list(G=train$G, E=train$E), y ~ G*E)
ssres = sum((test$data$y - predict(fit, test$data, list(G=test$G, E=test$E)))^2)
sstotal = sum((test$data$y - mean(test$data$y))^2)
R2 = 1 - ssres/sstotal
R2

Run the code above in your browser using DataLab