Learn R Programming

emdi (version 2.2.1)

step: Step Function

Description

This generic function selects a model by different criteria in a stepwise algorithm.

Usage

step(object, scope, criteria, direction, trace, steps, ...)

# S3 method for default step(object, ...)

# S3 method for fh step( object, scope = NULL, criteria = "AIC", direction = "both", trace = TRUE, steps = 1000, ... )

Value

The return of step depends on the class of its argument. Please refer to the documentation of the step function of the stats package for details of the default method.

For the fh method information about the resulting "best" model due to the chosen information criterion is provided:

call

the function call that produced the object.

coefficients

data frame containing the estimated regression coefficients, the standard errors and the t- and p-values of the explanatory variables.

Arguments

object

an object of type "fh" that contains the chosen information criterion or of type "lm" for the default method.

scope

formula or a list including two formulas (lower and upper) specifying the models considered in the step function. Defaults to NULL.

criteria

a character string describing the model selection criterion. Criteria that can be chosen are "AIC", "AICc", "AICb1", "AICb2", "BIC", "KIC", "KICc", "KICb1", or "KICb2". Defaults to "AIC".

direction

a character string describing the direction of stepwise algorithm. Directions that can be chosen are "both", "backward" or "forward". Defaults to "both". If no scope argument is provided, the default is "backward".

trace

if TRUE, information about the single steps is provided during the stepwise procedure. Defaults to TRUE.

steps

a number determining the maximum number of steps. Defaults to 1000.

...

additional arguments that are not used in this method.

Details

The default method of the generic function step applies the step function for lm models of the stats package. Please refer to the documentation of the step function of the stats package for details.

The information criteria "AICc", "AICb1", "AICb2", "KIC", "KICc", "KICb1" and "KICb2" are especially developed for Fay-Herriot models by Marhuenda et al. (2014). They are based on a bootstrap algorithm. If one of the criteria is chosen, make sure that the bootstrap iterations (B) of the "fh" object are set to a positive number. For some model extensions of the Fay-Herriot model only the "AIC" and the "BIC" information criteria are provided and for some none of the information criteria are defined. Check the model_select component of the "fh" object (objectname$model$model_select). If no criteria are provided, it is not possible to apply the stepwise variable selection algorithm.

References

Marhuenda, Y., Morales, D. and Pardo, M.C. (2014). Information criteria for Fay-Herriot model selection. Computational Statistics and Data Analysis 70, 268-280.

See Also

step

emdiObject, fh

Examples

Run this code
# \donttest{
# Loading data - population and sample data
data("eusilcA_popAgg")
data("eusilcA_smpAgg")

# Combine sample and population data
combined_data <- combine_data(
  pop_data = eusilcA_popAgg,
  pop_domains = "Domain",
  smp_data = eusilcA_smpAgg,
  smp_domains = "Domain"
)

# Estimate FH model that contains all variables that should be considered
fh_std <- fh(
  fixed = Mean ~ cash + self_empl + unempl_ben,
  vardir = "Var_Mean", combined_data = combined_data,
  domains = "Domain", method = "ml", B = c(0, 50)
)

# Example 1: Use default settings
step(fh_std)

# Example 2: Choose "KICb2" information criterion
step(fh_std, criteria = "KICb2")
# }

Run the code above in your browser using DataLab