Stepwise Model Term Selection Using GAIC

Description

The optimizer function stepwise() performs stepwise model term selection using a Generalized Akaike Information Criterion (GAIC). Estimation is based on the Rigby and Stasinopoulos (RS) and Cole and Green (CG) algorithms, as implemented in function RS.

Usage

## wrapper function for stepwise GAMLSS estimation
step_gamlss2(formula, ..., fixed = NULL, K = 2,
  strategy = c("both.linear", "both"), keeporder = FALSE,
  cores = 1L)

## stepwise optimizer function
stepwise(x, y, specials, family, offsets,
  weights, start, xterms, sterms, control)

Arguments

formula A model formula for gamlss2.
… Arguments passed to gamlss2.
fixed An optional one-sided formula, Formula object, or list of formulas specifying model terms that must always remain in the model. Terms must also occur in the search scope given by formula. For multi-parameter families, right-hand sides or list elements correspond to the distributional parameters in their usual order.
K Numeric, the penalty for the GAIC.
strategy Character vector of selection strategies; see the details.
keeporder Logical. Update distributional parameters sequentially rather than search across all parameters? See the details for the order.
cores Integer, number of workers for candidate fits. The default cores = 1L runs sequentially. Larger values use future_lapply with a temporary multisession plan, including on Windows. The caller’s future plan is restored on exit. This requires the suggested packages future and future.apply.
x, y, specials, family, offsets, weights, start, xterms, sterms Model components and starting values passed to the optimizer, as documented for RS.
control Further control arguments as specified within the call of gamlss2.

Details

The wrapper function step_gamlss2() calls gamlss2 using the stepwise() optimizer function.

Argument strategy selects one or more strategies:

“forward”
Add the term that most improves the GAIC.
“backward”
Remove the term that most improves the GAIC.
“replace”
Exchange a selected term for an unselected term if this improves the GAIC.
“both”
Consider both additions and removals.
“all”
Combine forward, backward, and replacement steps.

Append “.linear” to any strategy to restrict it to linear terms. These strategies run before those applied to all model terms. The default is strategy = c(“both.linear”, “both”) and keeporder = FALSE. Selected strategies are iterated until the GAIC no longer improves.

With keeporder = TRUE, parameters are updated in the order specified by gamlss2.family, or in reverse order for backward elimination. Otherwise, selection searches across all parameters.

Terms supplied in fixed are included in the initial model and are never eligible for removal or replacement. The intercept is always retained and need not be included in fixed. Fixing a linear interaction also fixes all of its available lower-order marginal terms.

Linear selection is performed on formula terms, not individual columns of the model matrix. Thus, all columns representing a factor or an interaction with a factor are added, removed, or replaced together. Linear interactions obey strong hierarchy: an interaction can enter only after its available lower-order terms have entered, and a lower-order term cannot be removed while an included interaction depends on it.

Value

The optimizer function stepwise() returns the final model as a named list of class “gamlss2”. See the return value of function RS. The wrapper function step_gamlss2() also returns the final model.

See Also

new_formula, gamlss2, gamlss2_control, RS

Examples

library("gamlss2")

## scale the covariates first
air <- subset(airquality, !is.na(Ozone))
air$Wind <- scale(air$Wind)
air$Temp <- scale(air$Temp)

## the formula defines the searching scope
f <- Ozone ~ Wind + Temp + Wind:Temp +
  ti(Wind) + ti(Temp) + ti(Wind, Temp) | .

## estimate a Gamma model using the stepwise algorithm
m1 <- step_gamlss2(f, data = air, family = GA, K = 2)

## always retain both linear main effects
m2 <- step_gamlss2(f, data = air, family = GA, K = 2,
  fixed = ~ Wind + Temp | .)

## same with
## m <- gamlss2(f, data = air, family = NO,
##   optimizer = stepwise, K = 2)

## show the new formula of selected model terms
new_formula(m1)

## final model summary
summary(m1)

## effect plots
plot(m1)

## diagnostic plots
plot(m1, which = "resid")

## plot GAIC
plot(m1, which = "selection")

## use forward linear, replace and backward strategy
m2 <- step_gamlss2(f, data = air, family = GA, K = 2,
  strategy = c("forward.linear", "replace", "backward"))

## plot GAIC
plot(m2, which = "selection")