RATS 10.1
RATS 10.1

Examples /

STARDIAGNOSTICS.RPF

Home Page

← Previous Next →

STARDIAGNOSTICS.RPF performs diagnostic tests from Eitrheim and Terasvirta(1996). These are diagnostics after estimation of a STAR model (either LSTAR or ESTAR). The STAR model that is tested is the LSTAR model on lynx population data that is analyzed in TARMODELS.RPF. This starts off with the estimation of the final model from that example.

 

This includes tests for residual serial correlation and for remaining (threshold) non-linearities. Both of these are done as LM tests using an auxiliary regression of the STAR residuals on the non-linear least squares derivatives and a set of additional variables. The final STAR estimates are done with NLLS including the DERIVES option to get the VECT[SERIES] of derivatives of the residuals with respect to the model parameters.

 

nlls(frml=star,parmset=regparms+starparms,derives=dd,iters=400)

 

We then save the residuals for use in the tests. (Since the tests are done with auxiliary regressions, the %RESIDS series will be overwritten by later instructions, so we need to make a copy of it).

 

set u = %resids

 

The test for residual serial correlation is simple: just regress the residuals on the derivatives and lagged residuals and test the lagged residuals. In this case, this allows for serial correlation up to 3rd order:

 

linreg u

# dd u{1 to 3}

exclude(title="Test for residual serial correlation")

# u{1 to 3}

 

The test for (threshold) non-linearity is more complicated, and is similar to the initial test for STAR behavior in the raw data. (Done with the @STARTEST procedure). In this case, the test is for threshold non-linearity in the first lag of the dependent variable. (The original model used the second lag). The LM test requires an auxiliary regression on interactions between the regressors from the base model and powers (1, 2 and 3) of the proposed threshold variable.Note that this produces some redundancies in the test variables since x{1} is one of the original, so 1 \(\times \) x{1}, x{1} \(\times \) x{1} and x{1} \(\times \) x{1}^2 will end up in the regression twice. The degrees of freedom of the test get adjusted automatically (in this case from 9 to 6).

 

The test can also be on the same lag as the original model (which would be testing for a double threshold), or possibly a threshold which isn't adequately described by LSTAR.

 

set testthresh = x{1}

 

This generates the full set of interactions between the regressors in the base autoregression and the powers of the testthresh variable.

 

compute basesize=%eqnsize(basemodel)

dec rect[series] testregs(3,basesize)

*

do i=1,basesize

   set testregs(1,i) = %eqnxvector(basemodel,t)(i)*testthresh

   set testregs(2,i) = %eqnxvector(basemodel,t)(i)*testthresh^2

   set testregs(3,i) = %eqnxvector(basemodel,t)(i)*testthresh^3

end do i

 

linreg u

# dd testregs

*

* Test the added variables

*

exclude(title="Test for remaining threshold non-linearity")

# testregs

 

Finally, this does a Nyblom(1989) fluctuations test for parameter constancy using the @FLUX procedure.

 

@flux(u=u,title="Nyblom Stability Test",labels=starlabels)

# dd

Full Program

cal 1821

open data lynx.dat

data(org=cols) 1821:1 1934:1 lynx

set x = log(lynx)/log(10)

*

* Fit a STAR model with a logistic transition. Note that this

* parameterizes  the model as two separate AR's with a weighting function

* governing  the linear combination of the two.

*

* Run the base autoregression

*

linreg(define=basemodel) x

# constant x{1 2}

*

* Define FRML's with the linear structure from basemodel, but with

* different coefficient vectors

*

frml(equation=basemodel,vector=phi1) phi1f

frml(equation=basemodel,vector=phi2) phi2f

compute phi1=phi2=%const(0.0)

nonlin(parmset=regparms) phi1 phi2

nonlin(parmset=starparms) gamma c

*

stats x

*

* The scale of the logistic is a scaling of the standard error on the

* transition variable, which gives it a scale-free interpretation.

*

compute scalef=1.0/sqrt(%variance)

nonlin(parmset=starparms) gamma c

*

* This uses lag 2 as the transition variable

*

frml glstar = %logistic(scalef*gamma*(x{2}-c),1.0)

frml star x = g=glstar,phi1f+g*phi2f

*

* Setting c to the mean and gamma to a reasonably high number should

* cause the estimates (which are linear in the "phi" parameters) to

* separate into high and low fairly quickly.

*

compute c=%mean,gamma=2.0

*

* Estimate first with the STAR parameters fixed, then with all

* parameters.

*

nlls(frml=star,parmset=regparms,iters=100)

*

* This estimates the model with all parameters (including the STAR

* parameters). The only difference between this and other examples of

* STAR is that it saves the derivatives for use in the LM tests and the

* regressor labels for later output.

*

nlls(frml=star,parmset=regparms+starparms,derives=dd,iters=400)

compute starlabels=%reglabels()

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

*

* Save the residuals from the STAR model

*

set u = %resids

*

* All the LM tests involve auxiliary regressions of residuals on the

* derivatives and some set of test variables. Some of the test variables

* are simple (a test for residual serial correlation just requires

* lagged residuals), some are more complicated.

*

* Test for serial correlation. Include lagged residuals

*

linreg u

# dd u{1 to 3}

*

* Test the added variables

*

exclude(title="Test for residual serial correlation")

# u{1 to 3}

*

* Test for remaining (threshold) non-linearity. Generate the auxiliary

* regressors for the powers of the test threshold variable (here lag 1

* of x) with the regressors from the base model.

*

* Here the test is on a threshold in x{1}. Note that this produces some

* redundancies in the test variables since x{1} is one of the original

* regressors so 1 x x{1}, x{1} x x{1} and x{1} x x{1}^2 will end up in

* the regression twice. The degrees of freedom of the test get adjusted

* automatically (in this case from 9 to 6).

*

* The test can also be on the same lag as the original model (which

* would be testing for a double threshold), or possibly a threshold

* which isn't adequately described by LSTAR.

*

set testthresh = x{1}

*

compute basesize=%eqnsize(basemodel)

dec rect[series] testregs(3,basesize)

*

do i=1,basesize

   set testregs(1,i) = %eqnxvector(basemodel,t)(i)*testthresh

   set testregs(2,i) = %eqnxvector(basemodel,t)(i)*testthresh^2

   set testregs(3,i) = %eqnxvector(basemodel,t)(i)*testthresh^3

end do i

*

* Run the auxiliary regression

*

linreg u

# dd testregs

*

* Test the added variables

*

exclude(title="Test for remaining threshold non-linearity")

# testregs

*

* This does a Nyblom test for stability

*

@flux(u=u,title="Nyblom Stability Test",labels=starlabels)

# dd

 

 

Output

Linear Regression - Estimation by Least Squares

Dependent Variable X

Annual Data From 1823:01 To 1934:01

Usable Observations                       112

Degrees of Freedom                        109

Centered R^2                        0.8340560

R-Bar^2                             0.8310112

Uncentered R^2                      0.9941247

Mean of Dependent Variable       2.9114411657

Std Error of Dependent Variable  0.5602974150

Standard Error of Estimate       0.2303284619

Sum of Squared Residuals         5.7825808417

Regression F(2,109)                  273.9241

Significance Level of F             0.0000000

Log Likelihood                         7.0432

Durbin-Watson Statistic                2.1744

 

    Variable                        Coeff      Std Error      T-Stat      Signif

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

1.  Constant                      1.057600456  0.121911121      8.67518  0.00000000

2.  X{1}                          1.384237712  0.063894797     21.66433  0.00000000

3.  X{2}                         -0.747775720  0.063948505    -11.69340  0.00000000

 

 

Statistics on Series X

Annual Data From 1821:01 To 1934:01

Observations                   114

Sample Mean               2.903664      Variance                   0.311820

Standard Error            0.558409      SE of Sample Mean          0.052300

t-Statistic (Mean=0)     55.519635      Signif Level (Mean=0)      0.000000

Skewness                 -0.366835      Signif Level (Sk=0)        0.114579

Kurtosis (excess)        -0.712265      Signif Level (Ku=0)        0.132317

Jarque-Bera               4.966567      Signif Level (JB=0)        0.083469

 

 

Nonlinear Least Squares - Estimation by Gauss-Newton

Convergence in     2 Iterations. Final criterion was  0.0000000 <=  0.0000100

 

Dependent Variable X

Annual Data From 1821:01 To 1934:01

Usable Observations                       112

Degrees of Freedom                        106

Skipped/Missing (from 114)                  2

Centered R^2                        0.8681148

R-Bar^2                             0.8618938

Uncentered R^2                      0.9953305

Mean of Dependent Variable       2.9114411657

Std Error of Dependent Variable  0.5602974150

Standard Error of Estimate       0.2082213200

Sum of Squared Residuals         4.5957485192

Regression F(5,106)                  139.5459

Significance Level of F             0.0000000

Log Likelihood                        19.9074

Durbin-Watson Statistic                2.1270

 

    Variable                        Coeff      Std Error      T-Stat      Signif

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

1.  PHI1(1)                       0.448812234  0.338714060      1.32505  0.18800460

2.  PHI1(2)                       1.148534689  0.122387158      9.38444  0.00000000

3.  PHI1(3)                      -0.255512121  0.200568503     -1.27394  0.20547103

4.  PHI2(1)                       1.544132583  0.669343508      2.30694  0.02300235

5.  PHI2(2)                       0.399231469  0.202314796      1.97332  0.05106245

6.  PHI2(3)                      -0.946729263  0.214784475     -4.40781  0.00002510

 

 

Nonlinear Least Squares - Estimation by Gauss-Newton

Convergence in    23 Iterations. Final criterion was  0.0000059 <=  0.0000100

 

Dependent Variable X

Annual Data From 1821:01 To 1934:01

Usable Observations                       112

Degrees of Freedom                        104

Skipped/Missing (from 114)                  2

Centered R^2                        0.8755218

R-Bar^2                             0.8671434

Uncentered R^2                      0.9955928

Mean of Dependent Variable       2.9114411657

Std Error of Dependent Variable  0.5602974150

Standard Error of Estimate       0.2042255754

Sum of Squared Residuals         4.3376409073

Regression F(7,104)                  104.4982

Significance Level of F             0.0000000

Log Likelihood                        23.1443

Durbin-Watson Statistic                2.1168

 

    Variable                        Coeff      Std Error      T-Stat      Signif

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

1.  PHI1(1)                       0.488082130  0.182910156      2.66843  0.00884196

2.  PHI1(2)                       1.246558507  0.070925204     17.57568  0.00000000

3.  PHI1(3)                      -0.366000141  0.098957109     -3.69857  0.00034836

4.  PHI2(1)                      -1.037621499  2.401769402     -0.43202  0.66661853

5.  PHI2(2)                       0.423787905  0.187934724      2.25497  0.02623001

6.  PHI2(3)                      -0.251742355  0.578531030     -0.43514  0.66436203

7.  GAMMA                         6.185215135  4.116324428      1.50261  0.13597103

8.  C                             3.339635482  0.102603258     32.54902  0.00000000

 

 

Linear Regression - Estimation by Least Squares

Dependent Variable U

Annual Data From 1826:01 To 1934:01

Usable Observations                       109

Degrees of Freedom                         98

Centered R^2                        0.0384355

R-Bar^2                            -0.0596833

Uncentered R^2                      0.0384356

Mean of Dependent Variable       0.0000617352

Std Error of Dependent Variable  0.2001952502

Standard Error of Estimate       0.2060828330

Sum of Squared Residuals         4.1620731382

Regression F(10,98)                    0.3917

Significance Level of F             0.9475406

Log Likelihood                        23.2964

Durbin-Watson Statistic                2.0105

 

    Variable                        Coeff      Std Error      T-Stat      Signif

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

1.  DD(1)                        -0.045564610  0.214506817     -0.21242  0.83222395

2.  DD(2)                        -0.064029880  0.091498946     -0.69979  0.48571742

3.  DD(3)                         0.082797781  0.108733567      0.76147  0.44820259

4.  DD(4)                         0.274380933  2.440883847      0.11241  0.91072788

5.  DD(5)                        -0.025379439  0.193430801     -0.13121  0.89588068

6.  DD(6)                        -0.059507635  0.590708034     -0.10074  0.91996306

7.  DD(7)                        -0.148164476  4.174819727     -0.03549  0.97176119

8.  DD(8)                        -0.009436656  0.103987967     -0.09075  0.92787839

9.  U{1}                         -0.119765693  0.134160874     -0.89270  0.37420357

10. U{2}                         -0.100996973  0.129525845     -0.77974  0.43742080

11. U{3}                          0.161157244  0.120108419      1.34176  0.18277302

 

 

Test for residual serial correlation

 

Null Hypothesis : The Following Coefficients Are Zero

U                Lag(s) 1 to 3

F(3,98)=      1.30561 with Significance Level 0.27698162

 

 

Linear Regression - Estimation by Least Squares

Dependent Variable U

Annual Data From 1823:01 To 1934:01

Usable Observations                       112

Degrees of Freedom                         98

Centered R^2                        0.0527247

R-Bar^2                            -0.0729343

Uncentered R^2                      0.0527247

Mean of Dependent Variable       0.0000000000

Std Error of Dependent Variable  0.1976811726

Standard Error of Estimate       0.2047631800

Sum of Squared Residuals         4.1089400676

Regression F(13,98)                    0.4196

Significance Level of F             0.9594722

Log Likelihood                        26.1776

Durbin-Watson Statistic                2.1637

 

    Variable                        Coeff      Std Error      T-Stat      Signif

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

1.  DD(1)                        -19.50216563  11.74053609     -1.66110  0.09989013

2.  DD(2)                         16.22427899  14.41215783      1.12574  0.26302679

3.  DD(3)                         16.81070683  10.34399964      1.62517  0.10733927

4.  DD(4)                         -9.99194143   5.24978870     -1.90330  0.05993551

5.  DD(5)                          0.93960096   0.54697132      1.71782  0.08898680

6.  DD(6)                          1.88851287   1.06230217      1.77775  0.07854596

7.  DD(7)                         -5.20873095   5.09975908     -1.02137  0.30959484

8.  DD(8)                          0.21137670   0.14253431      1.48299  0.14128640

9.  TESTREGS(1,1)                  0.00000000   0.00000000      0.00000  0.00000000

10. TESTREGS(2,1)                 -1.30383895   9.65250348     -0.13508  0.89282741

11. TESTREGS(3,1)                  3.62459490   3.62836332      0.99896  0.32027362

12. TESTREGS(1,2)                  0.00000000   0.00000000      0.00000  0.00000000

13. TESTREGS(2,2)                  0.00000000   0.00000000      0.00000  0.00000000

14. TESTREGS(3,2)                 -0.69359729   0.48824263     -1.42060  0.15860708

15. TESTREGS(1,3)                 21.86042099  12.62341631      1.73174  0.08646724

16. TESTREGS(2,3)                 -9.20295398   5.03814766     -1.82665  0.07079591

17. TESTREGS(3,3)                  1.25082700   0.65660205      1.90500  0.05971194

 

 

Test for remaining threshold non-linearity

 

Null Hypothesis : The Following Coefficients Are Zero

TESTREGS(1,1)

TESTREGS(2,1)

TESTREGS(3,1)

TESTREGS(1,2)

TESTREGS(2,2)

TESTREGS(3,2)

TESTREGS(1,3)

TESTREGS(2,3)

TESTREGS(3,3)

## X13. Redundant Restrictions. Using 6 Degrees, not 9

F(6,98)=      0.90910 with Significance Level 0.49174732

 

 

   Test    Statistic  P-Value MaxBreak

Joint      1.07264493    0.70  1882:01

 

1. PHI1(1) 0.15515662    0.36  1897:01

2. PHI1(2) 0.16157918    0.34  1897:01

3. PHI1(3) 0.16794235    0.33  1897:01

4. PHI2(1) 0.06062091    0.80  1897:01

5. PHI2(2) 0.06847624    0.75  1897:01

6. PHI2(3) 0.06121185    0.80  1897:01

7. GAMMA   0.12051927    0.48  1884:01

8. C       0.16067199    0.35  1897:01

 

 

 

 

 

 

 


Copyright © 2025 Thomas A. Doan