cocktail(x,y,d,
nlambda=100,
lambda.min=ifelse(nobs
lambda
values - default is 100.lambda.max
- the smallest value of lambda
for which all coefficients are zero. The default depends on the relationship between $N$ (the number of rows in the matrix of predictors) and $p$ (the number of prelambda
sequence. Typically, by leaving this option unspecified users can have
the program compute its own lambda
sequence based on
nlambda
and lambda.min
. Supplying a value of
min(dfmax*1.2,p)
.TRUE
, x matrix is normalized such that sum squares of each column $\sum^N_{i=1}x_{ij}^2/N=1$. Note that x is always centered (i.e. $\sum^N_{i=1}x_{ij}=0$) noeps
. Defaults vamaxit
.cocktail
.dgCMatrix
class, the standard class for sparse numeric matrices in the Matrix
package.). To convert it into normal type matrix use as.matrix()
.lambda
values usedlambda
.alpha=1
is the lasso penalty.
For computing speed reason, if models are not converging or running slow, consider increasing eps
, decreasing
nlambda
, or increasing lambda.min
before increasing
maxit
.FAQ:
Question:
Answer: cv.cocktail
only finds the optimal lambda given alpha fixed. So to
chose an good alpha you need to fit cv on a grid of alpha, say (0.1,0.3, 0.6, 0.9, 1) and choose the one corresponds to the lowest predicted deviance.
Question:cv.cocktail$cvm
, the mean 'cross-validated error' to optimize alpha and lambda as you did in your implementation. However, I don't know what the equation of this error is and this error is not referred to in your paper either. Do you mind explaining what this is?
Answer: We first define the log partial-likelihood for the Cox model. Assume $\hat{\beta}^{[k]}$ is the estimate fitted on $k$-th fold, define the log partial likelihood function as $$L(Data,\hat{\beta}[k])=\sum_{s=1}^{S} x_{i_{s}}^{T}\hat{\beta}[k]-\log(\sum_{i\in R_{s}}\exp(x_{i}^{T}\hat{\beta}[k])).$$ Then the log partial-likelihood deviance of the $k$-th fold is defined as $$D[Data,k]=-2(L(Data,\hat{\beta}[k])).$$ We now define the measurement we actually use for cross validation: it is the difference between the log partial-likelihood deviance evaluated on the full dataset and that evaluated on the on the dataset with $k$-th fold excluded. The cross-validated error is defined as $$CV-ERR[k]=D(Data[full],k)-D(Data[k^{th}\,\,fold\,\,excluded],k).$$
plot.cocktail
data(FHT)
m1<-cocktail(x=FHT$x,y=FHT$y,d=FHT$status,alpha=0.5)
predict(m1,newx=FHT$x[1:5,],s=c(0.01,0.005))
predict(m1,type="nonzero")
plot(m1)
Run the code above in your browser using DataLab