Learn R Programming

robustHD (version 0.5.0)

grplars: (Robust) groupwise least angle regression

Description

(Robustly) sequence groups of candidate predictors according to their predictive content and find the optimal model along the sequence.

Usage

grplars(x, ...)

## S3 method for class 'formula': grplars(formula, data, ...)

## S3 method for class 'data.frame': grplars(x, y, ...)

## S3 method for class 'default': grplars(x, y, sMax = NA, assign, fit = TRUE, s = c(0, sMax), crit = c("BIC", "PE"), splits = foldControl(), cost = rmspe, costArgs = list(), selectBest = c("hastie", "min"), seFactor = 1, ncores = 1, cl = NULL, seed = NULL, model = TRUE, ...)

rgrplars(x, ...)

## S3 method for class 'formula': rgrplars(formula, data, ...)

## S3 method for class 'data.frame': rgrplars(x, y, ...)

## S3 method for class 'default': rgrplars(x, y, sMax = NA, assign, centerFun = median, scaleFun = mad, regFun = lmrob, regArgs = list(), combine = c("min", "euclidean", "mahalanobis"), const = 2, prob = 0.95, fit = TRUE, s = c(0, sMax), crit = c("BIC", "PE"), splits = foldControl(), cost = rtmspe, costArgs = list(), selectBest = c("hastie", "min"), seFactor = 1, ncores = 1, cl = NULL, seed = NULL, model = TRUE, ...)

Arguments

formula
a formula describing the full model.
data
an optional data frame, list or environment (or object coercible to a data frame by as.data.frame) containing the variables in the model. If not found in data, the variables are taken from
x
a matrix or data frame containing the candidate predictors.
y
a numeric vector containing the response.
sMax
an integer giving the number of predictor groups to be sequenced. If it is NA (the default), predictor groups are sequenced as long as there are twice as many observations as expected predictor variables (number of predictor groups t
assign
an integer vector giving the predictor group to which each predictor variable belongs.
centerFun
a function to compute a robust estimate for the center (defaults to median).
scaleFun
a function to compute a robust estimate for the scale (defaults to mad).
regFun
a function to compute robust linear regressions that can be interpreted as weighted least squares (defaults to lmrob).
regArgs
a list of arguments to be passed to regFun.
combine
a character string specifying how to combine the data cleaning weights from the robust regressions with each predictor group. Possible values are "min" for taking the minimum weight for each observation, "euclidean" for w
const
numeric; tuning constant for multivariate winsorization to be used in the initial corralation estimates based on adjusted univariate winsorization (defaults to 2).
prob
numeric; probability for the quantile of the $\chi^{2}$ distribution to be used in multivariate winsorization (defaults to 0.95).
fit
a logical indicating whether to fit submodels along the sequence (TRUE, the default) or to simply return the sequence (FALSE).
s
an integer vector of length two giving the first and last step along the sequence for which to compute submodels. The default is to start with a model containing only an intercept (step 0) and iteratively add all groups along the sequence (step <
crit
a character string specifying the optimality criterion to be used for selecting the final model. Possible values are "BIC" for the Bayes information criterion and "PE" for resampling-based prediction error estimation.
splits
an object giving data splits to be used for prediction error estimation (see perry).
cost
a cost function measuring prediction loss (see perry for some requirements). The default is to use the root trimmed mean squared prediction error for a robust fit and the root mean squared predic
costArgs
a list of additional arguments to be passed to the prediction loss function cost.
selectBest,seFactor
arguments specifying a criterion for selecting the best model (see perrySelect). The default is to use a one-standard-error rule.
ncores
a positive integer giving the number of processor cores to be used for parallel computing (the default is 1 for no parallelization). If this is set to NA, all available processor cores are used. For obtaining the data cleaning weigh
cl
a parallel cluster for parallel computing as generated by makeCluster. This is preferred over ncores for tasks that are parallelized on the Rlevel, in which case
seed
optional initial seed for the random number generator (see .Random.seed). This is useful because many robust regression functions (including lmrob

Value

  • If fit is FALSE, an integer vector containing the indices of the sequenced predictor groups.

    Else if crit is "PE", an object of class "perrySeqModel" (inheriting from classes "perryTuning", see perryTuning). It contains information on the prediction error criterion, and includes the final model as component finalModel.

    Otherwise an object of class "grplars" (inheriting from class "seqModel") with the following components:

  • activean integer vector containing the sequence of predictor groups.
  • san integer vector containing the steps for which submodels along the sequence have been computed.
  • coefficientsa numeric matrix in which each column contains the regression coefficients of the corresponding submodel along the sequence.
  • fitted.valuesa numeric matrix in which each column contains the fitted values of the corresponding submodel along the sequence.
  • residualsa numeric matrix in which each column contains the residuals of the corresponding submodel along the sequence.
  • dfan integer vector containing the degrees of freedom of the submodels along the sequence (i.e., the number of estimated coefficients).
  • robusta logical indicating whether a robust fit was computed.
  • scalea numeric vector giving the robust residual scale estimates for the submodels along the sequence (only returned for a robust fit).
  • critan object of class "bicSelect" containing the BIC values and indicating the final model (only returned if argument crit is "BIC" and argument s indicates more than one step along the sequence).
  • muXa numeric vector containing the center estimates of the predictor variables.
  • sigmaXa numeric vector containing the scale estimates of the predictor variables.
  • muYnumeric; the center estimate of the response.
  • sigmaYnumeric; the scale estimate of the response.
  • xthe matrix of candidate predictors (if model is TRUE).
  • ythe response (if model is TRUE).
  • assignan integer vector giving the predictor group to which each predictor variable belongs.
  • wa numeric vector giving the data cleaning weights (only returned for a robust fit).
  • callthe matched function call.

See Also

coef, fitted, plot, predict, residuals, lmrob

Examples

Run this code
data("TopGear")
# keep complete observations
keep <- complete.cases(TopGear)
TopGear <- TopGear[keep, ]
# remove information on car model
info <- TopGear[, 1:3]
TopGear <- TopGear[, -(1:3)]
# log-transform price
TopGear$Price <- log(TopGear$Price)

# robust groupwise LARS
rgrplars(MPG ~ ., data = TopGear, sMax = 15)

Run the code above in your browser using DataLab