Learn R Programming

fixest (version 0.8.0)

stepwise: Stepwise estimation tools

Description

Functions to perform stepwise estimations.

Usage

stepwise(...)

sw

cstepwise

csw

stepwise0

sw0

cstepwise0

csw0

Arguments

...

Represents formula variables to be added in a stepwise fashion to an estimation.

Format

An object of class function of length 1.

An object of class function of length 1.

An object of class function of length 1.

An object of class function of length 1.

An object of class function of length 1.

An object of class function of length 1.

An object of class function of length 1.

Details

To include multiple independent variables, you need to use the stepwise functions. There are 4 stepwise functions associated to 4 short aliases. These are a) stepwise, stepwise0, cstepwise, cstepwise0, and b) sw, sw0, csw, csw0. Let's explain that.

Assume you have the following formula: fml = y ~ x1 + sw(x2, x3). The stepwise function sw will estimate the following two models: y ~ x1 + x2 and y ~ x1 + x3. That is, each element in sw() is sequentially, and separately, added to the formula. Would have you used sw0 in lieu of sw, then the model y ~ x1 would also have been estimated. The 0 in the name means that the model wihtout any stepwise element also needs to be estimated.

Finally, the prefix c means cumulative: each stepwise element is added to the next. That is, fml = y ~ x1 + csw(x2, x3) would lead to the following models y ~ x1 + x2 and y ~ x1 + x2 + x3. The 0 has the same meaning and would also lead to the model without the stepwise elements to be estimated: in other words, fml = y ~ x1 + csw0(x2, x3) leads to the following three models: y ~ x1, y ~ x1 + x2 and y ~ x1 + x2 + x3.

Examples

Run this code
# NOT RUN {
base = iris
names(base) = c("y", "x1", "x2", "x3", "species")

# Regular stepwise
feols(y ~ sw(x1, x2, x3), base)

# Cumulative stepwise
feols(y ~ csw(x1, x2, x3), base)

# Using the 0
feols(y ~ x1 + x2 + sw0(x3), base)

# }

Run the code above in your browser using DataLab