predict.glmgraph: Model predictions based on a fitted "glmgraph" object.

Description Usage Arguments Author(s) See Also Examples

Description

Similar to other predict methods, this function returns predictions from a fitted "glmgraph" object.

Usage

1
2
3
## S3 method for class 'glmgraph'
predict(object, X, type=c("response", "coefficients",
"class", "nzeros","link"), lambda1, lambda2,...)

Arguments

object

Fitted "glmgraph" model object.

X

Matrix of values at which predictions are to be made.

lambda1

Values of the regularization parameter lambda1 at which predictions are requested. For values of lambda1 not in the sequence of fitted models, linear interpolation is used.

lambda2

Values of the regularization parameter lambda1 at which predictions are requested. Specified lambda2 should be the subet of lambda2 used to fit glmgraph object.

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

Author(s)

Li Chen <li.chen@auburn.edu> , Jun Chen <chen.jun2@mayo.edu>

See Also

glmgraph

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 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)
 obj <- glmgraph(X,Y,L)
 res <- predict(obj, X, type="link", lambda1=0.05,lambda2=0.01)
 res <- predict(obj, X, type="response", lambda1=0.05,lambda2=0.01)
 res <- predict(obj,X,type="nzeros",lambda1=0.05,lambda2=0.01)
 ### binomial
 Y <- rbinom(n,1,prob=1/(1+exp(-eta)))
 obj <- glmgraph(X,Y,L,family="binomial")
 res <- predict(obj,X,type="class",lambda1=c(0.05,0.06),lambda2=c(0.02,0.16,0.32))

lichen-lab/SICS documentation built on May 6, 2019, 7:18 a.m.