| predict.ggmix_fit {ggmix} | R Documentation | 
Make predictions from a ggmix_fit object
Description
Similar to other predict methods, this functions predicts fitted
values, coefficients and more from a fitted ggmix_fit object.
Usage
## 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   | 
newx | 
 matrix of values for   | 
s | 
 Value(s) of the penalty parameter   | 
type | 
 Type of prediction required. Type   | 
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
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")