LASSO: LASSO

Description Usage Arguments Value

View source: R/LASSO.R

Description

Applies the LASSO to raw spontaneous report data. Every event is regressed on all the drugs in the data set. The function returns a data frame with every drug-event pair and the estimated regression coefficient.

In case there are not enough observations of an event (the event must appear at least twice), the regression is not performed. All the regression estimates for the drugs and that particular event are set to 0. The entries in the lambda column of the data frame are set to NA.

Shrinkage parameter
One can set the shrinkage parameter with the argument lambda in a number of ways:

  1. lambda = NULL (Default). The parameter is set through cross-validation. The number of folds can be set with nfolds (Default = 10). The loss function used can be set with type.measure (Default = deviance). See for other type.measure options the function glmnet::cv.glmnet. The glmnet::cv.glmnet function returns two estimates: lambda.min and lambda.1se. To use the former, set lambda.type to "min" (default). For the latter, type "1se".

  2. Set to one value, e.g., lambda = 0.5. The same shrinkage parameter is used for all events.

  3. A vector of length n_events, e.g., lambda = c(0.5, 0.8, 1). The shrinkage parameters are specified for each event individually.

Usage

1
2
3
LASSO(reports, n_drugs, n_events, lambda = NULL, nfolds = 10,
  type.measure = "deviance", lambda.type = "min", alpha = 1,
  event_ids = 1:n_events, verbose = FALSE)

Arguments

reports

A binary matrix, where each row represents a report

n_drugs, n_events

The number of drugs and events

lambda

Shrinkage parameter. Can be a list of length n_events. When not set, estimated through cross-validation

nfolds

Number of folds used for cross-validation

type.measure

Loss function used (Default: deviance). See for more options glmnet::cv.glmnet

lambda.type

Type of estimate that is used (either "min" - default - or "1se")

alpha

The elastic net mixing parameter (Default: 1.0 - LASSO)

event_ids

IDs of the events evaluated (Default: all)

verbose

Verbosity (Default: FALSE)

Value

A data frame with the columns

drug_id

ID for the drug (simply numbered 1,2,3,...etc.)

event_id

ID for the event (simply numbered 1,2,3,...etc.)

lambda

The shrinkage parameter λ that was used for this pair. In case the regression was not performed (because the event was not observed or only observed once), the entry is NA

LASSO

The regression parameter after regressing all drugs to the event in question


bips-hb/pvm documentation built on Dec. 14, 2020, 9:31 a.m.