levelcv {logilasso}R Documentation

Cross-Validation for different interaction levels

Description

Performs cross-validation for interactions involving k, k+1,...,k+u factors which can be specified by the arguments from.which.int=k and to.which.int=k+u. For each interaction order k+j a cvfold cross-validation is performed. Returns an object of class levellogilasso which is a subclass of cvlogilasso.

Usage

levelcv(Y ,combX = NULL , from.which.int = 1, to.which.int=NULL,
epsilon = 0.1, lambdainit =1, lambdamin = 0.1, trace = 1,
method = "groupl1", cvfold=10, Newton = TRUE, stopkrit = 1e-8)

Arguments

The function can be initialized in 2 different ways: 1. Y as a contingency table. 2. Y together wit a combination matrix combX (see example).

Y The vector containing the counts for each cell in the contingency table. Either given as table or as vector together with a matrix combX, where each component of the vector corresponds to a combination of factors in the corresponding row of combX.
combX Matrix of dimension length(Y) x number of factors. For each component of Y the corresponding combinations of the level is given as a row entry. See example.
from.which.int Numeric. The samllest number of factors whose interaction is considered. For example if it is =1, the algorithm starts considering all main effects models.
to.which.int Up to which interaction should the solution be calculated. to.which.int=n indicate that interaction involving n factors are considered.
epsilon The step length for lambda. In each step, lambda diminished by epsilon.
lambdainit The upper bound for lambda, where the solution path for beta starts.
lambdamin The lower bound for lambda, where the solution path ends.
trace Defines what is printed out during the calculation. 0 = nothing, 1 = Current cvfold 2 = additionally points for each lambda 3 = Every 10th step writes the active set 4 = Additionally the new active set are written out, whenever a component enters the active set
method Is either "groupl1", "l1" or "l2", depending on the desired penalization of the coefficients.
cvfold If cvfold is larger than 1, cross-validation is performed.
Newton Logical. If Newton=TRUE, Newton steps are performed, otherwise the function optim is used.
stopkrit Convergence tolerance; the smaller the more precise.

Details

A levellogilasso object is returned. This is a list of objects of class cvlogilasso for each interaction from from.which.int to to.which.int. For objects of that class, the methods plot, predict, traceplot and graphmod are available.

Value

The elements of the list of class cvlogilasso each consists of the following entries:

loss A loss matrix of dimension cvfold x number of assessed lambdas in the solution path. For each part of the data left out, the loss for all lambdas of the solution path is calculated. The loss is NULL in case of cvfold=1
path A matrix. In the second row the newly active or newly inactive components of beta are listed to the corresponding lambda in the first row of the matrix. Is NULL for the class cvlogilasso
betapath A matrix of dimension length(beta) x lambda in the solution path. The columns consist of the betas for the different lambdas in lambdapath. Is NULL for the class cvlogilasso.
lambdapath A vector of all lambdas for which the solution was calculated.
X The design matrix used to fit the log-linear model.
nrfac Number of factors.

References

Corinne Dahinden, Giovanni Parmigiani, Mark Emerik and Peter Buehlmann available at http://stat.ethz.ch/~dahinden/Paper/BMC.pdf

Examples

library(gRbase)
data(reinis)
levellogi <- levelcv(reinis,lambdainit=1,lambdamin=0.1,from.which.int=1,to.which.int=3,cvfold=3)

## The methods predict, plot, traceplot and graphmod are defined for the resulting
## object of class cvlogilasso
predlevel <- predict(levellogi)
plot(predlevel)
traceplot(predlevel)
graphmod(predlevel)

### Different initialization: Y and combX
### 5 factors: All have 2 levels
### nlev would be c(2,2,2,2,2)
Y     <- c(4,1,3,2,9)
combX <- rbind(c(1,0,1,1,0),c(1,0,0,1,1),c(0,1,0,0,1),c(0,0,1,0,0),c(1,1,0,0,1))
### 4 observations wit level 1 of factor 1, level 0 of factor two, level 1 of factor
### 3 and so on.
levellogi2 <- levelcv(Y,combX=combX,from.which.int=1,to.which.int=3,cvfold=3)

[Package logilasso version 0.1.0 Index]