Learn R Programming

isodistrreg (version 0.6.0)

idrbag: Compute IDR predictions with (su)bagging

Description

Computes IDR predictions with bootstrap aggregating (bagging) or subsample aggregation (subagging).

Usage

idrbag(y, X, y_observed = NULL, weights = NULL, decreasing = FALSE,
  groups = setNames(rep(1, ncol(X)), colnames(X)), orders = c("comp" = 1),
  stoch = "sd", pars = list(verbose = FALSE, eps_abs = 1e-5,
  eps_rel = 1e-5, max_iter = 10000L), n_jobs = 1, progress = TRUE, newdata,
  digits = NULL, interpolation = "linear", b, p, replace = FALSE,
  grid = NULL, seed = NULL)

Value

A list of predictions, see predict.idrfit.

Arguments

y

numeric vector (the response variable).

X

data frame of numeric or ordered factor variables (the regression covariates).

y_observed

vector of indicators (TRUE or 1 for observed, FALSE or 0 for right-censored). At least one observation must be uncensored. Default is all observed (rep(TRUE, length(y))).

weights

vector of finite, non-negative weights (same length as y), at least one of which must be positive; observations with zero weight are dropped from the fit. Default is all weights equal to one. Weights are processed in single precision; it is up to the caller to avoid extreme imbalance (as a rule of thumb, no weight below ~1e-7 of the total weight).

decreasing

boolean indicating whether y decreases with X (by default, it increases with X).

groups

named vector of length ncol(X) denoting groups of variables that are to be ordered with the same order (see 'Details'). Only relevant if X contains more than one variable. The same names as in X should be used.

orders

named vector giving for each group in groups the order that will be applied to this group. Only relevant if X contains more than one variable. The names of orders give the order, the entries give the group labels. Available options: "comp" for componentwise order, "sd" for stochastic dominance, "icx" for increasing convex order (see 'Details). Default is "comp" for all variables. The "sd" and "icx" orders can only be used with numeric variables, but not with ordered factors.

stoch

stochastic order constraint used for estimation. Default is "sd" for first order stochastic dominance. Use "hazard" for hazard rate order (experimental).

pars

parameters for quadratic programming optimization (only relevant if X has more than one column), a list with options "verbose" T / F (verbosity of solver), "eps_abs" positive float, "eps_rel" positive float, "max_iter" positive integer.

n_jobs

number of worker threads used to fit the individual subsamples in parallel. Only relevant when (su)bagging is active. Default is 1 (serial execution).

progress

display a progress bar while fitting (TRUE, FALSE or 1, 0). Default is TRUE; the bar is written to stderr and is best viewed in an interactive R session.

newdata

data.frame containing variables with which to predict. Ordered factor variables are converted to numeric for computation, so ensure that the factor levels are identical in newdata and in X.

digits

removed functionality, parameter kept for backwards compatibility but ignored with warning: number of decimal places for the predictive CDF, useful to keep the solution small across covariates.

interpolation

interpolation method for univariate data, ignored at this time (a warning is issued once per session if a value other than "linear" is supplied). Only linear is supported for single variate, multivariate uses midpoint.

b

number of (su)bagging samples.

p

size of (su)bagging samples relative to training data.

replace

draw samples with (TRUE, 1) or without (FALSE, 0) replacement?

grid

grid on which the predictive CDFs are evaluated. Default are the unique values of y.

seed

integer seed for the random number generator. Only relevant when (su)bagging is active.

Details

This function draws b times a random subsample of size ceiling(nrow(X)*p)) from the training data, fits IDR to each subsample, computes predictions for the new data supplied in newdata, and averages the predictions derived from the b subsamples. There are no default values for b and p.