Skip to contents

This function is a patroklos-compliant fitter with integrated CV and, if length(lambda) == 1, also a patroklos-compliant fitter with validated predictions.

Usage

ptk_zerosum(
  x,
  y,
  val_error_fun,
  exclude_pheno_from_lasso = TRUE,
  binarize_predictions = NULL,
  ...,
  nFold = 10,
  zeroSum.weights = NULL,
  penalty.factor = NULL,
  family = "binomial"
)

Arguments

x

data as a numeric matrix object (rows=samples). The zero-sum regression requires data on the log scale, i.e. x should be log-transformed data.

y

Named list with entries

  • "bin", a named numeric one-column matrix, binary response to be used for training,

  • "cox", a named numeric two-column matrix to be used for training, time to event and event (0 = censoring, 1 = event) in first and second column, respectively.

  • "true", a named numeric one-column matrix, binary response to be used for calculating the CV error.

val_error_fun

Function used to calculate the error of independently validated predictions. Must take two numeric vector of equal length: y and y_hat, the true and predicted outcomes, respectively, and return a numeric scalar; the lower, the better the model. See error_rate() or neg_roc_auc() for examples.

exclude_pheno_from_lasso

Logical. If TRUE, set LASSO penalty weights corresponding to features from the pheno data to zero.

binarize_predictions

numeric or NULL. If not NULL, the predict method for the returned ptk_zerosum object will binarize the predictions using the binarize_predictions as a threshold.

...

can be used for adjusting internal parameters

nFold

the number of folds used by the cross validation (Default 10)

zeroSum.weights

weights vector for the zero-sum constraint of length ncol(x). By setting a weight to 0 the corresponding feature will be excluded from the zero-sum constraint. (must be greater than or equal to zero, default 1)

penalty.factor

weights vector for the elatic net regularization of length ncol(x). By setting a weight to 0 the corresponding feature will not be regularized and thus will be part of the resulting model. (must be greater than or equal to zero, default 1).

family

choose the regression type:

gaussian:

numeric response

binomial:
multinomial:
cox:

y should be matrix with two columns, the first must contain the event time and the second indicating the type: 1 = event has occured, 0 = right censoring

Value

A ptk_zerosum S3 object with the cv_predict attribute renamed to val_predict_list.