Learn R Programming

apple (version 0.3)

cv.apple: cross validation for apple path

Description

Does K-fold cross validation for apple.

Usage

cv.apple(X, y, family="binomial", penalty="LASSO", gamma, K = 10, alpha=0, seed = 1, cha.poi = 1, eps = 1e-15, lambda.min.ratio, max.iter = 100, max.num, n.lambda = 100)

Arguments

X
input matrix, of dimension nobs x nvars; each row is an observation vector.
y
response variable, of dimension nobs x 1. non-negative counts for

family="poisson", binary for family="binomial".

family
response type.
penalty
LASSO and MCP are provided.
gamma
the MCP concavity parameter.
K
number of folds used in cross validation. The default it 10.
alpha
weight used in the cross validation cost function, with $Q (\lambda) =\alpha Dev(\lambda)+ (1-\alpha) s(\lambda) \log n/n.$

seed
random seed used to sample the training sets and test sets
cha.poi
the value used to change from Newton Raphson correction to Coordinate Descent correction, which is the $\alpha$ in the following inequality, $k> \alpha\sqrt{n}$, where $k$ is the size of current active set. when this inequality holds, the correction method changes from Newton Raphson to Coordinate Descent.
eps
the precision used to test the convergence.
lambda.min.ratio
optional input. smallest value for lambda, as a fraction of max.lam, the (data derived) entry value. the default depends on the sample size n relative to the number of variables p. if n > p, the default is 0.0001. otherwise, the default is 0.01.
max.iter
maximum number of iteration in the computation.
max.num
optional input. maximum number of nonzero coefficients.
n.lambda
the number of lambda values.

Value

cv
list of cross validation loss
lambda
list of lambda
a0
the list of intercept
beta
the list of coefficients
cv.loc
location of cv selected solution in the path
ebic.loc
the location of the EBIC selected solution in the path
cv.beta
cross validation selected beta
ebic.beta
ebic selected beta
cv.a0
cv selected intercept
ebic.a0
ebic selected intercept

References

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

See Also

plot.apple, apple and predict.apple

Examples

Run this code

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


fit.cv=cv.apple(X, y, family="binomial", alpha=0.25, K=5)


plot(fit.cv)

Run the code above in your browser using DataLab