Running examples in ‘glmnet-Ex.R’ failed
The error most likely occurred in:

> ### Name: cv.glmnet
> ### Title: Cross-validation for glmnet
> ### Aliases: cv.glmnet
> ### Keywords: models regression
> 
> ### ** Examples
> 
> set.seed(1010)
> n=1000;p=100
> nzc=trunc(p/10)
> x=matrix(rnorm(n*p),n,p)
> beta=rnorm(nzc)
> fx= x[,seq(nzc)] %*% beta
> eps=rnorm(n)*5
> y=drop(fx+eps)
> px=exp(fx)
> px=px/(1+px)
> ly=rbinom(n=length(px),prob=px,size=1)
> set.seed(1011)
> cvob1=cv.glmnet(x,y)
> plot(cvob1)
> coef(cvob1)
101 x 1 sparse Matrix of class "dgCMatrix"
                       1
(Intercept) -0.114499004
V1          -0.249682465
V2           0.354656099
V3           .          
V4          -0.250595374
V5          -0.220882137
V6           0.281975536
V7           0.226455138
V8          -1.389842399
V9           1.055440917
V10          0.185144685
V11          .          
V12          .          
V13          .          
V14          .          
V15          .          
V16          .          
V17          .          
V18         -0.008251507
V19          .          
V20          .          
V21          .          
V22          .          
V23          .          
V24          .          
V25          .          
V26          0.029472478
V27          .          
V28          .          
V29          .          
V30          .          
V31          .          
V32          .          
V33          .          
V34          .          
V35          .          
V36          .          
V37          .          
V38          .          
V39          .          
V40          .          
V41          .          
V42          .          
V43          .          
V44          .          
V45          .          
V46          .          
V47          .          
V48          .          
V49          .          
V50          .          
V51          .          
V52          .          
V53          .          
V54          .          
V55          .          
V56          .          
V57          .          
V58          .          
V59          .          
V60          .          
V61          .          
V62          .          
V63          .          
V64          .          
V65          .          
V66          .          
V67          .          
V68          .          
V69          .          
V70          .          
V71          .          
V72          .          
V73          .          
V74          .          
V75         -0.177175572
V76          .          
V77          .          
V78          .          
V79          .          
V80          .          
V81          .          
V82          .          
V83          .          
V84          .          
V85          .          
V86          .          
V87          .          
V88          .          
V89          .          
V90          .          
V91          .          
V92          .          
V93          .          
V94          .          
V95          .          
V96          .          
V97          .          
V98          .          
V99          .          
V100         .          
> predict(cvob1,newx=x[1:5,], s="lambda.min")
              1
[1,] -1.3447658
[2,]  0.9443441
[3,]  0.6989746
[4,]  1.8698290
[5,] -4.7372693
> title("Gaussian Family",line=2.5)
> set.seed(1011)
> cvob1a=cv.glmnet(x,y,type.measure="mae")
> plot(cvob1a)
> title("Gaussian Family",line=2.5)
> set.seed(1011)
> par(mfrow=c(2,2),mar=c(4.5,4.5,4,1))
> cvob2=cv.glmnet(x,ly,family="binomial")
> plot(cvob2)
> title("Binomial Family",line=2.5)
> frame()
> set.seed(1011)
> cvob3=cv.glmnet(x,ly,family="binomial",type.measure="class")
> plot(cvob3)
> title("Binomial Family",line=2.5)
> set.seed(1011)
> cvob3a=cv.glmnet(x,ly,family="binomial",type.measure="auc")
> plot(cvob3a)
> title("Binomial Family",line=2.5)
> set.seed(1011)
> mu=exp(fx/10)
> y=rpois(n,mu)
> cvob4=cv.glmnet(x,y,family="poisson")
> plot(cvob4)
> title("Poisson Family",line=2.5)
> # Multinomial
> n=500;p=30
> nzc=trunc(p/10)
> x=matrix(rnorm(n*p),n,p)
> beta3=matrix(rnorm(30),10,3)
> beta3=rbind(beta3,matrix(0,p-10,3))
> f3=x%*% beta3
> p3=exp(f3)
> p3=p3/apply(p3,1,sum)
> g3=rmult(p3)
> set.seed(10101)
> cvfit=cv.glmnet(x,g3,family="multinomial")
Error in apply(nz, 1, median) : dim(X) must have a positive length
Calls: cv.glmnet -> apply
Execution halted