Latest TSP Examples
Last updated: Feb-21-11
first draft of new index format 10/2006
(not quite complete, and some things need to be checked/added)
new upcoming index format 8/2006
Examples Sorted by Date
By Date
Examples Sorted by Group
The examples below are the latest bits of code that have
arisen from technical support questions, plus a few which
were volunteered by TSP users.
A few of them are relatively rough and may not be fully
commented. Others are extensively commented, and some are
in PROC form, quite ready for general use.
Some of the examples are cross-referenced in a second
category. The first category will then be given in
parentheses. For example, panunit is listed first
under U (Unit root), and second under Panel.
Example Categories
- Panel data Models
- QDV Models
- Time Series
- General Nonlinear Estimation
- General
G - Panel - GMM models
- usbalme
Panel GMM with measurement errors (original 3/93, corrected MASK for second model, correct comments 11/02) (Nov-12-02)
- arelbon2
Arellano-Bond example with 3 RHS variables. (Feb-20-02)
- gapubal
Setting up a gapped SMPL for unbalanced stacked panel data, so that GMM(NMA=k) can be used. (May-04-00)
- probitac (F)
Probit with SEs robust to autocorrelation (uses GMM). (May-05-98)
- arelbond
Simple Arellano-Bond example, 1-step and 2-step estimators (balanced panel data). Uses cov1step and premaskg. Uses very simple artificial data. (originally written 9/19/97; revised 12/97 for cov1step change; revised 4/98 to correct the COVOC=OWN behavior in the 2-step estimator, and add a comparative table of 1-step, 2-step, and default GMM coefficients) (Apr-17-98)
- cov1step
Arellano-Bond 1-step COVOC matrix - GMM/panel (originally released 8/4/97; revised to add mask argument to work around GMM bug in applying mask) (Dec-17-97)
- firstdif
Automates creation of first-differenced variables for GMM panel models, where the variables are named by time period, like y1 y2 y3, etc. (Nov-11-97)
- lm2test
like Arellano-Bond m2 statistic, tests AR(1) and AR(2), by Bronwyn Hall. Originally written 3/97, revised for 4.3 compatibility. (Oct-08-97)
- lm2test2
Alternative version of lm2test, using explicit lags. Unfortunately, it seems to be about 20% slower than lm2test. (Oct-08-97)
- cov2step
Arellano-Bond 2-step COVOC matrix - GMM/panel (Sep-18-97)
- premaskg
creates mask for GMM with panel data (Aug-04-97)
- premaskc
2 examples of calling premaskg (Aug-04-97)
- mask2
2 different ways to set up a large sparse MASK matrix for use in GMM (different instruments in different equations). (Feb-27-96)
E - Panel - Error Components models
- kleinfe (P)
2SLS and 3SLS with (one-way) fixed effects. Shows the easy way to do this - by removing the individual means from all variables (including the instruments). Results match those with individual dummies. Uses the Klein data, as a 3-individual unbalanced panel. (Jan-26-01)
- reub
Random Effects on UnBalanced data - ML estimation of one-way model. Written as a PROC, where you just supply a list of RHS variables (Jan-17-01)
- reubab
example of using the REUB Proc, on the Arellano-Bond model. (Jan-17-01)
- probitre
Probit with Random Effects - the Borjas-Sueyoshi 2-stage model. Extensive comments on the Pooled vs. Random Effects estimators. (Nov-12-99)
- g4
Panel 1-way and 2-way variance components (both individual and time effects), via Maximum Likelihood (vs. GLS). For balanced data. A better version is on the Benchmarks page. (Nov-02-99)
- ec3sls
3SLS with 2-way error components, balanced panel. Uses transformed data with 3SLS commands. Much faster than old matrix versions. (Feb-04-99)
- ec2sls
2SLS with 2-way error components, balanced panel. Uses transformed data with 2SLS commands. Much faster than old matrix versions. (Feb-04-99)
- ec3sm1
3SLS with 2-way error components, balanced panel, Matrix version. (originally written 11/97; renamed 2/99 when replaced by faster nonmatrix version) (Feb-04-99)
- ec2sm3
2SLS with 2-way error components, balanced panel, 3rd Matrix version. (originally written 11/97; renamed 2/99 when replaced by faster nonmatrix version) (Feb-04-99)
- p3s
Example of using ec3sls on a real model (data files are not included). (Nov-26-97)
- ec2sm1
First matrix algebra version of ec2sls. Does not use transformed data. Notation differs a bit from Hsiao(1986). (Original version 9/97). (Nov-18-97)
- ec2sm2
Second matrix algebra version of ec2sls. Uses transformed data; notation is close to Hsiao(1986). (Nov-18-97)
- h3b
Hsiao(1986)'s Appendix 3B - verifies 2-way EC Omega inverse (Sep-11-97)
- apd
creates artificial panel data. balanced, one-way random effects, 2 Xs correlated with random effects (May-20-97)
- ub2wfere
unbalanced 2-way fixed and random effects follows Wansbeek and Kapteyn (J of E, 7/1989). Not tested against any real-world benchmark results. See also g4, which can be extended to the unbalanced case. (Dec-18-96)
- data2way
generates artificial data for 2-way model (Dec-18-96)
P - Panel - other than GMM and Error Components
- frontp3 (Q)
Frontier production function, unbalanced panel, same as frontp1, but works on any stacked unbalanced panel (Feb-21-11)
- pstr
Panel Smooth Transition Regression. 2 regimes. grid search and ML PROC estimation (original 9/05, revised 9/07) (Sep-05-07)
- infot
Information Matrix Test - example with Probit (May-03-07)
- gcoefi
Panel OLS model where some coefficients vary by individual, and others do not. Includes a PROC to automate this. (Apr-13-06)
- frontp2 (Q)
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. (original 1/01, revised 4/04 to use 2-step iteration process and compute efficiency term, revised 7/05 to check for positive skewness) (Jul-28-05)
- pansd
computes standard deviation of a panel series within each individual, and stores result as a series (Oct-06-04)
- gspd5
Duplicate state variables for each industry. (original 1/94, updated 6/03 to remove unavailable data files) (Jun-23-03)
- pdlpanel
PDL done via the PANEL command. (original 9/94, updated 6/03 to use FREQ(PANEL) ). (Jun-23-03)
- feihat
hat matrix (leverage) for fixed effects model. (Sep-18-02)
- panrw
simulates Panel Random Walk with drift. (Apr-10-01)
- koyck2 (D)
koyckp example applied to a different dataset. (Feb-02-01)
- fixedse
standard errors for the intercept terms in a fixed effects model (balanced or unbalanced) (Original: 11/96; updated comments 2/01) (Feb-01-01)
- kleinfe
2SLS and 3SLS with (one-way) fixed effects. Shows the easy way to do this - by removing the individual means from all variables (including the instruments). Results match those with individual dummies. Uses the Klein data, as a 3-individual unbalanced panel. (Jan-26-01)
- frontp1 (Q)
Frontier production function, unbalanced panel, error components, v_it - u_i. Follows Battese and Coelli, 1992. (Jan-25-01)
- koyckp (D)
Koyck (geometric) distributed lag, with truncation terms for finite sample panel or time series. Example on Almon data. (Jan-24-01)
- timediff
time dummies in first differenced equations (when differencing to remove individual effects) (Nov-21-00)
- probitfe
Probit fixed effects - efficient iteration for large N. (Jul-12-00)
- diaghet
Diagonal heteroskedasticity model (like SUR, but no off-diagonal terms); can be useful when N > T. (Jun-23-00)
- panw
Weighted fixed effects estimation. (Jun-16-00)
- panmeans
Removing individual or time means. (original: 8/98, updated 2/00 to use PANEL(WITHIN) to remove individual means). (Feb-07-00)
- pansmpl
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. (Oct-22-99)
- balu
Panel - "balances" unbalanced data by adding artificial observations with zeros for all variables. (Sep-07-99)
- sbicpan
SBIC values for Total and Within in PANEL. Also explains why SBIC may not be easy to use for choosing an optimal number of lags. (Aug-15-99)
- ah
Anderson-Hsiao 2SLS for dynamic panel model (avoids finite sample bias in fixed effects estimator). (Aug-12-99)
- fixedubmv
How to convert PANEL's @FIXED matrix to a series, for the most general case, when the data is unbalanced and has missing values. (originally written 6/98; revised 8/98 to replicate fixed effects from initial nonmissing observations to all observations, updated 7/99) (Jul-15-99)
- panchow
Chow test for panel data, within model, where both the coefficients and fixed effects vary across 2 periods. (Original: 3/98, updated 6/99) (Jun-09-99)
- panunit (U)
Panel unit root test of Im, Pesaran, and Shin. Improved version, which has the URL for downloading the paper, and describes how to look up the critical values in IPS Tables 2-4. (original: 8/97, updated 9/98, 3/99) (May-11-99)
- ar1fmlp (T)
AR(1) (exact ML) for panel data, using the FIML command. Reproduces AR1(TSCS) results. (Mar-01-99)
- panboot
Panel bootstrapping. Draws residuals within an individual. (Feb-09-99)
- fixediv
2SLS with fixed effects. Efficient computation, by using PANEL in 2 stages. (originally written 5/97; revised 11/98 to compute summary statistics on structural residuals) See kleinfe for an improved method. (May-16-98)
- ar1hetub
version of ar1het for unbalanced data (Apr-29-98)
- logitshp (L)
Mixed Logit on (24) shares (fractional dependent variables aggregated over many choosers), panel data. Calculates predicted shares. Handles missing X values for zero shares (in a rather ad hoc way). (Feb-06-98)
- unbalsu4 (M)
(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. (Nov-26-97)
- ar1het
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. (Nov-21-97)
- logitfe3 (L)
fixed effects logit for panel data with 3 time periods (choice taken 1 or 2 times). Follows Hsiao(1986), p.162. (Jun-20-97)
- garcia
Growth model, stochastic differential equations, unbalanced panel. Uses recursive EQSUB. This nonlinear panel growth model is used on tree heights. (Jun-12-97)
- panhaus (B)
reproduces Hausman test of RE vs. FE in panel data (Feb-13-97)
- bal2wfe
balanced 2-way fixed effects (Dec-18-96)
- coxpanel
ML estimation of Cox proportional hazards model, balanced data example with 3 time periods. Uses lagged EQSUB feature. (May-16-96)
L - Logit models
- dpdx3
Mean and variance of dP/dX for Logit with 3 choices. (original 3/99, revised 4/02 to draw artificial data) (Apr-10-02)
- logitbc
Logit with approximate Bias Correction. (Dec-14-02)
- pr2 (F)
McFadden's pseudo R-squared for Probit/Logit. In TSP 4.4 as "Kullback-Leibler R-squared" (@KLRSQ), replaced in TSP 4.5 by Estrella's "Scaled R-squared". (originally written 12/96; revised 4/98 to add Arturo Estrella's improved R-squared, revised 11/02 to add conditional logit example) (Nov-13-02)
- mnestlog2
2-level nested multinomial logit. (Aug-27-01)
- nestlog2
2-level nested conditional logit. (Aug-27-01)
- nestl
nested logit example from TSP User's Guide. Shows relation to mixed logit model. (Apr-20-01)
- logitlim
Same as logitcsu, but includes code which takes limits of ratios, to avoid EXP(xb) overflow, when xb is larger than 88. (Sep-07-99)
- logitcsu
Logit - conditional, with shares as dependent variable, unbalanced data. Data has been "balanced" by running balu first. (Sep-07-99)
- rpl
Random Parameters (coefficients) Logit. Example with a fixed intercept and one additional RHS variable with a normally distributed random coefficient. Uses ML PROC. (Aug-03-99)
- logitsh
Logit with shares as dependent variables. Was previously corrupted on examples disk and web page. (originally released 7/96, revised 2/98 to add more comments) (Feb-25-98)
- logitshp
Mixed Logit on (24) shares (fractional dependent variables aggregated over many choosers), panel data. Calculates predicted shares. Handles missing X values for zero shares (in a rather ad hoc way). (Feb-06-98)
- logitfe3
fixed effects logit for panel data with 3 time periods (choice taken 1 or 2 times). Follows Hsiao(1986), p.162. (Jun-20-97)
- testnlog
2 level (5 x 10) nested logit, with artificial test data, by Bronwyn Hall (Apr-01-97)
- wclogit
weighted conditional logit. (originally written Mar 94) (Oct-31-96)
- logitmix
mixed logit via ML command; a standard TSP testrun (Sep-25-96)
- logiteach
data setup code for conditional logit, where each alternative is chosen exactly once. (Sep-12-96)
- logitf
forecasts from a multinomial logit model (picks most likely Y value for a set of X values). not tested. (May-20-96)
- nest31
improved version of NEST3, can be changed for diff. model (Dec-06-94)
- nest3
3-level nested logit (Nov-30-94)
- dpdx
standard errors for @DPDX from Logit (Jun-02-94)
- nlogit
2-level nested logit (Nov-05-93)
F - Probit models
- opdydx
dy/dx for Ordered Probit. Computes change in histogram of predicted dependent variable, for changes in a given X variable. (Feb-03-05)
- msprobit (S)
Real Markov switching Probit model, by Masahito Kobayashi. (Mar-29-04)
- ebiprob
Bivariate probit where Y2 is not observed unless Y1=1. Artificial data. (Nov-19-03)
- probks2
Semiparametric Probit (Klein and Spady) on large dataset (2339 obs.). Should revise to use KERNEL command in TSP 5.0. (Apr-12-02)
- probks
Semiparametric Probit (Klein and Spady) on small dataset (32 obs.). (Apr-12-02)
- pr2
McFadden's pseudo R-squared for Probit/Logit. In TSP 4.4 as "Kullback-Leibler R-squared" (@KLRSQ), replaced in TSP 4.5 by Estrella's "Scaled R-squared". (originally written 12/96; revised 4/98 to add Arturo Estrella's improved R-squared, revised 11/02 to add conditional logit example) (Nov-13-02)
- tobithet (J)
Tobit and Probit, when heteroskedasticity is a function of variables. (Aug-27-01)
- op3
Ordered Probit - examines changes in Y for changes in a dummy variable. (Aug-09-01)
- opfp
Ordered Probit forecasted probabilities. (Jun-28-01)
- phe
Bivariate Probit with Hermite quadrature. (Apr-09-01)
- hetprob
LM test for heteroskedasticity in Probit. Follows Godfrey's book. (Original: 10/95, comments added 3/99, made easier to use 1/01) (Jan-26-01)
- op1r1 (Q)
2 eqns: Ordered Probit and Regression / sample selection (Jan-12-01)
- p1op1
2 eqns: Probit and Ordered Probit, correlated, by Bronwyn Hall (Jan-11-01)
- p1r2n (Q)
3 eqns: Probit and 2 Regression - non-selection, with simultaneity in Probit eqn (Dec-16-00)
- p1r2s (Q)
3 eqns: Probit and 2 Regression - selection model (Dec-16-00)
- biprob
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. (original: 3/99, updated 11/00 for dep. var. names) (Nov-30-00)
- probitfe (P)
Probit fixed effects - efficient iteration for large N. (Jul-12-00)
- probitre (E)
Probit with Random Effects - the Borjas-Sueyoshi 2-stage model. Extensive comments on the Pooled vs. Random Effects estimators. (Nov-12-99)
- probder
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). (Oct-06-99)
- swprob
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. (Jun-11-99)
- tnp
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. (Mar-01-99)
- probitac
Probit with SEs robust to autocorrelation (uses GMM). (May-05-98)
J - Tobit models
- hurdle2bc
Double hurdle model with Box-Cox (Oct-29-08)
- tob2
2-equation (bivariate) simultaneous Tobit (original 11/92, revised 3/07) (Mar-07-07)
- hurdle2
Double Hurdle model. Tobit is single hurdle; this is like Tobit with and additional selection equation . (Nov-17-06)
- tobr2
R-squared for Tobit model, one possible formulation. (Jun-19-02)
- tobpred
Predictions from Tobit model, conditional and unconditional. (May-22-02)
- tobithet
Tobit and Probit, when heteroskedasticity is a function of variables. (Aug-27-01)
- scls
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, of UTL/ISEG, Lisbon. (original: 4/99, updated 3/00 to cite source of data file). (Mar-28-00)
- tob2lim
2-Limit Tobit (with both upper and lower bounds). Uses globally concave parameterization for iterations, to avoid convergence problems. Written as a Proc -- you supply variable names and upper/lower bounds (original: 10/97; minor update 7/98) (Jul-24-98)
- tobrncf
Tobit with random coefficients, Ionnatos, JBES July 1995 (Apr-02-97)
- tobendog
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. (Feb-13-96)
- tob2sur
2-equation Tobit, but with no RHS endogenous variables (Nov-06-92)
S - Switching regression models
- msprobit
Real Markov switching Probit model, by Masahito Kobayashi. (Mar-29-04)
- regime
Real Markov switching regression model, by Masahito Kobayashi. (Mar-29-04)
- swregun
Switching with unknown regime and unknown sample separation, by Augustin de Coulon. (Nov-19-03)
- hamsimp
Markov chain model - simple 2-regime from Hamilton's book, via EM. By David Bivin (Sep-11-00)
- markovrt (T)
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. (Nov-09-99)
- swprob (F)
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. (Jun-11-99)
- swreg
Switching regression, regime unknown. Follows Maddala(1983), p.283. (Jun-11-99)
- diseq104
Disequilibrium model, with sample separation known. Section 10.4 of Maddala(1983), p.307-309. (Sep-16-97)
- switch
Disequilibrium / switching regression model from 4.3 User's Guide, by Bronwyn Hall. Maddala p.298 (Nov-11-96)
Q - QDV - Qualitative Dependent Variables (other than above)
- frontp3
Frontier production function, unbalanced panel, same as frontp1, but works on any stacked unbalanced panel (Feb-21-11)
- ophe
Ordered Probit Random Effects by Hermite Quadrature (Jan-29-08)
- frontp2
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. (original 1/01, revised 4/04 to use 2-step iteration process and compute efficiency term, revised 7/05 to check for positive skewness) (Jul-28-05)
- fronte
Efficiency term for Frontier model from Battesse and Coelli (1988) (original 3/02, updated 4/04) (Apr-13-04)
- frontp1
Frontier production function, unbalanced panel, error components, v_it - u_i. Follows Battese and Coelli, 1992. (Jan-25-01)
- op1r1
2 eqns: Ordered Probit and Regression / sample selection (Jan-12-01)
- p1op1 (F)
2 eqns: Probit and Ordered Probit, correlated, by Bronwyn Hall (Jan-11-01)
- p1r2n
3 eqns: Probit and 2 Regression - non-selection, with simultaneity in Probit eqn (Dec-16-00)
- p1r2s
3 eqns: Probit and 2 Regression - selection model (Dec-16-00)
- biprob (F)
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. (original: 3/99, updated 11/00 for dep. var. names) (Nov-30-00)
- opac
Ordered Probit with AutoCorrelation-robust SEs (Aug-17-00)
- count
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. (Oct-26-99)
- ssg1g
sample selection model - demonstrates multiple local optima with grid search, following Nawata(1995). Graphs LogL vs. RHO. Automated grid search is part of SAMPSEL in TSP 4.5. (Mar-23-99)
- nbsim
Using RANDOM(NEGBIN) when the mean is different for each observation (Jun-11-98)
- coxpanel (P)
ML estimation of Cox proportional hazards model, balanced data example with 3 time periods. Uses lagged EQSUB feature. (May-16-96)
- bivord
Bivariate Ordered Probit (without data). Could be improved in TSP 4.5 and higher by using CNORM(z1,z2,rho) function. (Nov-16-94)
- cn4
4-dimensional cumulative normal integral, approximated with many random draws, CNORM(), CNORMI(), and Cholesky factorization. (Aug-24-93)
- bivar
approximation for Bivariate normal CDF in ML. Outdated in TSP 4.5 and higher, where CNORM(z1,z2,rho) can be used. (Apr-01-93)
- hazard
log-linear hazard function with one time-varying covariate (Jan-01-93)
- samsel2
sample selection with 2 selection equations (undocumented) (Dec-03-92)
H - GARCH models
- archar1
ARCH(1) with AR(1) (Jan-14-08)
- archdiag
Diagnostic tests for asymmetry of ARCH residuals. (Oct-28-02)
- igarch
Integrated GARCH(1,1), with constraint that alpha1+beta1=1. (Nov-16-99)
- archf
ARCH forecasting. Revised slightly for TSP 4.5, where ARCH no longer estimates H(0) by default. (Sep-30-99)
- egarch11
EGARCH(1,1) estimation. Exponential GARCH, where log(h(t)) = alpha0 + alpha1*abs(e(t-1)) + beta1*log(h(t-1)). (Feb-23-99)
K - Kalman filter
- kfcomf
Kalman Filter with Common Factor (stochastic trend) (Jan-08-09)
- kald
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). (Sep-11-98)
- kalmanhp
Kalman filter HyperParameter estimation, using ML PROC. Estimates 2 variance parameters in the transition equation. (originally written 1/97; revised 4/98 to clarify that only the SEs of the final state vector are inconsistent) (Apr-13-98)
- kfllt
Kalman Filter on Local Linear Trend - Harvey(1989), p.170 (Sep-05-96)
- kfarma11
Evaluation of conditional likelihood function for ARMA(1,1) via the KALMAN command. (Jul-22-96)
- kfma1
Ditto, but for MA(1) model. Harvey, TSM, 1981, p.103 (Jul-18-96)
- kfloop2
Kalman filter in a DO loop, to compute SEs for state vector at each period. 2 parameters in state vector, with prior computed from initial observations. (Jun-21-96)
- kfloop
Kalman filter in a DO loop, to compute SEs for state vector at each period. 1 parameter in state vector, with user-supplied prior. (Jun-21-96)
- kfml
estimates Kalman Filter transition matrix via grid search (2 parameters). Compare with kalmanhp above. (Mar-07-96)
U - Unit root and cointegration
- vratio2
Revised code for vratio, with changed commands noted by question marks. (Jul-09-02)
- adfbrk
ADF tests with trend breakpoints. (original 2/02, revised 4/02) (Apr-05-02)
- adfgls
GLS version of ADF unit root test with p-value (Elliott, Rothenberg, Stock (1992,1996)), by Yin-Wong Cheung. (originally stored here 5/97, updated 4/00 to add comments). (Apr-28-00)
- vratio
Variance ratio test for unit root. (original: 7/98, updated 3/00 to add some comments, see vratio2 also). (Mar-24-00)
- cointarp
Cointegration test with AR(p) residuals - Stock-Watson(1993) and Phillips-Loretan(1991, p.424). (Jan-05-00)
- joh1
Reproduces Johansen-Juselius cointegration results for Finnish data. (original: 1993, updated: 94, 1/97, 9/99 - added alpha values (speed of adjustment); reproduces more results from the original article) (Sep-30-99)
- gmmns
GMM on non-stationary data. Follows Hamilton(1994), p.424 / Ogaki(1993). Estimates model as a function of detrended variables. (May-27-99)
- panunit
Panel unit root test of Im, Pesaran, and Shin. Improved version, which has the URL for downloading the paper, and describes how to look up the critical values in IPS Tables 2-4. (original: 8/97, updated 9/98, 3/99) (May-11-99)
- shinfull
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 paper. (Oct-02-98)
- sft
Tests shinfull on artificial data. Test P-values against published table of critical values. (Oct-02-98)
- ppmex
Phillips-Perron "z hat sub t" unit root test on Mexican data. Uses ppzt.tsp. (Oct-24-96)
- ppenders
ppzt on data from 4 countries. Mostly reproduces table on p.263 of Enders, "Applied Economic Time Series", 1995 (Oct-24-96)
- ppzt
defines Proc ppzt, for 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. (Oct-24-96)
- kwunit2
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) below. Shows different styles of coding. (Mar-29-96)
- kwunit
KPSS unit root test, where stationarity is the null. Revised version - handles data of any frequency - uses current SMPL to determine range of data (Jan-08-96)
V - VAR - Vector AutoRegression
- vardif
VAR on differenced series, but compute impulse response for original series (Oct-19-04)
- gir2
Generalized Impulse Response, via LSQ and SOLVE. (extendable to structural VAR) (Mar-07-02)
- varira
Impulse Response SEs via ANALYZ. Hardcoded example for 3 equations, 4 lags, 6 periods. (Feb-15-02)
- gir
Generalized Impulse Response - invariant to equation order. Reproduces results in Pesaran and Shin (1998) with KPSW data. (Mar-20-01)
- varmc
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. (original: 9/98, corrected 11/00 for real data) (Nov-07-00)
- bernanke
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. (original: 10/98, revised 8/99 to use relative convergence check, check for under/exact/overidentification.) (Aug-14-99)
- varst32
Uses BJEST to check polynomial roots for stationarity of a VAR (3 variables, 2 lags). (original: 11/95, revised 11/98 to use TSP 4.4 feature for printing roots) (Nov-13-98)
- varbq
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. (Oct-26-98)
- varsiml
Use SIML to create impulse responses, after a VAR command. Corrects the original version dated 8/94. (Jun-11-98)
- varforc
forecasting after VAR. (originally written 5/97; revised 6/98 to note that FORCST now works after VAR, so this code is obsolete) (Jun-11-98)
- sbic
Shows 3 different normalizations for SBIC and AIC, and which one TSP 4.4 uses in OLSQ. In TSP 4.5, we switched to using the unnormalized SBIC and AIC. (Feb-19-98)
- varsbici
Chooses optimal lag orders for VAR by minimizing @SBIC. Allows for different lags on different variables. Example with just 2 variables. (Sep-25-97)
- varsbic
chooses optimal lag order for VAR by minimizing @SBIC (Sep-11-97)
- varst21
same as varst32, but 2 variables with 1 lag (much easier to read and understand) (Nov-13-95)
D - Distributed Lags (including PDL)
- pdlsqboth
PDL in LSQ, with Both Near and Far constraints (Nov-15-07)
- pdlpanel (P)
PDL done via the PANEL command. (original 9/94, updated 6/03 to use FREQ(PANEL) ). (Jun-23-03)
- lnormdl
Distributed lag with shape from lognormal density. (Apr-05-02)
- gammadl
Distributed lag with shape from gamma density. (Apr-05-02)
- koyck2
koyckp example applied to a different dataset. (Feb-02-01)
- koyckp
Koyck (geometric) distributed lag, with truncation terms for finite sample panel or time series. Example on Almon data. (Jan-24-01)
- pdlar
single PDL variable with AR(p) residuals (4.4) (Jul-11-97)
- pdlar2
example of calling pdlar (Jun-13-97)
- pdlar243
4.3 code version of pdlar2 (calls pdlar43) (Jun-12-97)
- pdlar43
4.3 code version of pdlar (Jun-12-97)
T - Time series (miscellaneous)
- regma1
Regression with MA(1) residuals (Mar-19-07)
- regarma2
OLS with ARMA(8,2) errors, exact ML. (original 1/99, did not work, revised 2/07, now works) (Feb-23-07)
- arma41ml
regression with ARMA(4,1) residual. exact ML. Sunspot data. (Dec-03-04)
- ar1mlp
regression with AR(1) residual. Reproduces AR1 command with ML PROC and new BJEST option. (Dec-03-04)
- ar2mlp (B)
regression with AR(2) residual, exact ML estimation. Uses both ML and ML PROC, with the new BJEST option which allows general ARMA residuals. Klein-I consumption function data. (Nov-28-04)
- plotac
Proc which can be called after BJIDENT to print the autocorrelation function (and its 95% bounds) with color graphics. (original 9/96, updated 9/04 to use Bartlett SEs) (Sep-16-04)
- dl
Approximation to dL (lower critical value for Durbin-Waston, using NOB and K1. (Apr-20-04)
- regarma
Regression with ARMA(8,2) errors (uses ML PROC). Much easier to modify than previous codes like armax7. (original 10/97, revised slightly to avoid creating a variable named U, to avoid a bug in ML PROC, 5/03) (May-14-03)
- bkf
Baxter-King filter. (original 5/01, corrected 10/02) (Oct-26-02)
- dwnl
Approximate P-value for Durbin-Watson in nonlinear model, using regression on first derivatives. (Jun-12-02)
- bilin2
second order bilinear model. (Sep-25-02)
- star (A)
Smooth Transition AutoRegressive models. (May-25-01)
- dateloop (I)
looping over a dated sample - simpler than doquart example, and explains 2 methods (Nov-21-00)
- calendar
Calendar information in Procs. 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. (original: 7/98, updated 2/00 for century leap years). (Feb-28-00)
- markovrt
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. (Nov-09-99)
- changept
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. (Sep-27-99)
- ar1fmlp
AR(1) (exact ML) for panel data, using the FIML command. Reproduces AR1(TSCS) results. (Mar-01-99)
- expsm2
Double exponential smoothing with arbitrary smoothing parameter. Compares with ARIMA(0,2,2) model. (Jan-06-99)
- hptrend44
Faster version of HPtrend (Hodrick-Prescott trend decomposition). Uses the MFORM(BAND) option in TSP 4.4 for maximum speed. Also includes modular versions of the Proc for fast use with multiple series. (Oct-21-97)
- qtomw
Quarterly to Monthly conversion, using ratio to average, and weights (sum and average versions). (Jun-20-97)
- qtomw2
Examples of calling qtomw, converting forecasts from quarterly model into monthly forecasts. (Jun-20-97)
- ma
simple Proc to calculate moving average of length n (Feb-25-97)
- gapbal
creates gapped smpl for balanced AR1(TSCS) (obsolete in 4.4 and later versions) (Feb-21-97)
- dh (B)
reproduces Durbin's h statistic (Feb-11-97)
- bilinear
ML estimation of simple bilinear time series model. Uses recursive derivative code; could be made simpler with ML PROC. (Jan-30-96)
- ar1tscs
easy way of creating the gapped SMPL for AR1(TSCS), from an ID variable, for balanced or unbalanced data. Outdated in TSP 4.4, where FREQ(PANEL) can be used instead of a gapped SMPL. (Jun-21-95)
- doquart (I)
DO loop over time periods with quarterly data (May-12-94)
M - ML and ML PROC, and general nonlinear estimation
- pstr (P)
Panel Smooth Transition Regression. 2 regimes. grid search and ML PROC estimation (original 9/05, revised 9/07) (Sep-05-07)
- regarma2 (T)
OLS with ARMA(8,2) errors, exact ML. (original 1/99, did not work, revised 2/07, now works) (Feb-23-07)
- gammas
gamma simulation of rainfall model, where trace values below 0.1 are truncated to zero. (Oct-29-04)
- gammar
gamma estimation of rainfall model. Uses ML PROC and CDF to evaluate igamma() function. (Oct-29-04)
- boxcoxj
Jacobian term for testing log vs. level and general Box-Cox model. (Mar-17-04)
- hhsim
Minimum distance estimation of Hall-Hayashi dynamic factor model. Uses simulated data, a runnable version of the hhex example. (Jun-25-03)
- regarma (T)
Regression with ARMA(8,2) errors (uses ML PROC). Much easier to modify than previous codes like armax7. (original 10/97, revised slightly to avoid creating a variable named U, to avoid a bug in ML PROC, 5/03) (May-14-03)
- aids
Almost Ideal Demand System, with elasticities, Deaton and Muellbauer model, based on SAS example. (Jun-13-02)
- spatial
Proc which estimates Spatial Autocorrelation and Spatial Autoregressive models. User supplies W = spatial proximity weight matrix. (Original: 12/97; updated 4/01) (Apr-04-01)
- biquad
Bivariate normal cdf - how to evaluate probabilities in all 4 quadrants, by changing signs of the arguments to CNORM2(z1,z2,rho). (Jan-03-00)
- boxtid0
Box-Tidwell regression when the RHS variables are sometimes zero. (Oct-06-99)
- rpl (L)
Random Parameters (coefficients) Logit. Example with a fixed intercept and one additional RHS variable with a normally distributed random coefficient. Uses ML PROC. (Aug-03-99)
- expsm2 (T)
Double exponential smoothing with arbitrary smoothing parameter. Compares with ARIMA(0,2,2) model. (Jan-06-99)
- ar1fml (A)
AR(1) exact ML with the FIML and ML commands. Does not use the new NODROPMISS option; instead creates an artificial first observation which is not used. NODROPMISS is a better way to handle this -- see ar1fmlp. (Nov-03-98)
- boxcoxar
Box-Cox with AR(1) residual (Jul-28-98)
- boxcox0
Box-Cox transformation when Y is zero (May-29-98)
- student (R)
regression with Student t residuals; see also stacklos example. (May-26-98)
- kalmanhp (K)
Kalman filter HyperParameter estimation, using ML PROC. Estimates 2 variance parameters in the transition equation. (originally written 1/97; revised 4/98 to clarify that only the SEs of the final state vector are inconsistent) (Apr-13-98)
- rancoef
ML estimation of a regression with a single random coefficient. Outlines how to extend to multiple random coefficients. (Mar-11-98)
- spatcal
Example of running spatial.tsp on California plant species data. Reproduces results for Spatial AutoCorrelation and Spatial AutoRegression from Upton and Fingleton (1985). (Dec-05-97)
- olsme
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. (Dec-04-97)
- unbalsu4
(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. (Nov-26-97)
- stacklos (R)
LAD and Student's t residuals on classic Stack Loss dataset (Sep-12-97)
- fiml5
FIML via ML with 5 equations (like fiml4 and fiml11) (Jul-21-97)
- garcia (P)
Growth model, stochastic differential equations, unbalanced panel. Uses recursive EQSUB. This nonlinear panel growth model is used on tree heights. (Jun-12-97)
- ml2stage
calculates corrected VCOV for second stage ML estimator. 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. (Apr-22-97)
- unbalsur1
unbalanced SUR -- 2 equations; some observations missing for the second equation. ML version only (easiest way to get estimates and proper standard errors). (Dec-02-96)
- grid
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 (May-23-96)
- kfml (K)
estimates Kalman Filter transition matrix via grid search (2 parameters). Compare with kalmanhp above. (Mar-07-96)
- bilinear (T)
ML estimation of simple bilinear time series model. Uses recursive derivative code; could be made simpler with ML PROC. (Jan-30-96)
- fiml11
11-equation FIML estimation, via the ML command. Just an extension of the old fiml4 example. (Dec-22-95)
- unbalml
slightly more complicated version of unbalsur1. Probably not needed. (Dec-15-95)
- unbalsur
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 unbalsur1. (Aug-10-95)
- fiml4
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. (Dec-01-93)
A - Autoregressive residuals with LSQ (nonlinear/multiequation)
- surar1
nonlinear SUR with AR(1) residuals, different RHO for each equation, conditional or exact ML (original 4/97, updated 3/04 to correct transformation for first obs. and to use NODROPMISS option) (May-27-04)
- formar1
FORM with exact ML first observation for LSQ; includes Jacobian trick so that FIML is not needed. (Nov-29-02)
- ar1w
weighted AR1 estimation via ML in TSP 4.5 (Jun-22-01)
- ar1fse
AR1 forecast standard errors, via ANALYZ. (Jun-12-01)
- star
Smooth Transition AutoRegressive models. (May-25-01)
- ar1fml
AR(1) exact ML with the FIML and ML commands. Does not use the new NODROPMISS option; instead creates an artificial first observation which is not used. NODROPMISS is a better way to handle this -- see ar1fmlp. (Nov-03-98)
- boxcoxar (M)
Box-Cox with AR(1) residual (Jul-28-98)
- pdlar (D)
single PDL variable with AR(p) residuals (4.4) (Jul-11-97)
- pdlar2 (D)
example of calling pdlar (Jun-13-97)
- pdlar243 (D)
4.3 code version of pdlar2 (calls pdlar43) (Jun-12-97)
- pdlar43 (D)
4.3 code version of pdlar (Jun-12-97)
- ar4nl
AR(4) on single nonlinear equation (conditional ML) (Feb-05-97)
R - Robust (resistant to outliers or heteroskedasticity) and non-parametric
- vuongf
Vuong test, example with FIML. (Mar-12-06)
- vuong
Vuong test of non-nested models. Computed from difference in LogL for each observations. Example with OLS. (Mar-12-06)
- lad2sk
2-stage LAD estimation of Klein-I consumption equation (Apr-08-04)
- wtdsampl (I)
Randomly sample from a vector with non-uniform weights. Similiar to random(draw=). Proc WSM, with example of using it. (original 12/97, updated 9/03 for multiple series). (Sep-19-03)
- wild
Wild bootstrap, used to approximate the distribution of a test statistic. (May-08-03)
- list7ch3
Programming with subscripted lists, to choose up to 3 variables to add to a regression. To reproduce Levine-Renelt 1992 EBA results. (May-01-03)
- neural
Neural network regression on Stackloss dataset. Logistic function of RHS variables with 2 nodes. (Apr-30-03)
- kerlin
Outline for computing Partially Linear Regression by Robinson. Should be revised to use KERNEL command in TSP 5.0. (Jul-18-02)
- probks2 (F)
Semiparametric Probit (Klein and Spady) on large dataset (2339 obs.). Should revise to use KERNEL command in TSP 5.0. (Apr-12-02)
- probks (F)
Semiparametric Probit (Klein and Spady) on small dataset (32 obs.). (Apr-12-02)
- spline3
Cubic spline with 3 segments. Examples of fitting sin(6x) and log(.1+x). (Mar-22-02)
- splsbic
Cubic spline which chooses the number of segments by minimizing SBIC. Examples of fitting sin(6x) and log(.1+x). (Mar-18-02)
- odr2 (I)
Orthogonal Distance Regression - simpler estimation which avoids the N nuisance parameters. (Feb-27-02)
- glejser
Glesjer and MSS tests for heteroskedasticity in quantile regression. (Apr-25-01)
- gmac2
Chow test with simple heteroskedasticity - MAC2 test from Thursby(1992), Proc example on Grunfeld data (original 12/00, revised 1/01 to add p-value) (Jan-12-01)
- wilcoxon
Wilcoxon signed rank test, with p-value. Nonparametric test for symmetry of a series around a given value. (original: 11/98, corrected 10/00 for rankt and extreme asymmetry) (Oct-13-00)
- signtest
Sign test for median of zero, with exact binomial p-value (Oct-12-00)
- opac (Q)
Ordered Probit with AutoCorrelation-robust SEs (Aug-17-00)
- scls (J)
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, of UTL/ISEG, Lisbon. (original: 4/99, updated 3/00 to cite source of data file). (Mar-28-00)
- winsor
Winsorized residuals, for robust/bounded influence estimation. A simple iterative version. (Dec-06-99)
- ktau
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. (original: 3/96, updated 10/99, added PROC interface to rank correlation procedure with ties correctly handled.) (Oct-14-99)
- changept (T)
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. (Sep-27-99)
- panboot (P)
Panel bootstrapping. Draws residuals within an individual. (Feb-09-99)
- jb
Jarque-Bera normality test, starting from small-sample versions of @SKEW and @KURT stored by MSD. (Sep-04-98)
- student
regression with Student t residuals; see also stacklos example. (May-26-98)
- stacklos
LAD and Student's t residuals on classic Stack Loss dataset (Sep-12-97)
- kercc
gaussian kernel regression - version with kronecker product. Fast and concise but memory intensive - only good for relatively small samples (up to 500 obs?) Also illustrates DOT trick for using GRAPH in a loop with different TITLE strings (up to 8 chars). (Aug-04-97)
- mbbjex3
moving blocks bootstrap (OLS or LAD), by Bernd Fitzenberger. Similar to plain bootstrap, but handles autocorrelation as well as heteroskedasticity. (Jun-17-97)
- kernel
gaussian kernel density estimation and regression, by Joao Santos-Silva (compare with kercc above) (Dec-14-95)
- rankcorr
revised version of old rankcorr example. This one uses the RANK option in the SORT command, instead of defining a separate RANK Proc. See the ktau example for an improved rank correlation, which handles ties correctly. (first version: Jan 93) (Jun-30-95)
- odr (I)
Orthogonal Distance Regression (errors in variables, when ratio of error variances in Ys and Xs is known) (Feb-16-94)
B - Benchmarks - reproducing results
- ar2mlp
regression with AR(2) residual, exact ML estimation. Uses both ML and ML PROC, with the new BJEST option which allows general ARMA residuals. Klein-I consumption function data. (Nov-28-04)
- dw245
Compute DW 5% critical values for n=245, k=2 to 10, using CDF(WTDCHI). (Mar-02-04)
- dw200
Verify DW 5% critical values for n=200, k'=2,3,4, using CDF(WTDCHI). (Mar-02-04)
- dw10
Verify DW critical values for n=10, k'=1, using CDF(WTDCHI). (Mar-02-04)
- kleinf (I)
Pseudo-F test for zero slopes in 2SLS, example using Klein Model I. (Sep-09-02)
- aids (M)
Almost Ideal Demand System, with elasticities, Deaton and Muellbauer model, based on SAS example. (Jun-13-02)
- divzero
reproduces DIVIND calculation with zero quantities. (Mar-05-02)
- kleinphi
reproduces 3SLS @PHI objective function with matrix commands. (Jul-25-01)
- wtdrsq
reproduces @RSQ from a weighted OLS regression, using OLSQ on manually weighted data and MSD. (original: 6/97, updated 12/99 to reproduce R-squared with linear algebra, updated 6/01 for another way to do the calculation) (Jun-12-01)
- ovid (I)
Overidentification tests in 2SLS - examples using Klein I (recently added to TSP 4.5) (Nov-11-00)
- skew
Reproduce Skewness and Kurtosis equations from MSD in manual. (Jun-21-00)
- joh1 (U)
Reproduces Johansen-Juselius cointegration results for Finnish data. (original: 1993, updated: 94, 1/97, 9/99 - added alpha values (speed of adjustment); reproduces more results from the original article) (Sep-30-99)
- condnum (I)
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. (originally written 1/98; revised 3/98 to add comment about condition number of Longley regression; revised 10/98 to use @VCOV, so it can be used after nonlinear estimation) (Oct-30-98)
- jb (R)
Jarque-Bera normality test, starting from small-sample versions of @SKEW and @KURT stored by MSD. (Sep-04-98)
- spatcal (M)
Example of running spatial.tsp on California plant species data. Reproduces results for Spatial AutoCorrelation and Spatial AutoRegression from Upton and Fingleton (1985). (Dec-05-97)
- kleinlmc
Klein-I LIML benchmarks on consumption equation. Reproduces Greene's coefficients, but not his standard errors. Explores alternative standard errors to those produced by the LIML command. (Sep-27-97)
- longley
Longley benchmark with double precision data; compares precision of default orthonormalized regression (11+ digits) with plain (X'X)"(X'Y) regression (7-9 digits) (Aug-12-97)
- prin
reproduces results from PRIN (principal components), via MAT commands (Jun-05-97)
- panhaus
reproduces Hausman test of RE vs. FE in panel data (Feb-13-97)
- dh
reproduces Durbin's h statistic (Feb-11-97)
- ppenders (U)
ppzt on data from 4 countries. Mostly reproduces table on p.263 of Enders, "Applied Economic Time Series", 1995 (Oct-24-96)
I - Miscellaneous
- subsetl
Create all subsets of a list; can be used to run subsets of RHS vars in many different commands. (Jul-11-07)
- interp2
Linear interpolation of missing values - general case (Mar-07-07)
- test_suits
Suits transformation of dummy variables (average effect for first dummy, difference from average for others). By Bronwyn Hall. (Apr-24-06)
- wls_tx04
standard errors for predicted values from WLS (Oct-14-05)
- plotac (T)
Proc which can be called after BJIDENT to print the autocorrelation function (and its 95% bounds) with color graphics. (original 9/96, updated 9/04 to use Bartlett SEs) (Sep-16-04)
- kleinchow
multiequation Chow tests on Klein-I model - parameter stability in SUR and 3SLS using LR and QLR tests. (Sep-07-04)
- pi
Various infinite series for computing pi to arbitrary precision. (May-12-04)
- fisher
Paasche, Laspeyres and Fisher price/quantity indices. Compare with DIVIND command. (original 12/95, updated 4/04 to document plist, qlist) (Apr-26-04)
- wtdsampl
Randomly sample from a vector with non-uniform weights. Similiar to random(draw=). Proc WSM, with example of using it. (original 12/97, updated 9/03 for multiple series). (Sep-19-03)
- lp
Very simple linear programming, using SIML. (Nov-28-02)
- kleinf
Pseudo-F test for zero slopes in 2SLS, example using Klein Model I. (Sep-09-02)
- gini
Gini index (income distribution). (original 11/92, corrected 8/02, added Proc Lorenz to plot Lorenz curve) (Aug-11-02)
- spline3 (R)
Cubic spline with 3 segments. Examples of fitting sin(6x) and log(.1+x). (Mar-22-02)
- splsbic (R)
Cubic spline which chooses the number of segments by minimizing SBIC. Examples of fitting sin(6x) and log(.1+x). (Mar-18-02)
- odr2
Orthogonal Distance Regression - simpler estimation which avoids the N nuisance parameters. (Feb-27-02)
- multinom
draws multinomial r.v.s for user specified probabilities. (Nov-20-02)
- clt
Central Limit Theorem example - convergence of mean of uniform r.v.s to normality. (Nov-08-02)
- dotfile
using DOT loops to construct filename(s). (Oct-08-02)
- omnorm
Omnibus test for multivariate normality. Reproduces results from Doornik and Hansen (1994) for Fisher Iris data. (May-31-01)
- exog
Exogeneity test (Hausman-Wu), and also Breusch-Godfrey LM test for autocorrelation in 2SLS. (Original 12/98, updated 5/01) (May-23-01)
- rantrunc
truncated normal r.v.s via inverted CDF. (Feb-21-01)
- dateloop
looping over a dated sample - simpler than doquart example, and explains 2 methods (Nov-21-00)
- ovid
Overidentification tests in 2SLS - examples using Klein I (recently added to TSP 4.5) (Nov-11-00)
- submat
extract submatrix (Proc), given starting/ending row/column (Oct-13-00)
- coeftab
printing a small table of selected coefs and SEs from a large estimation, by using ANALYZ (Jul-24-00)
- int
Integration using trapezoidal rule approximation in a DO loop. (Jun-26-00)
- gnuplot
gnuplot graphics - .GIF file output only (Mar-05-00)
- gnuploti
gnuplot graphics - X window output (Mar-05-00)
- ss9b
gnuplot graphics - GRAPH of SAMPSEL LogL with multiple local optima. (Mar-05-00)
- ovid
Overidentification test in 2SLS. (Dec-28-00)
- addfac
Add factor forecasting. Uses EQSUB to add the add factor variable to an existing estimated equation. (Jul-13-99)
- addfactor
Estimation and forecasting with an add factor, on the same equation. (The coefficient on the add factor is zero during estimation, and one during forecasting). (May-11-99)
- subsets
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. (Nov-24-98)
- condnum
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. (originally written 1/98; revised 3/98 to add comment about condition number of Longley regression; revised 10/98 to use @VCOV, so it can be used after nonlinear estimation) (Oct-30-98)
- cubic
Equations for real roots of cubic equation, with positive constraints. (Aug-12-98)
- percent
Arbitrary quantiles (such as 5%, 95%), using sort. (Jul-27-98)
- listsort
Creates a LIST (R8 R5 R6 ...) from a vector of integers (8 5 6 ...). (Jul-09-98)
- interp
Linear interpolation of missing values, for very simple case of single isolated missing values. Discusses why this is not a very good idea. (Apr-28-98)
- sbic (V)
Shows 3 different normalizations for SBIC and AIC, and which one TSP 4.4 uses in OLSQ. In TSP 4.5, we switched to using the unnormalized SBIC and AIC. (Feb-19-98)
- tab2
Forms and print 2 x 2 contingency table, with ChiSq(1) test for independence. Inputs are 2 dummy variables. (Oct-16-97)
- tab2t
Examples of calling tab2. (Oct-16-97)
- finance
Financial applications, by Sotiris Staikouras: 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 (Aug-21-97)
- analyzr
using the restricted coefs stored by ANALYZ (May-23-97)
- stack2
Procs which stack 2 matrices (vertically or horizontally) Note: MMAKE will stack (2 or more) matrices horizontally, if they have the same number of rows (they don't have to have the same number of columns). This feature was added to TSP 4.3 on 4/25/95. (Jan-30-97)
- merge
Proc which merges two samples by ID variables (Jul-31-96)
- bandm
creates a banded symmetric matrix from its first column. Outdated - use MFORM(BAND) in TSP 4.4. (Dec-15-95)
- analyzf
computes an F-statistic for testing a group of variables with ANALYZ. Compares with the method of running the restricted regression. Outdated in TSP 4.5; the F-stat is computed automatically when ANALYZ is run after OLSQ with linear restrictions. (Nov-02-95)
- anova
Proc which prints a (formatted) "ANOVA table" after OLS (Oct-26-95)
- probdist
compute various probability distributions and plot them. (Sep-01-95)
- listsave
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. (Aug-04-95)
- sortl
sorts a list of variable names, by the variables' values in a given period. Coding similar to listsave. (Jun-12-95)
- freqsav
a way to save and restore the frequency (for use at start and end of a Proc). Outdated in TSP 4.3 and later, in which the FREQ command can take a variable (with value 0 1 4 12, etc.) as an argument, and @FREQ is stored with just such a value by FREQ. (Apr-24-95)
- ridge
Bayesian mixed estimator (combines prior with estimated coefficients and VCOV), works for non-OLS models. (Jan-11-95)
- delobs
deletes some observations permanently from a dataset (Oct-05-94)
- quintile
sample Quintiles (20%, 40%, ...) via SORT (Aug-04-94)
- gmmvar
VCOV for GMM with non-optimal COVOC (Hansen Theorem 3.1). Outdated in TSP 4.4 and higher, where GMM(NOOPTCOV) is the default. (Jun-08-94)
- doquart
DO loop over time periods with quarterly data (May-12-94)
- odr
Orthogonal Distance Regression (errors in variables, when ratio of error variances in Ys and Xs is known) (Feb-16-94)
- median
median via SORT command. Outdated by MSD(ALL) in 4.2B and higher. (Jan-01-93)
- phichow
Chow test for 2SLS (pseudo-F test for parameter stability, split sample) (Jan-01-93)
- illus41
illustrative model from the manual (slightly dated) (Oct-05-92)
tspex.zip
Download all examples in unix .zip format.
(On PC or Mac, use unzip -a to add proper
end-of-line characters.)
In case you are downloading to a PC, and your
unzip program does not support the -a option
(such as PKUNZIP), here is a freeware unzip which
supports -a:
unzip.zip
(includes both UNZIP.DOC and UNZIP.EXE)
UNZIP.DOC
UNZIP.EXE
This page was created with Fortran.