Learn R Programming

LEGIT (version 1.4.1)

predict.LEGIT: Predictions of LEGIT fits

Description

Predictions of LEGIT fits.

Usage

# S3 method for LEGIT
predict(object, data, genes, env, ...)

Value

Returns a vector with the predicted values.

Arguments

object

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

data

data.frame of the dataset to be used.

genes

data.frame of the variables inside the genetic score G (can be any sort of variable, doesn't even have to be genetic).

env

data.frame of the variables inside the environmental score E (can be any sort of variable, doesn't even have to be environmental).

...

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 = LEGIT(train$data, train$G, train$E, y ~ G*E)
ssres = sum((test$data$y - predict(fit, test$data, test$G, test$E))^2)
sstotal = sum((test$data$y - mean(test$data$y))^2)
R2 = 1 - ssres/sstotal

Run the code above in your browser using DataLab