Title: | Paired Lasso Regression |
---|---|
Description: | Implements sparse regression with paired covariates (Rauschenberger et al. 2020 <doi:10.1007/s11634-019-00375-6>). For the optional shrinkage, install ashr (<https://github.com/stephens999/ashr>) and CorShrink (<https://github.com/kkdey/CorShrink>) from GitHub (see README). |
Authors: | Armin Rauschenberger [aut, cre] |
Maintainer: | Armin Rauschenberger <[email protected]> |
License: | GPL-3 |
Version: | 0.0.9 |
Built: | 2024-09-12 05:00:10 UTC |
Source: | https://github.com/rauschenberger/palasso |
This function combines local -values to a global
-value.
.combine(x, method = "simes")
.combine(x, method = "simes")
x |
local |
method |
character |
These functions return a numeric vector of length
(main effects),
or a numeric matrix with
rows and
columns
(interaction effects).
Westfall, P. H. (2005). "Combining p-values". Encyclopedia of Biostatistics doi:10.1002/0470011815.b2a15181
# independence p <- runif(10) palasso:::.combine(p) ## dependence #runif <- function(n,cor=0){ # Sigma <- matrix(cor,nrow=n,ncol=n) # diag(Sigma) <- 1 # mu <- rep(0,times=n) # q <- MASS::mvrnorm(n=1,mu=mu,Sigma=Sigma) # stats::pnorm(q=q) #} #p <- runif(n=10,cor=0.8) #combine(p)
# independence p <- runif(10) palasso:::.combine(p) ## dependence #runif <- function(n,cor=0){ # Sigma <- matrix(cor,nrow=n,ncol=n) # diag(Sigma) <- 1 # mu <- rep(0,times=n) # q <- MASS::mvrnorm(n=1,mu=mu,Sigma=Sigma) # stats::pnorm(q=q) #} #p <- runif(n=10,cor=0.8) #combine(p)
Calculates the correlation between the response and the covariates. Shrinks the correlation coefficients for each covariate set separately.
.cor(y, x, args)
.cor(y, x, args)
y |
vector of length |
x |
matrix with |
args |
options for paired lasso: list of arguments (output from .dims and .args) |
list of vectors
NA
NA
Repeatedly leaves out samples, and predicts their response.
.cv(y, x, foldid, lambda, args)
.cv(y, x, foldid, lambda, args)
y |
response:
vector of length |
x |
covariates:
matrix with |
foldid |
fold identifiers:
vector of length |
lambda |
lambda sequence: vector of decreasing positive values |
args |
options for paired lasso: list of arguments (output from .dims and .args) |
Returns matrix of predicted values (except "cox")
NA
NA
This function extracts the dimensions.
.dims(y, X, args = NULL)
.dims(y, X, args = NULL)
y |
response:
vector of length |
X |
covariates:
list of matrices,
each with |
args |
options for paired lasso: list of arguments (output from .dims and .args) |
The function .dims
extracts the dimensionality.
It returns the numbers of samples,
covariate pairs and covariate sets.
It also returns the number of weighting schemes,
and the names of these weighting schemes.
NA
NA
Extracts cv.glmnet
-like object.
.extract(fit, lambda, cvm, type.measure)
.extract(fit, lambda, cvm, type.measure)
fit |
matrix with one row for each sample
("gaussian", "binomial" and "poisson"),
or one row for each fold (only "cox"),
and one column for each |
lambda |
lambda sequence: vector of decreasing positive values |
cvm |
mean cross-validated loss:
vector of same length as |
type.measure |
... loss function: character "deviance", "mse", "mae", "class", or "auc" |
NA
NA
Fits all models from the chosen bag.
.fit(y, x, args)
.fit(y, x, args)
y |
response:
vector of length |
x |
covariates:
matrix with |
args |
options for paired lasso: list of arguments (output from .dims and .args) |
list of glmnet
-like objects
NA
NA
Assigns samples to cross-validation folds, balancing the folds in the case of a binary or survival response.
.folds(y, nfolds, foldid = NULL)
.folds(y, nfolds, foldid = NULL)
y |
response:
vector of length |
nfolds |
number of folds:
positive integer
( |
foldid |
fold identifiers:
vector of length |
Returns the fold identifiers.
NA
NA
Calculates mean cross-validated loss
.loss(y, fit, family, type.measure, foldid = NULL)
.loss(y, fit, family, type.measure, foldid = NULL)
y |
response:
vector of length |
fit |
matrix with one row for each sample
("gaussian", "binomial" and "poisson"),
or one row for each fold (only "cox"),
and one column for each |
family |
model family: character "gaussian", "binomial", "poisson", or "cox" |
type.measure |
... loss function: character "deviance", "mse", "mae", "class", or "auc" |
foldid |
fold identifiers:
vector of length |
Returns list of vectors, one for each model.
NA
NA
Calculates the weighting schemes.
.weight(cor, args)
.weight(cor, args)
cor |
correlation coefficients:
list of |
args |
options for paired lasso: list of arguments (output from .dims and .args) |
list of named vectors (one for each weighting scheme)
NA
NA
This page lists the arguments for the (internal) "palasso" function(s).
y |
response:
vector of length |
X |
covariates:
list of matrices,
each with |
max |
maximum number of non-zero coefficients:
positive numeric, or |
... |
|
x |
covariates:
matrix with |
args |
options for paired lasso: list of arguments (output from .dims and .args) |
nfolds |
number of folds:
positive integer
( |
foldid |
fold identifiers:
vector of length |
cor |
correlation coefficients:
list of |
lambda |
lambda sequence: vector of decreasing positive values |
family |
model family: character "gaussian", "binomial", "poisson", or "cox" |
type.measure |
... loss function: character "deviance", "mse", "mae", "class", or "auc" |
fit |
matrix with one row for each sample
("gaussian", "binomial" and "poisson"),
or one row for each fold (only "cox"),
and one column for each |
cvm |
mean cross-validated loss:
vector of same length as |
This page lists the main methods for class "palasso".
## S3 method for class 'palasso' predict(object, newdata, model = "paired", s = "lambda.min", max = NULL, ...) ## S3 method for class 'palasso' coef(object, model = "paired", s = "lambda.min", max = NULL, ...) ## S3 method for class 'palasso' weights(object, model = "paired", max = NULL, ...) ## S3 method for class 'palasso' fitted(object, model = "paired", s = "lambda.min", max = NULL, ...) ## S3 method for class 'palasso' residuals(object, model = "paired", s = "lambda.min", max = NULL, ...) ## S3 method for class 'palasso' deviance(object, model = "paired", max = NULL, ...) ## S3 method for class 'palasso' logLik(object, model = "paired", max = NULL, ...) ## S3 method for class 'palasso' summary(object, model = "paired", ...)
## S3 method for class 'palasso' predict(object, newdata, model = "paired", s = "lambda.min", max = NULL, ...) ## S3 method for class 'palasso' coef(object, model = "paired", s = "lambda.min", max = NULL, ...) ## S3 method for class 'palasso' weights(object, model = "paired", max = NULL, ...) ## S3 method for class 'palasso' fitted(object, model = "paired", s = "lambda.min", max = NULL, ...) ## S3 method for class 'palasso' residuals(object, model = "paired", s = "lambda.min", max = NULL, ...) ## S3 method for class 'palasso' deviance(object, model = "paired", max = NULL, ...) ## S3 method for class 'palasso' logLik(object, model = "paired", max = NULL, ...) ## S3 method for class 'palasso' summary(object, model = "paired", ...)
object |
palasso object |
newdata |
covariates:
list of matrices, each with |
model |
character |
s |
penalty parameter:
character |
max |
maximum number of non-zero coefficients,
positive integer,
or |
... |
further arguments for
|
By default, the function predict
returns
the linear predictor (type="link"
).
Consider predicting the response (type="response"
).
Use palasso to fit the paired lasso.
The function palasso
fits the paired lasso.
Use this function if you have paired covariates
and want a sparse model.
palasso(y = y, X = X, max = 10, ...)
palasso(y = y, X = X, max = 10, ...)
y |
response:
vector of length |
X |
covariates:
list of matrices,
each with |
max |
maximum number of non-zero coefficients:
positive numeric, or |
... |
Let x
denote one entry of the list X
. See glmnet
for alternative specifications of y
and x
. Among the further
arguments, family
must equal "gaussian"
, "binomial"
,
"poisson"
, or "cox"
, and penalty.factor
must not be
used.
Hidden arguments:
Deactivate adaptive lasso by setting adaptive
to FALSE
,
activate standard lasso by setting standard
to TRUE
,
and activate shrinkage by setting shrink
to TRUE
.
This function returns an object of class palasso
.
Available methods include
predict
,
coef
,
weights
,
fitted
,
residuals
,
deviance
,
logLik
,
and summary
.
A Rauschenberger, I Ciocanea-Teodorescu, RX Menezes, MA Jonker, and MA van de Wiel (2020). "Sparse classification with paired covariates." Advances in Data Analysis and Classification. 14:571-588. doi:10.1007/s11634-019-00375-6, pdf, [email protected]
set.seed(1) n <- 50; p <- 20 y <- rbinom(n=n,size=1,prob=0.5) X <- lapply(1:2,function(x) matrix(rnorm(n*p),nrow=n,ncol=p)) object <- palasso(y=y,X=X,family="binomial") # adaptive=TRUE,standard=FALSE names(object)
set.seed(1) n <- 50; p <- 20 y <- rbinom(n=n,size=1,prob=0.5) X <- lapply(1:2,function(x) matrix(rnorm(n*p),nrow=n,ncol=p)) object <- palasso(y=y,X=X,family="binomial") # adaptive=TRUE,standard=FALSE names(object)