Learn R Programming

glmgraph (version 1.0.3)

predict.cv.glmgraph: make prediction from a fitted "cv.glmgraph" object.

Description

This function makes predictions from a cross-validated glmgraph model, using the stored "cv.glmgraph" object, and the optimal value chosen for lambda1 and lambda2.

Usage

"predict"(object,X,s=c("lambda1.min","lambda1.1se"), type=c("response", "coefficients","class", "nzeros","link"),...)

Arguments

object
Fitted "cv.glmgraph" model object.
X
Matrix at which predictions are to be made.
s
Either "lambda1.min" or "lambda1.1se".If "lambda1.min" is used, prediction based on coefficient of best cross validation criteria(minimum "mse" or "mae" if family is "gaussian"; maximum "auc" or minimum "deviance" if family is "binomial") are returned. Otherwise, predictficients based on one-standard error rule are returned. The default value is "lambda1.min".
type
Type of prediction: "link" returns the linear predictors; "response" gives the fitted values; "class" returns the binomial outcome with the highest probability; "coefficients" returns the coefficients; "nzeros" returns a list containing the indices and names of the nonzero variables at each combination of lambda1 and lambda2.
...
Other parameters to predict

References

Li Chen. Han Liu. Hongzhe Li. Jun Chen. (2015) Graph-constrained Regularization for Sparse Generalized Linear Models.(Working paper)

See Also

cv.glmgraph,coef.cv.glmgraph

Examples

Run this code
 set.seed(1234)
 library(glmgraph)
 n <- 100
 p1 <- 10
 p2 <- 90
 p <- p1+p2
 X <- matrix(rnorm(n*p), n,p)
 magnitude <- 1
 ### construct laplacian matrix from adjacency matrix
 A <- matrix(rep(0,p*p),p,p)
 A[1:p1,1:p1] <- 1
 A[(p1+1):p,(p1+1):p] <- 1
 diag(A) <- 0
 btrue <- c(rep(magnitude,p1),rep(0,p2))
 intercept <- 0
 eta <- intercept+X%*%btrue
 diagL <- apply(A,1,sum)
 L <- -A
 diag(L) <- diagL
 ### gaussian
 Y <- eta+rnorm(n)
 cv.obj <- cv.glmgraph(X,Y,L)
 beta.min <- predict(cv.obj,X,type="coefficients")

Run the code above in your browser using DataLab