predict.ggmix_fit: Make predictions from a 'ggmix_fit' object

Description Usage Arguments Details Value Examples

View source: R/methods.R

Description

Similar to other predict methods, this functions predicts fitted values, coefficients and more from a fitted ggmix_fit object.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## S3 method for class 'ggmix_fit'
predict(
  object,
  newx,
  s = NULL,
  type = c("link", "response", "coefficients", "all", "nonzero", "individual"),
  covariance,
  ...
)

## S3 method for class 'ggmix_fit'
coef(object, s = NULL, type, ...)

Arguments

object

Fitted ggmix_fit model object from the ggmix function

newx

matrix of values for x at which predictions are to be made. Do not include the intercept. Must be a matrix. This argument is not used for type = c("coefficients","nonzero","all"). This matrix must have the same number of columns originally supplied to the ggmix fitting function.

s

Value(s) of the penalty parameter lambda at which predictions are required. Default is the entire sequence used to create the model.

type

Type of prediction required. Type "link" gives the fitted values X β. Type "response" is equivalent to type "link". Type "coefficients" computes the coefficients at the requested values for s and returns the regression coefficients only, including the intercept. Type "all" returns both the regression coefficients and variance components at the requested value of s. Type "nonzero" returns a 1 column matrix of the the nonzero fixed effects, as well as variance components for each value of s. If more than one s is provided, then "nonzero" will return a list of 1 column matrices. Default: "link"

covariance

covariance between test and training individuals. if there are q testing individuals and N-q training individuals, then this covariance matrix is q x (N-q)

...

additional arguments to pass to predict function

Details

s is the new vector at which predictions are requested. If s is not in the lambda sequence used for fitting the model, the predict function will use linear interpolation to make predictions. The new values are interpolated using a fraction of predicted values from both left and right lambda indices. coef(...) is equivalent to predict(ggmix_fit, type="coefficients",...). To get individual level predictions at each value of lambda, you must provide the lambda sequence to the s argument. You can pass either a ggmix_fit or ggmix_gic object. See examples for more details.

Value

The object returned depends on type.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
data("admixed")
fitlmm <- ggmix(x = admixed$xtrain, y = admixed$ytrain,
                kinship = admixed$kin_train,
                estimation = "full")
bicGGMIX <- gic(fitlmm,
                an = log(length(admixed$ytrain)))
plot(bicGGMIX)
coef(bicGGMIX, s = "lambda.min")
yhat_test <- predict(bicGGMIX, s="lambda.min",
                     newx = admixed$xtest, type = "individual",
                     covariance = admixed$kin_test_train)
cor(yhat_test, admixed$ytest)
yhat_test_population <- predict(bicGGMIX, s="lambda.min",
                                newx = admixed$xtest,
                                type = "response")

ggmix documentation built on April 13, 2021, 9:06 a.m.