Ivar Pettersen


Bilder av Marie

Contents:

- An oxpack for estimating STR-models

- The ox-source file for the oxpack

- A brief tutorial on how to use the oxpack

- A class of ox-procedures which do simple bootstrappings of means and residuals

- Using TextPad with Stata: A Collection of tips


News / changes:

- 27.08.01: Downloadable Oxpack compiled for Ox 3.00. File named STR2.oxo.

- 27.08.01: The experimental long-run estimates procedure has been hidden.

An OxPack for solving smooth transition regressions.

Based on Professor Timo Tërasvirta's GAUSS code I have written a class of procedures which estimate and test STAR-models. The compiled binary, the oxpack itself, may be downloaded here. This version has been compiled with Ox 3.00. The 2.20-version will be added soon. If you are using Ox 2.20 you may compile the source file, downloadable below. To compile the file, start the Command prompt, cd to the relevant directory and type oxl -c STR2.ox. To use the oxpack your version of GiveWin must support oxpacks.

How to install the oxpack: The downloaded file, STR2.oxo, is the compiled module you wish to install. Start GiveWin, enter the Modules-menu, select Oxpack. The oxpack box includes a menu called Packages. In this menu an item is called Add/Remove Package, choose this. The following dialog box should appear:

The upper field should contain the (absolute) address of the downloaded oxo-file. Use the Browse button. The lower field should hold the name of the class (it does not do this automatically, you need to change this value), in this case STR2. Remember that the field is case-sensitive. Press Add and the oxpack should be available. Please notice that this program is very much in its Beta-stages so I can not be held responsible for any estimation errors. Some of the text in the program is in Norwegian, sorry about that, I will translate it later.

The ox-file can be downloaded here. This file is not completely identical to the oxpack's source file, but if compiled it would give the same functionality. The difference is that I have added some features to the class which are not, at least yet, available in the oxpack. Lately I have been working on a procedure which calculates long-run estimates and standard errors. This procedure assumes that the model is an error correction model of the type:

Some comments about the ox-file:

The file contains a main() procedure which shows how one can use the class directly to estimate STAR-models. The UK-House data-file has kindly been made available by Professor David Hendry. Download links below. Tërasvirta uses it in his very educational paper on STR-estimation ("Handbook of applied economic statistics", volume 155, edited by Ullah and Giles, 1998 by Marcel Dekker, Inc).

ukhouse4.in7

ukhouse4.bn7

Most of the routines (all tests) in the program have been translated directly from Timo Tërasvirta's Gauss files.

The InitX procedures calculate starting values. I originally had one Init procedure that handled all types of STR-models. I chose to divide this to avoid confusion and to gain some speed.

The STR-estimation uses not only the estimated starting values for gamma and c but also the parameter estimates. The program ought to have an option to set the parameter starting values to zero. And the possibility of user-provided starting values should be implemented.

Timo Tërasvirta's procedures are at the end of the program. They are direct translations from the gauss files. But I have changed them to work with zero indexing.

The Gradient procedure is fishy. The formulas are Timo Tërasvirtas concerning LSTR1 with one or two transition variables but the ESTR- and LSTR2- calculations are incorrect. I have not given enough attention to this given that I never use ESTR. Comments appriciated. The errors will not affect estimation results, but will make several tests inapplicable.

The program is tested against results from Tërasvirtas estimation of Hendrys housing model. Several model formulations are not tested against a correctly estimated model (ESTR, LSTR2 and models where a variable is modelled with two transition-variables). The estimates these routines provide may be wrong. I do not feel competent to evaluate them, so by assumption I believe them to be wrong given that I can not test them against "true" values.

How to use the oxpack. An example:

In the variable selection dialog (choose Model -> Formulate) there are 8 options.

Transvar is the button for the transition variable (the first transition variable if using two)
Y_variable endogenous variable
Lin_variable selects variables that should enter the linear part of the model only
Nlin_variable selects variables entering both linearly and non-linearly
ZeroRestrictions stands for, well, zero-restrictions and makes sure a Nlin_variable enters non-linearly only
Transvar2: This button has several functions depending on what kind of model the user estimates. It was, and still is, the button that selects a second transition variable.
Nlin_variable2 selects variables that should follow this second transition variable.

If the user chooses a model with one transition variable (LSTR1) the Transvar2 and Nlin_variable2 have other purposes. If using LSTR1 all variables marked with Transvar2 will be tested as potential transition variables (given that linearity tests are selected in the options box, this applies to both pre-estimation tests for non-linearity and post-estimation tests for remaining non-linearity). The Nlin_variable2 box is used to select variables to be tested for constancy. It can be used to pick variables entering the linear part only. Variables entering the non-linear part are selected in the options menu (I ran out of buttons so some ad hoc solutions are used).

The program can only handle one or two transition variables. The non-linear variables may be modelled with either one of the transition variables, or both at the same time.

Figure 1: The variable selection dialog box.

The box above show all options described above. Notice that all variables which play a role in the estimation are labeled with a letter. The example is typical for an estimation of a model with one transition variable, delph_1. The Constant and mphh1 are modelled both linearly and non-linearly, and are labeled N. The variables labeled L are modelled linearly only.

Figure 2: Modell settings (at least most of them)

The model setting box selects which tests to perform, sets parameters for starting values grid search and chooses among output options.

Print starting values is a setting which allows the user to see the results of the grid search estimation (always a good idea).

Linear tests (pre-estimation) chooses linearity tests. These tests are used to determine whether there is any non-linearity within the model and to choose between the STR-specifications.

Print tr-function prints the values of the estimated transition function to the output file.

Two of the boxes are used to indicate whether trend is used as transition variable. Trend needs special attention concerning standardisation. The program could try to detect a trend, but I chose not to implement this given that the user might want to standardise it before the estimation.

The next settings custumizes parameters for the grid search, focusing on the slope parameter gamma and the break point c only. The user supplies a starting value, a step lenght and the number of gammas to be tried. In the example above 100 gammas would be tried, starting at 0 ending at 99. There are two sets of settings for gamma. The second set applies when an additional transition variable is used.

The setting for c determines how many break points should be tried. Once the number of c's have been set the grid search will search between the min and max value of the transition variable. The Step C option overrides No of C in a way, letting the user supply the steplength. If this option is unequal to zero the search will start at the minimum value of the transition variable, use the given increment, where the number of tries still is determined by No of C. By using this options the user risks a search out of the upper boundries of the transition variable.

There is an option to use Num2Derivative to calculate standard errors. I always use this. I my experience standard errors are always under-estimated when using iteration techniques. Timo Tërasvirta scales the standard errors with a constant to compensate for this. Consult the Ox-manual for details about this procedure.

Residual Statistics reports a battery of tests for autocorrelastion. The procedure which calculates these tests is a direct translation of Tërasvirta's corresponding Gauss-file

Draw tr-function and Draw residuals do the obvious. The residuals are drawn together with a set of residuals from a linear regression (in practice a regression where the variables are modelled linearly only).

Reset-test is self-explanatory

Test for remaining non-linearity. This allows the user to check whether the non-linearity within the model is adequately handeled. The tests are available when estimating models with one transition variable only. Testing for remaining non-linearity has an additional purpose. It is possible to check whether the linear variables in your model could contain remaining non-linearity due to an additional transition variable. Labeling variables with the transvar 2-button makes it possible for the user to test several variables. In general, when using models with one transition variable, the transvar 2-button selects variables which should be tested as potential transition variables, both for pre- and post-estimation purposes.

Print residuals prints the values of the STR-residuals to the output file

Testing for parameter constancy is available when using one transition variable only. To select variables in this test the user must use two different methods. To select variables in the linear part, use Nlin_variable 2, to select variables in the non-linear part use the appropriate box in the model settings dialog. Select variables by number. The numbering is based by the order in which the variables appear in the variable selection dialog. Ex: if I wanted to test the constancy of mphh1 I would write 2 in the box (see figure 1 above). Notice that the numbers are separated by ;. Both variables would be tested if I wrote 1;2 in the box.

Press OK after making your selections in the model settings dialog takes you to the Estimate Model-box, as seen below:

Figure 3: Estimate Model

This is where one can choose the preferred method and select the sample. LSTR1_2 is the option for two transition variables. Make your selections and the estimations start. The options button lets the user choose convergence criteria for the iteration procedure, see below.

Estimation output can be downloaded or viewed here. The model I have just estimated is Hendry's UK housing prices model (I do not have it at hand for the moment so I am not absolutely sure it's picture perfect). First the procedure tests for non-linearity. The next output is the result of the grid search. Based on 5000 estimations (50 c's and 100 gammas) we find some maximum. These results are fed into the iterative procedure as starting values. Hopefully the model converges, in my example it does, giving estimation results close to what Tërasvirta estimated. The program then tries to test for remaining non-linearity, but fails. This is caused by the two dummies d674 and dvbanks. The program tries to aviod dummy-variables when testing linearity, but failed to do so in this case because both dummies are formulated in a non-conventional way. The estimated transition function looks like this:

A variable selection box for estimating a model with two transition variables looks like this:

The difference from above is that Q2 and Q3 are modelled non-linearly with trend as the second transition variable.

 


Bootstrapping and Monte Carlo-simulations.

In order for myself to understand what bootstrapping is I have written a class of procedures in Ox which illustrate some simple aspects about bootstrapping. The class contains procedures for bootstrapping means, residual bootstrapping and very simple Monte Carlo-simulations. The ox-file can be downloaded here.


Min andre hjemmeside.

 

   NTNU
 Fakultet
   Institutt
 Personlig vevside

Owner: Ivar Pettersen
ivar.pettersen@svt.ntnu.no
Last update: 09.01.01

ntnu