tsplogoH O M E / I N F O / P R O D U C T S / O R D E R / S U P P O R T     

 

Benchmarks / Linear / Matrices / Miscellaneous / ML+QDV / Nonlinear / Panel Data /
Pindyck & Rubinfeld / Robust / Statistical tests / Time Series / Univariate / Advanced

 

 

TSP Examples by type

 

Benchmarks

AIDS.TSP

Almost Ideal Demand System, with elasticities, Deaton and Muellbauer model, based on SAS example. (LSQ,EQSUB,ANALYZ)

AR2MLP.TSP

Regression with AR(2) residual, exact ML estimation. Uses both ML and ML PROC, with the BJEST option that allows general ARMA residuals. Klein-I consumption function data.

CONDNUM.TSP

Condition number of X'X or any @VCOV matrix (version which is independent of the scale of X). Example using Klein-Goldberger consumption data. The condition number is a measure of multicollinearity.

DH.TSP

reproduces Durbin's h statistic

DIVZERO.TSP

Reproduces DIVIND calculation with zero quantities. Tests Paasche, Fisher, Laspeyres.

DW200.TSP

Verify DW 5% critical values for n=200, k'=2,3,4, using CDF(WTDCHI).

ILLUS41.TSP

Illustrative model from the TSP manual.

JB.TSP

Reproduces Jarque-Bera normality test, starting from small-sample versions of @SKEW and @KURT stored by MSD.

JOH1.TSP

Reproduces Johansen-Juselius cointegration results for Finnish data. More complete than COJOH, and uses VAR. Originally by David Cushman.

KLEINF.TSP

Reproduces pseudo-F test for zero slopes in 2SLS, example using Klein Model I.

KLEINLMC.TSP

Klein-I LIML benchmarks on consumption equation. Reproduces Greene's 3rd edition coefficients & standard errors. Explores alternative standard errors to those produced by the LIML command.

LONGLEY.TSP

Longley benchmark with double precision data; compares precision of default orthonormalized regression (11+ digits) with plain (X'X)"(X'Y) regression (7-9 digits)

LONGLEY2.TSP

Longley benchmark - test regression accuracy on a particular computer by entering the same variable twice in OLSQ and adjusting TOL to range over values that cause failure to detect singularity

NASTY2.TSP

Wilkinson's Statistics Quiz - high precision data

OVID.TSP

Overidentification tests in 2SLS - examples using Klein I

PANHAUS.TSP

Reproduces Hausman test of RE vs. FE in panel data

PPENDERS.TSP

ppzt test on data from 4 countries. Mostly reproduces table on p.263 of Enders, "Applied Economic Time Series", 1995

PRIN.TSP

reproduces results from PRIN (principal components), with MATRIX commands

SKEW.TSP

Reproduce Skewness and Kurtosis equations from MSD in manual, as a check.

SPATCAL.TSP

Example of running spatial.tsp on California plant species data. Reproduces results for Spatial AutoCorrelation and Spatial AutoRegression from Upton and Fingleton (1985).

STACKLP.TSP

Uses LAD and LP to estimate an LAD model on the stackloss dataset

WTDRSQ.TSP

Reproduces @RSQ from a weighted OLS regression, using OLSQ on manually weighted data and MSD.

Linear estimation

ANOVA.TSP

Proc which prints a (formatted) "ANOVA table" after OLS

KLEINLSQ.TSP

Test 3SLS on the Klein-I model (for FIML see Econometric Benchmarks). Shows how to reproduce the 3SLS @PHI criterion function using matrix commands.

LADCEN.TSP

LAD for censored and quantile regression

LPNR.TSP

Linear Programming tests from Numerical Recipes

RIDGE.TSP

Bayesian mixed estimator (combines prior with estimated coefficients and VCOV), works for non-OLS models.

TEST8.TSP

Original testrun from the 1975 TSP 2.7 manual; data originally from Johnston, Econometric Methods, p.127.

WEIGHT.TSP

OLSQ, MSD, and INST with weights; also shows formated read of input data

WHITESE.TSP

OLSQ with Eicker-White standard errors; shows how to compute by hand.

WHITFAST.TSP

OPTIONS FAST for faster regression computation; check with ROBUST

WHITINST.TSP

Tests of INST and LSQ with robust standard errors.

WHITNLSE.TSP

LSQ(ROBUST) on linear equations

WLS_TX04.TSP

Standard errors for predicted values from WLS

Matrix operations

AR1FML.TSP

AR(1) exact ML with the FIML and ML commands.

EIG.TSP

Tests of the eigenvector function in the MATRIX procedure.

MATEST.TSP

Test the new Matrix command introduced in V 4.2 for matrix algebra, including various matrix functions.

MFORM.TSP

MFORM for creating and rearranging matrices

SUBMAT.TSP

PROC to extract a submatrix, given starting/ending row/column

TAB2.TSP

Forms and print 2 x 2 contingency table (crosstab), with ChiSq(1) test for independence. Inputs are 2 dummy variables.

TAB2T.TSP

Examples of calling TAB2.

Miscellaneous and data transformation

ALL.TSP

Test of all TSP commands on dummy data, roughly in alphabetical order

CIRCLEPLOT.TSP

Plots with circles indicating "importance" or "size" of the observation.

CNVMAP.TSP

Tests of the CONVERT procedure for time series with the (MAP=) option

COMMENT.TSP

Testing of reading data (error messages) and ignoring trailing comments in the series.

DBCOPY.TSP

Testing various TSP databank commands including DBCOPY for moving databanks to a different computer

DBTEST.TSP

Simple test of making a databank using OUT.

DBTESTIN.TSP

Simple test of reading a databank using IN.

DBTESTRD.TSP

Tests of reading and writing databanks; deleting series from a databank.

DELOBS.TSP

Deletes some observations permanently from a dataset by placing them at the end of the sample and truncating.

DIVZ.TSP

Testing various DIVISIA options (zero, splice, etc) when data includes negatives, zeroes, or missing values.

DOC.TSP

Tests the DOC command, adding documentation to series.

DOT43.TSP

Test of nested DOT loops.

DOTFILE.TSP

Using DOT loops to construct filename(s). Quadruple DOTs to concatenate strings.

DYNG.TSP

Testing dynamic (recursive)  and reverse dynamic GENR

EXCEL.TSP

Various tests of reading spreadsheets (wk3, wks, various Excel formats)

FFW.TSP

Test of free format WRITE with many significant digits.

FILES.TSP

Creating multiple files, automatic closing of files

FISHER.TSP

Paasche, Laspeyres and Fisher price/quantity indices directly. Compare with DIVIND command.

FREQ.TSP

Testing the options for setting the frequency of the data

GNUPLOT.TSP

gnuplot graphics - .GIF file output only, unix versions. (PLOT,GRAPH)

GNUPLOTI.TSP

gnuplot graphics - X window output, unix versions. (PLOT,GRAPH)

GSA.TSP

Tests various froms of the GENR command for variable transformation.

HELP.TSP

Example of using HELP in a batch program.

HIST.TSP

Testing HIST with integer data (DISCRETE option) and CDF, DENSITY, NORMAL, STANDARD options for Oxmetrics graphics

INTERP.TSP

Linear interpolation of missing values, for very simple case of single isolated missing values. Discusses why this may not be a good idea. See interp2 for general case.

INTERP2.TSP

Linear interpolation of missing values, general case.

LAG43.TSP

Testing subscripts for series and double subscripts for matrices

LAGTEST.TSP

New subscript features - integer and static date subscripts for series

LIST.TSP

Test various features of LISTs including implicit dashed lists, leading zeroes, suffixes, etc.

LISTSAVE.TSP

writes a LIST into an external file, formatted as a TSP command. Messy, but the only way to save a list in an external file at present. Could be useful if you are saving an @VCOV matrix in a databank, and you also want to save the @RNMS parameter names for later use by ANALYZ in a separate run.

LISTSORT.TSP

Creates a LIST (R8 R5 R6 ...) from a vector of integers (8 5 6 ...).

LISTSUB.TSP

Demonstrates the use of subscripted lists, useful in PROCs

LNGNAM.TSP

Test of long names ( > 8 characters)

LNGW1.TSP

Test of long names in writing spreadsheet

LNGW2.TSP

Test of long names in reading spreadsheet

MERGE.TSP

Proc which merges two samples by ID variables

MSD43.TSP

MSD with missing data, showing the pairwise option

PERCENT.TSP

Obtain arbitrary quantiles (such as 5%, 95%), using sort.

PI.TSP

Various infinite series for computing pi to arbitrary precision.

PLOTTEST.TSP

Tests of plots and graphs

PROC44.TSP

PROC argument changes in TSP 4.4 - lists, lags, etc

QUINTILE.TSP

Sample Quintiles (20%, 40%, ...) via SORT. Similar to percent example.

RELOP.TSP

Testing the results of relational operators at high precision (btwn 10-16 to 10-17)

SETEST.TSP

SET with all types of subscripts

SHOW.TSP

Illustrates the use of the SHOW command to list contents of TSP memory (series, equations, procs, etc)

SORT.TSP

Test various features of SORT command

SORTL.TSP

Sorts a list of variable names, by the variables' values in a given period. Coding similar to listsave.

STATA.TSP

READ Stata .DTA files versions 2 through 10.

SUBSETL.TSP

Create all subsets of a list; can be used to run subsets of RHS vars in many different commands

SUBSETS.TSP

OLS on all subsets of the RHS variables. Computes X'X once, and then uses submatrices to compute regression coefficients and SSR. Returns the set of coefficients which minimizes SBIC.

SUITS.TSP

Suits transformation of dummy variables (average effect for first dummy, difference from average for others). By Bronwyn Hall.

TERSE.TSP

Test  TERSE and SILENT options in many commands

TEST8MV.TSP

TEST8 with missing value handling.

TVH.TSP

Read Excel files with multiple sheets and titles

YEARDUM.TSP

Estimating the average of a set of year dummies (compare the SUITS proc)

Maximum likelihood estimation and qualitative dependent variable models

BILINEAR.TSP

ML estimation of simple bilinear time series model. Uses recursive derivative code; could be made simpler with ML PROC. Granger and Andersen 1978

BIPROB.TSP

Bivariate probit, in ML using CNORM2(z1,z2,rho). Written as a Proc; should be easy to use on real data -- just supply the variable names. (ML)

BIQUAD.TSP

Bivariate normal cdf - how to evaluate probabilities in all 4 quadrants, by changing signs of the arguments to CNORM2(z1,z2,rho).

BIVORD.TSP

Bivariate Ordered Probit (without data). Could be improved in TSP 4.5 and higher by using CNORM(z1,z2,rho) function.

BOXCOX.TSP

Box-Cox with ML command (can also be done with FIML)

BOXCOXJ.TSP

Jacobian term for testing log vs. level and general Box-Cox model.

BOXTID0.TSP

Box-Tidwell regression when the RHS variables are sometimes zero.

CLOGIT.TSP

Example of conditional logit two ways, with data organized by case or choice

CLOGIT2.TSP

Example of conditional logit with data organized by choice, differing number of choices per case.

CLSF.TSP

Example of conditional logit two ways, with data organized by case or choice, demonstrating use of suffix list for choices and missing value behavior

CN4.TSP

4-dimensional cumulative normal integral, approximated with many random draws, CNORM(), CNORMI(), and Cholesky factorization.

COUNT.TSP

14 alternative Count (Poisson and Negative Binomial) models, including Hurdle and Zero-Inflated models. Automated via ML command. Written by Vincenzo Atella, with help from Clint Cummins. (ML)

DISEQ104.TSP

Disequilibrium model, with sample separation known. Section 10.4 of Maddala(1983), p.307-309. (LSQ)

DPDX.TSP

Standard errors for @DPDX from Logit. ANALYZ can also do this.

DPDX3.TSP

Mean and variance of dP/dX for Logit with 3 choices.

EBIPROB.TSP

Bivariate probit where Y2 is not observed unless Y1=1. (ML)

FIML11.TSP

11-equation FIML estimation, via the ML command. An extension of the old fiml4 example.

FIML4.TSP

4-equation FIML with ML command (HCOV=N, LDL' example). Example of how to parametrize the multivariate normal density, using LDL' factorization of Sigma-inverse.

FRONTE.TSP

Efficiency term for Frontier model from Battesse and Coelli (1988). Extends example in TSP User's Guide, section 9.7.3.

GAMMAR.TSP

gamma estimation of rainfall model. Uses ML PROC and CDF to evaluate igamma() function.

GAMMAS.TSP

gamma simulation of rainfall model, where trace values below 0.1 are truncated to zero.

GRID.TSP

checks a 3-parameter nonlinear model for multiple local optima. 2 different ways of choosing starting values: 1. full grid 2. random draw within bounds (like simulated anealling) reports back optimum found

HAMSIMP.TSP

Markov chain model - simple 2-regime from Hamilton's book, via EM. By David Bivin

HAZARD.TSP

log-linear hazard function with one time-varying covariate

HETPROB.TSP

LM test for heteroskedasticity in Probit. Follows Godfrey's book.

HURDLE2.TSP

Double Hurdle model. Tobit is single hurdle; this is like Tobit with an additional selection equation.

HURDLE2BC.TSP

Double hurdle model with Box-Cox transformation

INTRV.TSP

Test of Interval regression (includes equivalent Probit, Tobit, Ordered Probit)

LOGITBC.TSP

Logit with approximate finite sample bias correction.

LOGITCSU.TSP

Logit - conditional, with shares as dependent variable, unbalanced data. Data has been "balanced" by including all obs, with brand dummies=0 if choice not available. Includes code which takes limits of ratios, to avoid EXP(xb) overflow, when xb is larger than 88.

LOGITF.TSP

Forecasts from a multinomial logit model (picks most likely Y value for a set of X values). not tested.

LOGITFE3.TSP

Fixed effects logit for panel data with 3 time periods (choice taken 1 or 2 times). Follows Hsiao(1986), p.162. (ML)

LOGITMIX.TSP

Mixed logit via ML command

LOGITSH.TSP

Logit with shares as dependent variables.

LOGITSHP.TSP

Mixed Logit on (24) shares (fractional dependent variables aggregated over many choosers), panel data. Calculates predicted shares. Handles missing X values for zero shares.

MARKOVRT.TSP

Simple switching regression models - one with regime known, one with regime unknown. Not really Markov Chain models, because the switching does not involve the probability of the states in the previous period (for regime unknown). Data is generated from a Markov Chain, though.

ML2STAGE.TSP

Calculates corrected VCOV for second stage ML estimator (where estimation in the two stages involves different parameter sets). Automated differentiation. Useful in 2-stage estimation, where the second stage uses data computed from first stage ML parameter estimates. No example model or data.

MLOGIT.TSP

Standard multinomial logit, done by LOGIT and by maximum likelihood.

MLPM.TSP

Simplest ML Proc example - estimating the mean of normal data

MNESTLOG2.TSP

2-level nested multinomial logit.

MSPROBIT.TSP

Real Markov switching Probit model, by Masahito Kobayashi.

MXLOGIT.TSP

LOGIT - mixed - multinomal and conditional variables

NEGBIN.TSP

Simple Poisson and negative binomial examples using ML, with the procedures POISSON and NEGBIN for comparison.

NEST31.TSP

3 level nested logit that can be changed for different model, by Paul Ruud

NESTL.TSP

Nnested logit example from TSP User's Guide. Shows relation to mixed logit model.

NESTLOG2.TSP

2-level nested conditional logit.

NLOGIT.TSP

2-level nested logit (ML)

OLSME.TSP

OLS with measurement errors on the dependent variable, and known variances for these measurement errors (obtained from a first stage estimation). That is, the composite variance is made from these known variances that differ across observations, plus a residual variance that is equal across observations.

OP1R1.TSP

Ordered Probit (3 choices) and Regression / sample selection

OP3.TSP

Ordered Probit with forecasting - examines changes in Y for changes in a dummy variable. Example with 3 choices.

OPDYDX.TSP

dy/dx for Ordered Probit. Computes change in histogram of predicted dependent variable, for changes in a given X variable. More complex version of OP3, but without data.

OPFP.TSP

Ordered Probit forecasted probabilities. (ORDPROB)

OPHE.TSP

Ordered Probit Random Effects by Hermite Quadrature

P1OP1.TSP

2 eqns: Probit and Ordered Probit, correlated, by Bronwyn Hall

P1R2N.TSP

3 eqns: Probit and 2 Regression - non-selection, with simultaneity in Probit eqn

P1R2S.TSP

3 eqns: Probit and 2 Regression - selection model

PROBDER.TSP

Probability derivatives in Probit. Gives an alternative method of assessing changes in Y, for changes to a 0/1 RHS variable. (Derivatives are not appropriate for large changes in a discrete variable).

PROBIT.TSP

Test of Probit showing ML equivalent; also tests all options and prints maximum results

PROBTM.TSP

PROBIT, TOBIT, SAMPSEL with missing data (just a test)

RANCOEF.TSP

ML estimation of a regression with a single random coefficient. Outlines how to extend to multiple random coefficients.

REGIME.TSP

Real Markov switching regression model, by Masahito Kobayashi.

RPL.TSP

Random Parameters (coefficients) Logit. Example with a fixed intercept and one additional RHS variable with a normally distributed random coefficient.

SAMPSEL.TSP

Test of sample selection estimation on simple randomly generated data; compare to ML

SPATIAL.TSP

Proc which estimates Spatial Autocorrelation and Spatial Autoregressive models. User supplies W = spatial proximity weight matrix.

STACKLOS.TSP

LAD and Student's t residuals on classic Stack Loss dataset

STUDENT.TSP

Regression with Student t residuals; see also stacklos example.

SWITCH.TSP

Disequilibrium / switching regression model from 4.3 User's Guide, by Bronwyn Hall. Maddala;s text p.298

SWPROB.TSP

Switching Probits model, regime unknown. Estimated by ML with new CNORM2(z1,z2,rho) function. Follows Kimhi(1999). Like Maddala(1983), p.223, except the equations which switch are probits instead of regressions.

SWREG.TSP

Switching regression, regime unknown. Follows Maddala(1983), p.283. by BHH

SWREGUN.TSP

Switching with unknown regime and unknown sample separation, by Augustin de Coulon.

TESTNLOG.TSP

2 level (5 x 10) nested logit, with artificial test data, by Bronwyn Hall

TNP.TSP

Trinomial probit, in ML using the new CNORM2(z1,z1,rho) function in TSP 4.5. Uses one possible normalization for the residual correlation matrix, but it is not clear which normalization is best for an unrestricted model. See also the bunch example, which shows that the probability derivatives are invariant to different parameterizations the residual covariance matrix.

TOB2.TSP

2-equation (bivariate) simultaneous Tobit

TOB2SUR.TSP

2-equation Tobit, but with no RHS endogenous variables

TOBENDOG.TSP

ML estimation of a 2-equation model, where one equation is a tobit (truncated at zero), and the second equation has this variable on the RHS.

TOBIT.TSP

Test of TOBIT procedure including equivalent ML estimation

TOBITHET.TSP

Tobit and Probit, when heteroskedasticity is a function of variables.

TOBPDL.TSP

Test of TOBIT with PDL variable

TOBPRED.TSP

Predictions from Tobit model, conditional and unconditional.

TOBR2.TSP

R-squared for Tobit model, one possible formulation.

TOBRNCF.TSP

Tobit with random coefficients, Ionnatos, JBES July 1995

UNBALSUR.TSP

Does unbalanced SUR estimation (2 equations) in about 4 different ways. Fairly complicated. Users who don't want to compare minimum distance, pairwise deletion, etc. should just use unbalsu1.

WCLOGIT.TSP

Weighted conditional logit.

Nonlinear estimation and equation manipulation

ABDEF.TSP

Arellano-Bond estimation using GMM - simple example

ANALYZR.TSP

Example of using the restricted coefs stored by ANALYZ

ANASER.TSP

Testing ANALYZ for functions of series variables and bootstrap standard errors.

DIFFER.TSP

Test of DIFFER for all possible operations and functions, printing derivatives

DIFTEST2.TSP

Test of DIFFER by doing NLS using manual Gauss-Newton and derivatives from DIFFER

FORM40.TSP

Testing the equation forming procedure FORM.

FORMAR1.TSP

FRML with exact ML first observation for LSQ; includes Jacobian trick so that FIML is not needed.

GMM.TSP

Test GMM on single equation linear model

GMM2.TSP

Test GMM on 2 equations, compare to 3SLS.

GMM3.TSP

Test of GMM with OPTCOV option (to specify that COVOC supplied is the optimal one)

GMMERR.TSP

Test GMM syntax error handling

GMMPANEL.TSP

Documentation for the US---- panel examples.

KLEINMVR.TSP

Test LSQ, SUR on the Klein I model (for FIML see Econometric benchmarks)

MD.TSP

Minimum Distance estimation suing SUR on one observation with VCOV option.

PARAM.TSP

Tests of param and const with output pasted from LSQ for starting values

PEQTEST.TSP

Equation printing and analytic differentiation

SURAR1.TSP

Nonlinear SUR with AR(1) residuals, different RHO for each equation, plus conditional or exact ML

Panel (time series-cross section) data

AH.TSP

Anderson-Hsiao 2SLS for dynamic panel model (avoids finite sample bias in fixed effects estimator).

APD.TSP

Creates artificial panel data. Example of balanced, one-way random effects, 2 Xs correlated with random effects

AR1FMLP.TSP

AR(1) (exact ML) for panel data, using the FIML command. Reproduces AR1(TSCS) results.

AR1HET.TSP

AR(1) model with heteroskedasticity (rho(i), sigma2(i)). This follows Kmenta's "Elements of Econometrics" (1986) p.618-620. Includes a helpful degrees of freedom adjustment. This model has been criticized because rho(i) may proxy for individual effects alpha(i) that are not included.

AR1HETUB.TSP

A version of AR1HET for unbalanced data (Kmenta's GLS model using transformed data)

ARELBON2.TSP

Arellano-Bond example of setting up mask matrix and equations for GMM estimation on a linear model with 3 RHS variables.

ARELBOND.TSP

Simple Arellano-Bond example, 1-step and 2-step estimators (balanced panel data). Reproduces Table 5 of A-B. HAC standard errors hand-computed.

ARTSCS.TSP

Examples of working with a small panel dataset: AR(1) estimation, dealing with gaps, obtaining within firm sums, etc.

BAL2WFE.TSP

Balanced 2-way fixed effects in panel data

BALU.TSP

Panel - example of how to "balance" unbalanced data by adding artificial observations with zeros for all variables.

COV1STEP.TSP

Arellano-Bond 1-step COVOC matrix - GMM/panel

COV2STEP.TSP

Arellano-Bond 2-step COVOC matrix - GMM/panel

COXPANEL.TSP

ML estimation of Cox proportional hazards model, balanced data example with 3 time periods. Uses lagged EQSUB feature.

DATA2WAY.TSP

generates artificial data for 2-way model (RANDOM)

EC2SLS.TSP

2SLS with 2-way error components, balanced panel. Uses transformed data with 2SLS commands. See Hsiao's panel data book.

EC3SLS.TSP

3SLS with 2-way error components, balanced panel. Uses transformed data with 3SLS commands. See Hsiao's panel data book.

FEI.TSP

Test of FEI (group fixed effect) option in several commands (OLS, 2SLS, 3SLS, FIML)

FEIHAT.TSP

Compute hat matrix (leverage) for fixed effects model.

FIRSTDIF.TSP

Automates creation of first-differenced variables for GMM panel models, where the variables are named by time period, like y1 y2 y3, etc.

FRONTP1.TSP

Frontier production function, unbalanced panel, error components, v_it - u_i. Follows Battese and Coelli, 1992. See frontp2 for a simpler version.

FRONTP2.TSP

Frontier production function, unbalanced panel or cross section, v_it - u_it. Truncation point depends on z*d function. Follows Battese and Coelli, 1995. Simpler than frontp1.

GAPUBAL.TSP

Setting up a gapped SMPL for unbalanced stacked panel data, so that GMM(NMA=k) can be used.

GARCIA.TSP

Growth model, stochastic differential equations, unbalanced panel. Uses recursive EQSUB. This nonlinear panel growth model is used on tree heights.

GCOEFI.TSP

Panel OLS model where some coefficients vary by individual, and others do not. Includes a PROC to automate this.

GRUNFELD.TSP

Test random and fixed effect OLS and AR1 models on Grunfeld data (AR1, PANEL)

GSPD5.TSP

Create duplicate state variables for each industry.

H3B.TSP

Hsiao(1986)'s Appendix 3B - verifies 2-way EC Omega inverse (MATRIX)

HHGFISH.TSP

Models for panel count data (Hausman Hall & Griliches 1984)

HHGNB.TSP

Negative binomial models for panel count data from HHG (84)

HHSIM.TSP

Minimum distance estimation of Hall-Hayashi dynamic factor model. Uses simulated data. by Bronwyn Hall

INFOT.TSP

Information Matrix Test - example with Probit. Shows how to use DIFFER for first and second derivatives of an equation.

LM2TEST.TSP

Arellano-Bond m2 statistic, tests AR(1) and AR(2), by Bronwyn Hall.

LM2TEST2.TSP

Alternative version of lm2test, using explicit lags. Unfortunately, it seems to be about 20% slower than lm2test.

MASK2.TSP

2 different ways to set up a large sparse MASK matrix for use in GMM (different instruments in different equations).

N71A.TSP

PANEL(REI) - 2 local optima automatically detected

P3S.TSP

Three stage least squares with two-way error components (data files are not included).

PANBYT.TSP

PANEL with OPTIONS BYTE for economical storage of variables.

PANCHOW.TSP

Chow test for panel data, within model, where both the coefficients and fixed effects vary across 2 periods.

PANEL.TSP

Basic tests of the linear panel data estimator

PANMEANS.TSP

Removing individual or time means.

PANR.TSP

PANEL estimation with robust s.e.s

PANR2.TSP

Panel estimation in LSQ (IV) with robust s.e.s; uses panel freq to tell it how to group HCOMEGA

PANRW.TSP

Simulates Panel random walk with drift.

PANSD.TSP

Computes standard deviation of a panel series within each individual, and stores result as a series

PANSMPL.TSP

For Panel data with FREQ Q or M. Proc FIRMDATE creates @FIRM (1,2,...,N) and @DATE (197801,197802,...,199712) variables. These can be used to SELECT particular firms and ranges of dates for regressions. For balanced data which does not already have ID and Date variables.

PANUNIT.TSP

Panel unit root test of Im, Pesaran, and Shin. This version has the URL for downloading the paper, and describes how to look up the critical values in IPS Tables 2-4.

PANW.TSP

Weighted fixed effects estimation.

PHE.TSP

Bivariate Probit with Hermite quadrature. Compared with random effects Probit model, and regular CNORM2() version.

PREMASKC.TSP

Two examples of calling premaskg to create a GMM mask.

PREMASKG.TSP

Creates mask for GMM with panel data

PROBFE.TSP

Probit with fixed effects, showing some pathologies with only two groups

PROBITAC.TSP

Probit with SEs robust to autocorrelation.

PROBITRE.TSP

Probit with Random Effects - the Borjas-Sueyoshi 2-stage model. Monte Carlo analysis. Comments on the Pooled vs. Random Effects estimators. Related to PROBIT(REI) in TSP 5.0.

PROBRE.TSP

Tests Probit with random effects (using ML).

PSTR.TSP

Panel Smooth Transition Regression. 2 regimes. grid search and ML PROC estimation, originally written for TSP 5.0, updated to run in TSP 4.5 also

RDUSBAL.TSP

read USBAL dataset for the panel data examples USBALxxxx

TIMEDIFF.TSP

Time dummies in first differenced equations (when differencing to remove individual effects) - interpretation.

UB2WFERE.TSP

Unbalanced 2-way fixed and random effects follows Wansbeek and Kapteyn (J of E, 7/1989). Not tested against any real-world benchmark results.  GLS estimation, which depends on the method chosen to estimate the variance components. Compare with PANEL(REIT) in TSP 5.0 which uses ML estimation.

UNBALSU1.TSP

Unbalanced SUR -- 2 equations; some observations missing for the second equation. ML version only (easiest way to get estimates and proper standard errors).

UNBALSU4.TSP

(ML) SUR with 4 equations, in a nested pattern of missing data. In this example, there are 4 drugs that were invented at different times, and then observed up to the present (artificial data are used). The code can be used for 1-4 equations in this type of pattern.

USBALFE.TSP

Fixed Effects and other estimators via PANEL command

USBALGM4.TSP

Strong and weak exogeneity tests GMM (MASK=…)

USBALGMM.TSP

same as USBALPI but with GMM and first differencing

USBALME.TSP

Panel GMM with measurement errors

USBALPI.TSP

Basic Pi matrix with fixed effects and time-varying coef (Chamberlain, Handbook of Econometrics).

USBALPIM.TSP

Pi matrix with measurement errors

Robust methods

CHANGEPT.TSP

Andrews (1993) test for structural change with unknown change point (Maximum Wald test). Includes a Monte Carlo loop to verify that distribution of the test matches his results.

GLEJSER.TSP

Glejser and MSS tests for heteroskedasticity in quantile regression. by Bronwyn Hall

HCTYPE.TSP

OLSQ(HCTYPE=) Heteroscedastic-Consistent SEs

KERLIN.TSP

Computing Partial Linear Regression according to Robinson (1988).

KTAU.TSP

Computes Kendall's tau-b (nonparametric correlation), and its standard error. Compares with Spearman rank correlation, and regular Pearson correlation. Includes Proc to compute number of ties, and an improved Rank Proc which accounts for ties.

LAD2SK.TSP

2-stage LAD estimation of Klein-I consumption equation

LIST7CH3.TSP

Programming with subscripted lists, to choose up to 3 variables to add to a regression. To reproduce Levine-Renelt 1992 EBA results. (LIST)

MBBJEX3.TSP

moving blocks bootstrap (examples with OLS and LAD). Similar to plain bootstrap, but handles autocorrelation as well as heteroskedasticity. by Bernd Fitzenberger

NEURAL.TSP

Neural network regression on Stackloss dataset. Logistic function of RHS variables with 2 nodes.

ODR.TSP

Orthogonal Distance Regression (errors in variables, when ratio of error variances in Ys and Xs is known).

OPAC.TSP

Ordered Probit with AutoCorrelation-robust SEs. Also shows how to do ML via GMM on first order conditions.

PANBOOT.TSP

Panel bootstrapping. Draws residuals within an individual.

PROBKS.TSP

Semiparametric Probit (Klein and Spady) on small dataset (32 obs.). Uses KERNEL estimation.

SCLS.TSP

Symmetrically Censored Least Squares - proposed by Powell (1986) for Tobit model estimator robust to non-normality. The Newton algorithm here improves its iteration performance greatly. Includes test dataset. by Joao Santos Silva.

SIGNTEST.TSP

Sign test for median of zero, with exact binomial p-value

SPLINE3.TSP

Cubic spline with 3 segments. Examples of fitting sin(6x) and log(.1+x).

SPLSBIC.TSP

Cubic spline which chooses the number of segments by minimizing SBIC. Examples of fitting sin(6x) and log(.1+x).

VUONG.TSP

Vuong test of non-nested models. Computed from difference in LogL for each observations. Example with OLS.

VUONGF.TSP

Vuong test, example with FIML.

WILCOXON.TSP

Wilcoxon signed rank test, with p-value. Nonparametric test for symmetry of a series around a given value.

WILD.TSP

Wild bootstrap, used to approximate the distribution of a test statistic. (Davidson and Flachaire)

WINSOR.TSP

Winsorized residuals, and iterative M-estimation. A simple iterative version.

WTDSAMPL.TSP

Randomly sample from a vector with non-uniform weights. Similiar to random(draw=). Proc WSM, with example of using it.

Hypothesis testing

BDE.TSP

Brown-Durbin-Evans CUSUM and CUSUMSQ tests, both automated and manual.

CAPTEST.TSP

Test of the CAPITL procedure

CDF.TSP

Test of CDF proc for normal, t-dist, F-dist, chi-squared, bivariate normal, and Dickey-Fuller

CNORM.TSP

Tests of CNORM(), CNORMI(), LCNORM(), DLCNORM() functions

COEFTAB.TSP

How to print a small table of selected coefs and SEs from a large estimation, by using ANALYZ

EXOG.TSP

Exogeneity test (Hausman-Wu), Sargan test for identification, and also Breusch-Godfrey LM test for autocorrelation in 2SLS.

FITEST.TSP

Goodness of fit statistics after Pi matrix model, used by US panel examples

GMMCHISQ.TSP

chi-squared test of over-id restrictions (@GMMOVID in 4.3)

HAUSTEST.TSP

Example of Hausman specification test for Poisson vs Negative Binomial model on patent data

HYPTEST2.TSP

Hypothesis testing in linear models (OLS,SUR,2SLS,3SLS) - t-tests, F-tests, likelihood ratio and quasi-likelihood ratio tests.

KLEINCHOW.TSP

Multiequation Chow tests on Klein-I model - parameter stability in SUR and 3SLS using LR and QLR tests.

OMNORM.TSP

Omnibus test for multivariate normality. Reproduces results from Doornik and Hansen (1994) for Fisher Iris data.

PHICHOW.TSP

Chow test for 2SLS (pseudo-F test for parameter stability, split sample)

PROBDIST.TSP

Compute various probability distributions and plot them. by Bronwyn Hall

Time series analysis, GARCH, VAR, Kalman filters, etc.

ADDFACTOR.TSP

Two versions of estimation and forecasting with an add factor, on the same equation. First uses OLSQ and the second uses LSQ and SIML (potentially nonlinear).

ADFBRK.TSP

Various ADF (Augmented Dickey-Fuller) tests with trend breakpoints due to Perron; Harvey et al, etc. A PROC for performing the tests is included.

ADFGLS.TSP

GLS version of ADF (Augmented Dickey-Fuller) unit root test with p-value (Elliott, Rothenberg, Stock (1992,1996)), by Yin-Wong Cheung.

AGARCH.TSP

Asymmetric GARCH as in Ding, Granger, and Engle, Journal of Empirical Finance 1993

ALMONK.TSP

Example of PDL and Kernel estimation using original Almon data

ALMONS.TSP

Tests PDL and Shiller lag options using original Almon data

APARCH.TSP

Asymmetric Power GARCH as in Ding, Granger, and Engle, Journal of Empirical Finance 1993

AR1FSE.TSP

AR1 forecast standard errors, via ANALYZ.

AR1MLP.TSP

Regression with AR(1) residual. Reproduces AR1 command with ML PROC and BJEST option.

AR1W.TSP

Weighted AR1 estimation via ML

AR4NL.TSP

AR(4) on single nonlinear equation (conditional ML)

AR9MA5.TSP

Basic example of Box-Jenkins identification and estimation for an ARMA (1,1) model

ARCH2.TSP

Example of ARCH model with two lags, on GNP and Consumption data

ARCHAR1.TSP

ARCH(1) with AR(1)

ARCHDIAG.TSP

Diagnostic tests for asymmetry of ARCH residuals.

ARCHF.TSP

ARCH forecasting for H(t).

ARCHML.TSP

Compare ARCH proc to ARCH via ML.

ARFX.TSP

AR1 forecasting, in and out of sample

ARMA41ML.TSP

regression with ARMA(4,1) residual. exact ML. Sunspot data.

ARMAX.TSP

regression with ARMA(1,1) error term from Harvey EATS book using Gauss-Newton iteration

ARMAX7.TSP

ARMAX(12,2) estimation with 7 rhs variables (P&R example) using Gauss-Newton iteration

ARMAXC.TSP

ARMA(12,2) estimation using Gauss-Newton iteration (Harvey data)

AUTOEXP.TSP

Example of Box-Jenkins estimation and forecasting using data on auto sales, where the forecast is in terms of the original data (rather than its logarithm).

AUTOSALE.TSP

Example of Box-Jenkins estimation and forecasting using data on auto sales

BERNANKE.TSP

VAR: Bernanke-Sims decomposition. This is a way of factoring Sigma, where the user specifies zero restrictions on particular elements of the factorization. Based on RATS code, and includes test examples.

BILIN2.TSP

Second order bilinear model, by Wiedyo Pura Buana

BJEC.TSP

Example of BJIDENT with ESACF on Box and Jenkins chem series

BKF.TSP

Baxter-King filter (an alternative to Hodrick-Prescott).

BOXCOXAR.TSP

Box-Cox with AR(1) residual. Should be revised to use NODROPMISS option. (FIML)

CALENDAR.TSP

PROCs for various calendar date conversions. Use to convert packed dates like 981231 to year,month,day variables; find which weekday, week, and month a particular day of the year is, etc.

COINT.TSP

Comprehensive test run for Unit root/cointegration testing, data from Nelson and Plosser 1982

COINTARP.TSP

Cointegration test with AR(p) residuals - Stock-Watson(1993) and Phillips-Loretan(1991, p.424).

COJOH.TSP

COINT test on Johansen-Juselius data

CUBIC.TSP

Equations for real roots of cubic equation. Also demonstrates imposing various constraints. (EQSUB,LSQ)

DATELOOP.TSP

Looping over a dated sample - simpler than doquart example, and explains 2 different methods for doing this.

DL.TSP

Approximation to dL (lower critical value for Durbin-Waston statistic), using NOB and K1 (# of RHS variables).

DOQUART.TSP

DO loop over time periods with quarterly data. Example with rolling regression and one-period-ahead forecasts. See the DATELOOP example for a simpler loop.

DWNL.TSP

Approximate P-value for Durbin-Watson in nonlinear model, using regression on first derivatives.

DWTEST.TSP

Durbin-Watson test with exact p-values; switch to Imhoff approx. at N=90

DYNAMSOL.TSP

SOLVE, SIML (dynamic simulation)

EGARCH11.TSP

EGARCH(1,1) estimation. Exponential GARCH, where log(h(t)) = alpha0 + alpha1*abs(e(t-1)) + beta1*log(h(t-1)).

EXPSM2.TSP

Double exponential smoothing with arbitrary smoothing parameter. Compared to ARIMA(0,2,2) model using BJEST.

FINANCE.TSP

Financial applications: 1. saving and sorting 60 betas 2. estimates of variance in rolling sample 3. standard deviation of sequential portfolios 4. t-stat for correlation coefficient, by Sotiris Staikouras

FORCST40.TSP

Single equation forecasting

GAMMADL.TSP

Distributed lag with shape from gamma density.

GARCHM.TSP

GARCH-M - testing via ML

GARCHMA.TSP

GARCH (1,1) with MA(1) residual - testing via ML

GARCHML.TSP

GARCH via ML Proc

GIR.TSP

Generalized Impulse Response - invariant to equation order. Reproduces results in Pesaran and Shin (1998) with KPSW data.

GIR2.TSP

Generalized Impulse Response, via LSQ and SOLVE. (extendable to structural VAR)

GMMNS.TSP

GMM on non-stationary data. Follows Hamilton(1994), p.424 / Ogaki(1993). Estimates model as a function of detrended variables.

HPTREND.TSP

Hodrick-Prescott trend decomposition, data example from Kydland-Prescott

HPTREND4.TSP

Faster version of HPtrend (Hodrick-Prescott trend decomposition). Includes modular versions of the PROC for fast use with multiple series.

IGARCH.TSP

Integrated GARCH(1,1), with constraint that alpha1+beta1=1.

ILLUSFOR.TSP

Test dynamic forecasting using illustrative model, also shows use of common factor test for AR1 models

ILLUSOLV.TSP

Test static similation done using three different methods on the illustrative model

KALD.TSP

Kalman filter with dummy variables that are singular in the initial observations (used to test new recursive residuals that no longer assume initial observations are nonsingular).

KALMAN.TSP

Various tests of the basic Kalman Filter procedure, compared to OLS

KALMANHP.TSP

Kalman filter HyperParameter estimation, using ML PROC. Estimates two variance parameters in the transition equation.

KALVT.TSP

Bootstraps the VT (transition variance) matrix for Kalman Filter by estimating without it, forming an estimate, and then estimating with a transition variance.

KFARMA11.TSP

Evaluation of conditional likelihood function for ARMA(1,1) via the KALMAN command.

KFCOMF.TSP

Kalman Filter with Common Factor (stochastic trend)

KFLLT.TSP

Kalman Filter on Local Linear Trend - Harvey(1989), p.170

KFLOOP.TSP

Kalman filter in a DO loop, to compute SEs for state vector at each period. One parameter in state vector, with user-supplied prior.

KFLOOP2.TSP

Kalman filter in a DO loop, to compute SEs for state vector at each period. Two parameters in state vector, with prior computed from initial observations.

KFMA1.TSP

Ditto, but for MA(1) model. Harvey, TSM, 1981, p.103

KFML.TSP

Estimates Kalman Filter transition matrix via grid search (2 parameters). Compare with KALMANHP.

KLEINSOL.TSP

Tests of model simulation (SIML, SOLVE) on Klein-I

KOYCK2.TSP

KOYCKP example applied to a different dataset.

KOYCKP.TSP

Koyck (geometric) distributed lag, with truncation terms for finite sample panel or time series. Example on Almon data.

KWUNIT.TSP

KPSS unit root test, where stationarity is the null. Handles data of any frequency - uses current SMPL to determine range of data and contains test data from Perron. Sample use illustrated for several frequencies.

KWUNIT2.TSP

Procs for KPSS unit root test. Revised version of KWUNIT Proc by Phil Meguire. Handles any frequency, adds argument to control taking log of input series, and includes critical values from the paper. Compare with Clint's revised version (KWUNIT).

LAGDEP.TSP

FORCST, AR1 with lagged dependent variable

LMAR.TSP

LM test of AR(p) residuals due to Breusch & Godfrey; computed directly using regression

LNORMDL.TSP

Distributed lag with shape from lognormal density.

MA.TSP

Simple Proc to calculate moving average of length n

MARCH2.TSP

Multivariate ARCH with 2 equations (not GARCH)

MARCH3.TSP

Multivariate ARCH with 3 equations (not GARCH)

MARCH4.TSP

Multivariate ARCH with 4 equations (not GARCH)

NONSTAT.TSP

BJEST, BJFRCST on nonstationary data

PDLAR.TSP

Proc to estimate with single PDL variable and AR(p) residuals using nonlinear least squares.

PDLAR2.TSP

Example of calling PROC pdlar

PDLCORC4.TSP

Test AR1 (Cochrane-Orcutt method)  with PDL variable and forecast.

PDLFARSU.TSP

PDL with FAR restriction and coefficients summing to one.

PDLFORC.TSP

Forecasting with a PDL variable estimation

PDLFS143.TSP

PDL with FAR restriction and coefficients summing to one; different lags & degree

PDLPANEL.TSP

PDL done via the PANEL command.

PDLQTR.TSP

Basic tests of OLSQ with PDL, quarterly data; also tests frequency conversion

PDLSQ.TSP

PDL done with LSQ - example for nonlinear or multi-equation estimation

PDLSQAR2.TSP

PDL and AR(2) errors using LSQ

PDLSQBOTH.TSP

PDL in LSQ, with both NEAR and FAR restrictions

PDLSQFAR.TSP

PDL with FAR restriction only

PEARML.TSP

AR1 on pear data - Hildreth-Lu example, showing exact ML

PLOTAC.TSP

Proc which can be called after BJIDENT to print the autocorrelation function (and its 95% bounds) with color graphics.

PPMEX.TSP

Phillips-Perron "z hat sub t" unit root test on Mexican data.

PPZT.TSP

Phillips-Perron "z hat sub t" version of the Dickey-Fuller unit root test. Differs from "z hat sub alpha" test in the COINT(PP) command.

PREDERR.TSP

Prediction error variance for OLS model using a proc

QTOMW.TSP

Quarterly to Monthly conversion, using ratio to average, and weights (sum and average versions).

QTOMW2.TSP

Examples of calling QTOMW, converting forecasts from quarterly model into monthly forecasts.

REGARMA.TSP

Regression with ARMA(8,2) errors (uses ML PROC). Conditional ML. Easier to modify than previous codes like armax7. See regarma2 for exact ML, which is easier to use.

REGARMA2.TSP

Regression with ARMA(8,2) errors, exact ML. See also regarma for conditional ML (but more complicated).

REGMA1.TSP

Regression with MA(1) residuals.

REGOP2.TSP

Testting various regression output options, especially the Durbin-Watson bounds.

SAMAV40.TSP

Seasonal adjustment on a quarterly GDP series

SFT.TSP

Tests shinfull on artificial data. Test P-values against published table of critical values.

SHINFULL.TSP

Shin-Fuller ARMA(p+1,q) unit root test from Journal of Time Series Analysis 1998. Uses exact ML ARMA estimation with multiplicative seasonal. Computes P-value of test statistic by interpolating critical value table from the paper.

SOLSIM.TSP

Trying MODEL and SOLVE when SIML is needed to check error messages.

STAR.TSP

Smooth Transition AutoRegressive models.

THEILU.TSP

Computing various Theil statistics, comparing to ACTFIT

TRADESOL.TSP

33 equation trade model - shows solution by 3 different methods using SIML and SOLVE.

VAR.TSP

VAR estimation and impulse response computation, also with OLS, SUR, and SIML for forecasting

VARBQ.TSP

VAR Blanchard-Quah decomposition (AER 1989). This is an alternative way of factoring Sigma (vs. the arbitrary Cholesky shocks) for impulse responses. The user orders the equations so that the first variable can have a long-run effect on all variables, and the last variable can have a long-run effect only on itself. Includes an example with 2 variables and 4 lags.

VARDIF.TSP

VAR on differenced series, but compute impulse response for original series

VARF.TSP

VAR forecasts

VARIRA.TSP

Impulse Response standard errors via ANALYZ. Hardcoded example for 3 equations, 4 lags, 6 periods.

VARJB.TSP

VAR example from Judge, et al 1988 (p.759) with bootstrap IR bounds

VARMC.TSP

VAR with Monte Carlo. Runs VAR in a loop with bootstrapped residuals to compute empirical distributions of any item in VAR's output. This example computes standard errors for variance decompositions.

VARSBICI.TSP

Chooses optimal lag orders for VAR by minimizing @SBIC. Allows for different lags on different variables. Example with just 2 variables.

VARSIML.TSP

Use SIML to create impulse responses, after a VAR command.

VARST21.TSP

Same as varst32, but 2 variables with 1 lag (much easier to read and understand)

VARST32.TSP

Uses BJEST to check polynomial roots for stationarity of a VAR (3 variables, 2 lags). See varst21 for simpler version.

VRATIO.TSP

Variance ratio test for unit root. See Campbell, Lo, and McKinley text.

Univariate procedures and distribution functions

CLT.TSP

Central Limit Theorem example - convergence of the mean of uniform random variables to normality.

FUNC.TSP

Testing various functions in GENR (normal, integer, etc.)

GINI.TSP

Compute a Gini index (income distribution measure).

INT.TSP

Integration using trapezoidal rule approximation in a DO loop.

MULTINOM.TSP

Draws multinomial r.v.s for user specified probabilities. Compare to new RANDOM(Multinomial) option, which generates random variables according to a multinomial distribution. by Bronwyn Hall

MW.TSP

Weighted median

RANDOM.TSP

Examples of the use of random number generator, including bootstrapping.

RANTRUNC.TSP

Truncated normal random variables via inverse CDF.

RN.TSP

RANDOM (MEAN=,STDDEV=,VAR=) for series mean, Poisson, Negative binomial, Laplace

TRIGTEST.TSP

Test trig function, normal density, and their derivatives

 

 

If you have any questions or comments about TSP please send an email to info@tspintl.com.

Comments or questions about this website should be sent to news@tspintl.com.