Learn R Programming

c060

Extended Inference for Lasso and Elastic-Net Regularized Cox and Generalized Linear Models

Maintainer F. Bertrand

https://doi.org/10.32614/CRAN.package.c060

The goal of the c060 package is to provide additional functions to perform stability selection, model validation and parameter tuning for glmnet models.

Installation

You can install the released version of c060 from CRAN with:

install.packages("c060")

And the development version from GitHub with:

install.packages("devtools")
devtools::install_github("fbertran/c060")

Examples

Gaussian Stability Selection

set.seed(1234)
x=matrix(rnorm(100*1000,0,1),100,1000)
y <- x[1:100,1:1000] %*% c(rep(2,5),rep(-2,5),rep(.1,990))
res <- stabpath(y,x,weakness=1,mc.cores=2)
#> Error in `stabpath()`:
#> ! could not find function "stabpath"
stabsel(res,error=0.05,type="pfer")
#> Error in `stabsel()`:
#> ! could not find function "stabsel"

Gaussian Stability Paths

set.seed(1234)
x <- matrix(rnorm(100*1000,0,1),100,1000)
y <- x[1:100,1:1000] %*% c(rep(2,5),rep(-2,5),rep(.1,990))
res <- stabpath(y,x,weakness=1,mc.cores=2)
#> Error in `stabpath()`:
#> ! could not find function "stabpath"
plot(res)
#> Error:
#> ! object 'res' not found

Binomial Stability Paths

y=sample(1:2,100,replace=TRUE)
res <- stabpath(y,x,weakness=1,mc.cores=2,family="binomial")
#> Error in `stabpath()`:
#> ! could not find function "stabpath"
plot(res)
#> Error:
#> ! object 'res' not found

Multinomial Stability Paths

y=sample(1:4,100,replace=TRUE)
res <- stabpath(y,x,weakness=1,mc.cores=2,family="multinomial")
#> Error in `stabpath()`:
#> ! could not find function "stabpath"
plot(res)
#> Error:
#> ! object 'res' not found

Poisson Stability Paths

N=100; p=1000
nzc=5
x=matrix(rnorm(N*p),N,p)
beta=rnorm(nzc)
f = x[,seq(nzc)] %*% beta
mu=exp(f)
y=rpois(N,mu)
res <- stabpath(y,x,weakness=1,mc.cores=2,family="poisson")
#> Error in `stabpath()`:
#> ! could not find function "stabpath"
plot(res)
#> Error:
#> ! object 'res' not found

Cox Stability Paths

library(survival)
set.seed(10101)
N=100;p=1000
nzc=p/3
x=matrix(rnorm(N*p),N,p)
beta=rnorm(nzc)
fx=x[,seq(nzc)] %*% beta/3
hx=exp(fx)
ty=rexp(N,hx)
tcens=rbinom(n=N,prob=.3,size=1)
y=cbind(time=ty,status=1-tcens)
res <- stabpath(y,x,weakness=1,mc.cores=2,family="cox")
#> Error in `stabpath()`:
#> ! could not find function "stabpath"
plot(res)
#> Error:
#> ! object 'res' not found

Example from glmnet package

set.seed(10101)
library(glmnet)
library(survival)
library(peperr)
N=1000;p=30
nzc=p/3
x=matrix(rnorm(N*p),N,p)
beta=rnorm(nzc)
fx=x[,seq(nzc)] %*% beta/3
hx=exp(fx)
ty=rexp(N,hx)
tcens=rbinom(n=N,prob=.3,size=1)# censoring indicator
y=Surv(ty,1-tcens)

EPSGO

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)

y - binomial

y.classes<-ifelse(y>= median(y),1, 0)
set.seed(1234)
nfolds = 10
foldid <- balancedFolds(class.column.factor=y.classes, cross.outer=nfolds)
#> Error in `balancedFolds()`:
#> ! could not find function "balancedFolds"
bounds <- t(data.frame(alpha=c(0, 1)))
colnames(bounds)<-c("lower","upper")
 
fit <- EPSGO(Q.func="tune.glmnet.interval", 
             bounds=bounds, 
             parms.coding="none", 
             seed = 1234, 
             show="final",
             fminlower = -100,
             x = x, y = y.classes, family = "binomial", 
             foldid = foldid,
             my.mfrow = c(4, 4),
             type.min = "lambda.1se",
             type.measure = "mse",
             verbose = FALSE)
#> Error in `EPSGO()`:
#> ! could not find function "EPSGO"
summary(fit)
#> Error in `h()`:
#> ! error in evaluating the argument 'object' in selecting a method for function 'summary': object 'fit' not found

y - multinomial: low - low 25%, middle - (25,75)-quantiles, high - larger 75%.

y.classes<-ifelse(y <= quantile(y,0.25),1, ifelse(y >= quantile(y,0.75),3, 2))
set.seed(1234)
nfolds = 10
foldid <- balancedFolds(class.column.factor=y.classes, cross.outer=nfolds)
#> Error in `balancedFolds()`:
#> ! could not find function "balancedFolds"
bounds <- t(data.frame(alpha=c(0, 1)))
colnames(bounds)<-c("lower","upper")
 
fit <- EPSGO(Q.func="tune.glmnet.interval", 
             bounds=bounds, 
             parms.coding="none", 
             seed = 1234, 
             show="none",
             fminlower = -100,
             x = x, y = y.classes, family = "multinomial", 
             foldid = foldid,
             type.min = "lambda.1se",
             type.measure = "mse",
             verbose = FALSE)
#> Error in `EPSGO()`:
#> ! could not find function "EPSGO"
summary(fit)
#> Error in `h()`:
#> ! error in evaluating the argument 'object' in selecting a method for function 'summary': object 'fit' not found

Gaussian

set.seed(1234)
x=matrix(rnorm(100*1000,0,1),100,1000)
y <- x[1:100,1:1000]%*%c(rep(2,5),rep(-2,5),rep(.1,990))

foldid <- rep(1:10,each=10)

fit <- EPSGO(Q.func="tune.glmnet.interval", 
             bounds=bounds, 
             parms.coding="none", 
             seed = 1234, 
             show="none",
             fminlower = -100,
             x = x, y = y, family = "gaussian", 
             foldid = foldid,
             type.min = "lambda.1se",
             type.measure = "mse",
             verbose = FALSE)
#> Error in `EPSGO()`:
#> ! could not find function "EPSGO"
summary(fit) 
#> Error in `h()`:
#> ! error in evaluating the argument 'object' in selecting a method for function 'summary': object 'fit' not found

Copy Link

Version

Install

install.packages('c060')

Monthly Downloads

347

Version

0.5-0

License

GPL-2

Issues

Pull Requests

Stars

Forks

Maintainer

Frederic Bertrand

Last Published

March 24th, 2026

Functions in c060 (0.5-0)

aggregation.auc

Determine the area under the ROC curve for a fitted model
coef.sum.intsearch

Get coefficients for a model
summary.intsearch

Summary method for interval search models
plot.sum.intsearc

Plot Summary object for interval search models
PLL.coxnet

Predictive partial log-likelihood for glmnet Cox PH model fit
complexity.glmnet

Interface for determination of penalty lambda in penalized regression model via cross-validation
EPSGO

Efficient Parameter Selection via Global Optimization
fit.glmnet

Interface function for fitting a penalized regression model with glmnet
plot.stabpath

function to plot a stability path
balancedFolds

Function producing stratified/ balanced folds for cross validation
Plot.peperr.curves

Plot method for prediction error curves of a peperr object
Plot.coef.glmnet

function to highlight the path of a pre-specified set of variables within the coefficient path
c060-package

c060: Extended Inference for Lasso and Elastic-Net Regularized Cox and Generalized Linear Models
stabsel

function to estimate a stable set of variables
tune.glmnet.interval

Wrapper function for glmnet objects.
predictProb.coxnet

Extract predicted survival probabilities from a glmnet fit
stabpath

Stability path for glmnet models