n <- 100
p <- 100
xvar <- matrix(ncol=p,nrow=p)
for(i in 1:p) for(j in i:p) xvar[i,j] <- 0.5^{abs(i-j)}
x <- matrix(rnorm(p*n), nrow=n)%*%chol(xvar)
beta <- matrix( (-1)^(1:p)*exp(-(1:p)/10) )
mu = x%*%beta
y <- rbinom(n, prob=1/(1+exp(-2*mu)), size=1)
fit <- cvselect(gamlr(x, y, verb=TRUE, family="binomial"), npen=5, nfold=5)
## plot some model selection criterion
par(mfrow=c(1,3))
## again, the CV plot
cvplot(fit)
## BF
plot(-log(fit$penalty),fit$BF,ylab="log BF", pch=21,bg="darkorange")
## adj BF
points(-log(fit$penalty),fit$BF-fit$zerodf,pch=21,bg="dodgerblue")
## fitted values and all crit
plot(fit, select="CV", col=8)
abline(v=-log(fit$penalty)[which.min(AIC(fit))], col="green", lty=2) # AIC
abline(v=-log(fit$penalty)[which.min(AIC(fit, k=log(fit$n)))], col="red", lty=2) # BIC
abline(v=-log(fit$penalty)[which.max(fit$BF)], col="darkorange", lty=2) # BF
abline(v=-log(fit$penalty)[which.max(fit$BF-fit$zerodf)], col="dodgerblue", lty=2) # adjBF
Run the code above in your browser using DataLab