predict.IMLEGIT | R Documentation |
Predictions of IMLEGIT fits.
## S3 method for class 'IMLEGIT'
predict(object, data, latent_var, ...)
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. |
Returns a vector with the predicted values.
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.