Functions for the palasso
manuscript.
.prepare(X, filter = 1, cutoff = "zero", scale = TRUE)
.simulate(x, effects)
.predict(
y,
X,
nfolds.ext = 5,
nfolds.int = 5,
adaptive = TRUE,
standard = TRUE,
elastic = TRUE,
shrink = TRUE,
family = "binomial",
...
)
.select(y, X, index, nfolds = 5, standard = TRUE, adaptive = TRUE, ...)
covariates: matrix with \(n\) rows and \(p\) columns
numeric, multiplying the sample size
character "zero", "knee", or "half"
logical
covariates: list of length \(k\), including matrices with \(n\) rows and \(p\) columns
number of causal covariates: vector of length \(k\)
response: vector of length \(n\)
number of external folds
arguments for palasso
indices of causal covariates: list of length \(k\), including vectors
.prepare
:
pre-processes sequencing data by
removing features with a low total abundance,
and adjusting for different library sizes;
obtains two transformations of the same data
by (1) binarising the counts with some cutoff
and (2) taking the Anscombe transform;
scales all covariates to mean zero and unit variance.
.simulate
:
simulates the response by
exploiting two experimental covariate matrices;
allows for different numbers of non-zero coefficients for X and Z.
.predict
:
estimates the predictive performance of different lasso models
(standard X and/or Z, adaptive X and/or Z, paired X and Z);
minimises the loss function "deviance", but also returns other loss functions;
supports logistic and Cox regression.
.select
:
estimates the selective performance of different lasso models
(standard X and/or Z, adaptive X and/or Z, paired X and Z);
limits the number of covariates to \(10\);
returns the number of selected covariates,
and the number of correctly selected covariates.
Use palasso to fit the paired lasso.
if (FALSE) set.seed(1)
n <- 30; p <- 40
X <- matrix(rpois(n*p,lambda=3),nrow=n,ncol=p)
x <- palasso:::.prepare(X)
y <- palasso:::.simulate(x,effects=c(1,2))
predict <- palasso:::.predict(y,x)
#> lambda nzero length
#> standard_x [0.3,(0.1),0.003] [0,(8),17] 100
#> standard_z [0.3,(0.07),0.003] [0,(5),17] 100
#> standard_xz [0.3,(0.05),0.003] [0,(12),15] 100
#> adaptive_x [0.1,(0.05),0.001] [0,(8),17] 100
#> adaptive_z [0.1,(0.03),0.001] [0,(5),17] 100
#> adaptive_xz [0.3,(0.05),0.003] [0,(12),15] 100
#> between_xz [0.3,(0.07),0.003] [0,(9),15] 100
#> within_xz [0.3,(0.05),0.003] [0,(12),15] 100
#> elastic95 [0.3,(0.05),0.003] [0,(12),19] 200
#> lambda nzero length
#> standard_x [0.3,(0.03),0.003] [0,(14),16] 100
#> standard_z [0.2,(0.08),0.002] [0,(6),9] 100
#> standard_xz [0.3,(0.01),0.003] [0,(15),16] 100
#> adaptive_x [7,(0.07),0.07] [0,(7),8] 100
#> adaptive_z [0.1,(0.04),0.001] [0,(6),9] 100
#> adaptive_xz [50,(0.6),0.5] [0,(7),8] 100
#> between_xz [5,(0.05),0.05] [0,(15),16] 100
#> within_xz [1000,(10),10] [0,(7),8] 100
#> elastic95 [0.3,(0.02),0.003] [0,(16),19] 200
#> lambda nzero length
#> standard_x [0.3,(0.02),0.003] [0,(12),15] 100
#> standard_z [0.2,(0.2),0.002] [0,(2),16] 100
#> standard_xz [0.3,(0.03),0.003] [0,(12),16] 100
#> adaptive_x [20,(20),0.2] [0,(0),9] 100
#> adaptive_z [0.1,(0.09),0.001] [0,(2),16] 100
#> adaptive_xz [30,(30),0.3] [0,(0),9] 100
#> between_xz [2,(0.02),0.02] [0,(12),13] 100
#> within_xz [300,(300),3] [0,(0),9] 100
#> elastic95 [0.3,(0.02),0.003] [0,(14),16] 200
#> lambda nzero length
#> standard_x [0.3,(0.1),0.003] [0,(5),13] 100
#> standard_z [0.2,(0.2),0.002] [0,(0),22] 100
#> standard_xz [0.3,(0.3),0.003] [0,(0),18] 100
#> adaptive_x [9,(9),0.09] [0,(0),6] 100
#> adaptive_z [0.09,(0.09),9e-04] [0,(0),22] 100
#> adaptive_xz [30,(30),0.3] [0,(0),6] 100
#> between_xz [2,(2),0.02] [0,(0),13] 100
#> within_xz [300,(300),3] [0,(0),5] 100
#> elastic95 [0.3,(0.06),0.003] [0,(14),19] 200
#> lambda nzero length
#> standard_x [0.3,(0.03),0.003] [0,(9),11] 100
#> standard_z [0.2,(0.02),0.002] [0,(19),20] 100
#> standard_xz [0.3,(0.04),0.003] [0,(11),13] 100
#> adaptive_x [30,(2),0.3] [0,(3),4] 100
#> adaptive_z [0.09,(0.009),9e-04] [0,(19),20] 100
#> adaptive_xz [90,(2),0.9] [0,(4),4] 100
#> between_xz [4,(0.1),0.04] [0,(9),9] 100
#> within_xz [2000,(200),20] [0,(3),4] 100
#> elastic95 [0.3,(0.04),0.003] [0,(11),14] 200
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls > cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls > cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls > cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls > cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls > cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls > cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
select <- palasso:::.select(y,x,attributes(y)) # \dontrun{}