predict.apple {apple}R Documentation

Model prediction based on a fitted apple/cv.apple object.

Description

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

Usage

## S3 method for class 'apple'
predict(object, X, which = 1:length(object$lambda), 
type = c("link", "response", "class"),...)

Arguments

object

fitted "apple" or "cv.apple" model object.

X

matrix of values at which predictions are to be made.

which

indices of the penalty parameter lambda at which predictions are required. by default, all indices are returned.

type

type of prediction: "link" returns the linear predictors; "response" gives the fitted values; "class" returns the binomial outcome with the highest probability.

...

see matplot.

Value

The object returned depends on type.

Author(s)

Yi Yu and Yang Feng

References

Yi Yu and Yang Feng, APPLE: Approximate Path for Penalized Likelihood Estimator, manuscript.

See Also

apple, cv.apple and plot.apple

Examples


p=10
n=200
d=5
coefs=c(3,1.5,0,0,2)
intercept=0
beta=rep(0,p)
beta[1:d]=coefs
set.seed(2)
X=matrix(rnorm(p*n), nrow=n)
mu=1/(1+exp(-X %*% beta-intercept))
y=rbinom(n,1,mu)
	

fit.apple=apple(X, y, family="binomial")


set.seed(3)
testX=matrix(rnorm(p*n), nrow=n)

predict(fit.apple,testX,type="link")
predict(fit.apple,testX,type="response")
predict(fit.apple,testX,type="class")


fit=cv.apple(X, y, family="binomial", alpha=0)
predict(fit.apple,testX,type="link", which = fit$cv.loc)
predict(fit.apple,testX,type="response", which = fit$cv.loc)
predict(fit.apple,testX,type="class", which = fit$cv.loc)


[Package apple version 0.3 Index]