RATS 11
RATS 11

Instructions /

STWISE Instruction

Home Page

← Previous Next →

STWISE(options)  depvar start end resids

# list of potential explanatory variables in Regression Format

 

STWISE (STepWISE) performs stepwise regressions using one of three methods. It only works with ordinary or weighted least squares; you cannot use instrumental variables.

Wizard

Use the Statistics—Linear Regressions Wizard and choose "Stepwise Regression" as the method.

Parameters

depvar

dependent variable

start, end

estimation range. If you have not set a SMPL, this defaults to the maximum range over which all of the variables involved, dependent and explanatory, are defined.

resid

(Optional) series for residuals

Supplementary card

The order of listing is important if you want to force variables (such as the CONSTANT) into the model, because the FORCE option, described later, will only act on the first variables listed on the card.

 

Please note that no variables are automatically included in each model unless you use the FORCE option.  (Some software automatically includes an intercept.)

Options

Standard Regression Options

Robust Error Options

 

METHOD=[STEPWISE]/BACKWARD/FORWARD/GTOS

Sets the method to be used (see "Stepwise Methods").

 

SLENTER=Threshold significance level for entering the model [.2]

SLENTER is used with the forward and stepwise procedures. At each stage, each variable not yet in the model is added on a trial basis. The one with the highest t-statistic is added if the significance level of its t is less than the threshold, otherwise the procedure is ended.

 

SLSTAY=stay value [.2]

SLSTAY is used with the backward and stepwise procedures. The t-statistic on each variable already in the model is examined. If the significance level on the one with the smallest t-statistic is larger than the threshold value, it is deleted and the procedure is repeated with the reduced regression.

 

If you choose METHOD=STEPWISE, STWISE will not allow you to set SLSTAY to a lower value than SLENTER.

 

FORCE=number of regressors to include in all models [0]

By default, all variables listed on the supplementary card are treated identically. Any may be included or omitted from the final regression. To force regressors into every model, list those variables first on the supplementary card and use the option FORCE to indicate how many are to be forced in. If some of these variables are handled using lag fields, count the number of actual regressors. For example, the following will include CONSTANT and TREND in all models:

 

   stwise(force=2) gnp_82

   # constant trend x1 x2 x3 ...

Variables Defined

Regression Variables

Stepwise Methods

STWISE performs stepwise regressions using one of four methods, selected using the METHOD option:

 

FORWARD (Forward selection)

Variables are added to the model sequentially until no variable not yet in the model would, when added, have a t-statistic with a p-value (significance level) smaller than the SLENTER threshold value.

BACKWARD (Backward selection)

Starting from the full set of regressors, variables with the lowest t-statistics are deleted until all remaining variables have a p–value smaller that the SLSTAY threshold.

STEPWISE (Full stepwise)

This is the default method and combines the first two. At each stage in the forward selection procedure, the backward selection algorithm is run to delete variables which now have small t-statistics.

GTOS (General TO Specific)

Use GTOS (for General TO Specific) if you want STWISE to drop regressors starting at the end of the list on the supplementary card. This is useful for pruning lags from an autoregressive model.

Missing Values

Any observation for which any of the variables is missing is omitted for the analysis.

Example

stwise(method=stepwise,slenter=.05,slstay=.05) y

# y{1 to 12}

compute loglres=%logl

 

This does a stepwise regression choosing lags for an autoregression. The "stepwise" procedure adds regressors when their t-statistic has a marginal significance level is smaller than .05, then deletes any added regressors which have a marginal significance level greater than .05.


 

stwise(method=gtos,force=9,slstay=.05) ysdiff

# constant trend y1t{1} y2t{1} y3t{1 2} seasons{0 to -2} ysdiff{1 to 12}

 

With FORCE=9, this includes all the regressors other than the YSDIFF lags in all models. This lags are trimmed using GTOS, so lags are dropped from the end as long as the marginal significance level is greater than .05.

 

Note the difference between these two examples: in the second example, the lags will always be 1 to the chosen lag, while in the first, it can be any collection of lags.

Sample Output

This is from the first example. The top part shows the decisions (in order) of how the regressors are added.

 

 Stepping  In with P= 0.000000 Variable Y{2}

 Stepping  In with P= 0.000001 Variable Y{3}

 Stepping  In with P= 0.000051 Variable Y{12}

 Stepping  In with P= 0.012926 Variable Y{10}

 Stepping  In with P= 0.010245 Variable Y{5}

 Stepping  In with P= 0.016502 Variable Y{4}

 

Stepwise Regression

Dependent Variable Y

Monthly Data From 1949:02 To 2004:03

Usable Observations                       662

Degrees of Freedom                        656

Centered R^2                        0.1632098

R-Bar^2                             0.1568318

Uncentered R^2                      0.1632883

Mean of Dependent Variable       0.0021148036

Std Error of Dependent Variable  0.2184979645

Standard Error of Estimate       0.2006339863

Sum of Squared Residuals         26.406621676

Log Likelihood                       127.0291

Durbin-Watson Statistic                2.0080

 

    Variable                        Coeff      Std Error      T-Stat      Signif

************************************************************************************

1.  Y{2}                          0.217545068  0.038300739      5.67992  0.00000002

2.  Y{3}                          0.158250999  0.037352602      4.23668  0.00002593

3.  Y{4}                          0.090152801  0.037504319      2.40380  0.01650214

4.  Y{5}                          0.098564922  0.038517297      2.55898  0.01072128

5.  Y{10}                        -0.112445036  0.037684701     -2.98384  0.00295236

6.  Y{12}                        -0.126950288  0.037311510     -3.40244  0.00070846

Notes

You can use DEFINE or FRML to save the form of the estimated regression as an EQUATION or FRML. If, however, your program needs to examine the choices made for the regressors, you can “fetch” the final regression by using the functions
 

%EQNSIZE(0)

number of regressors (could also use %NREG)

%EQNCOEFFS(0)

coefficient vector (could also use %BETA)

%EQNTABLE(0)

2 x regressors INTEGER array, where the first row elements are the series numbers of the chosen regressors and the second row are their lags

%EQNREGLABELS(0)

VECTOR[STRINGS] with the regressor labels

 

For instance, after the example above


disp %reglabels()


will show


Y{2} Y{3} Y{4} Y{5} Y{10} Y{12}


 


Copyright © 2025 Thomas A. Doan