Latest Examples Sorted by Date

Group codes are given in parentheses. For example, stacklos is in groups (R,M) (Robust and ML). See the list of Group Codes at the bottom of this page.

(Mar-19-07) regma1 (T) Regression with MA(1) residuals.
(Mar-07-07) interp2 (I) Linear interpolation of missing values, general case.
(Mar-07-07) tob2 (J) 2-equation (bivariate) simultaneous Tobit
(Feb-23-07) regarma2 (T,M) regression with ARMA(8,2) errors, exact ML. See also regarma for conditional ML (but more complicated). (ML PROC,BJEST)
(Nov-17-06) hurdle2 (J) Double Hurdle model. Tobit is single hurdle; this is like Tobit with an additional selection equation.
(Apr-24-06) test_suits (I) Suits transformation of dummy variables (average effect for first dummy, difference from average for others). By Bronwyn Hall.
(Apr-13-06) gcoefi (P) Panel OLS model where some coefficients vary by individual, and others do not. Includes a PROC to automate this.
(Mar-12-06) vuongf (R) Vuong test, example with FIML.
(Mar-12-06) vuong (R) Vuong test of non-nested models. Computed from difference in LogL for each observations. Example with OLS.
(Oct-14-05) wls_tx04 (I) standard errors for predicted values from WLS
(Sep-14-05) pstr (P,M) Panel Smooth Transition Regression. 2 regimes. grid search and ML PROC estimation
(Jul-28-05) frontp2 (Q,P) 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.
(Feb-03-05) opdydx (F) dy/dx for Ordered Probit. Computes change in histogram of predicted dependent variable, for changes in a given X variable.
(Dec-03-04) arma41ml (T) regression with ARMA(4,1) residual. exact ML. Sunspot data.
(Dec-03-04) ar1mlp (T) regression with AR(1) residual. Reproduces AR1 command with ML PROC and new BJEST option.
(Nov-28-04) ar2mlp (B,T) 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.
(Oct-29-04) gammas (M) gamma simulation of rainfall model, where trace values below 0.1 are truncated to zero.
(Oct-29-04) gammar (M) gamma estimation of rainfall model. Uses ML PROC and CDF to evaluate igamma() function.
(Oct-19-04) vardif (V) VAR on differenced series, but compute impulse response for original series
(Oct-06-04) pansd (P) computes standard deviation of a panel series within each individual, and stores result as a series
(Sep-16-04) plotac (T,I) Proc which can be called after BJIDENT to print the autocorrelation function (and its 95% bounds) with color graphics. (BJIDENT,GRAPH)
(Sep-07-04) kleinchow (I) multiequation Chow tests on Klein-I model - parameter stability in SUR and 3SLS using LR and QLR tests.
(May-27-04) surar1 (A) nonlinear SUR with AR(1) residuals, different RHO for each equation, conditional or exact ML (LSQ,FIML)
(May-12-04) pi (I) Various infinite series for computing pi to arbitrary precision.
(Apr-26-04) fisher (I) Paasche, Laspeyres and Fisher price/quantity indices. Compare with DIVIND command. (original 12/95, updated 4/04 to document plist, qlist)
(Apr-20-04) dl (T) Approximation to dL (lower critical value for Durbin-Waston, using NOB and K1.
(Apr-13-04) fronte (Q) Efficiency term for Frontier model from Battesse and Coelli (1988). Extends example in TSP User's Guide. (ML)
(Apr-08-04) lad2sk (R) 2-stage LAD estimation of Klein-I consumption equation
(Mar-29-04) msprobit (S,F) Real Markov switching Probit model, by Masahito Kobayashi. (ML PROC)
(Mar-29-04) regime (S) Real Markov switching regression model, by Masahito Kobayashi. (ML PROC)
(Mar-17-04) boxcoxj (M) Jacobian term for testing log vs. level and general Box-Cox model. (FIML)
(Mar-02-04) dw245 (B) Compute DW 5% critical values for n=245, k=2 to 10, using CDF(WTDCHI).
(Mar-02-04) dw200 (B) Verify DW 5% critical values for n=200, k'=2,3,4, using CDF(WTDCHI).
(Mar-02-04) dw10 (B) Verify DW critical values for n=10, k'=1, using CDF(WTDCHI).
(Nov-19-03) ebiprob (F) Bivariate probit where Y2 is not observed unless Y1=1. (ML)
(Nov-19-03) swregun (S) Switching with unknown regime and unknown sample separation, by Augustin de Coulon. (ML)
(Sep-19-03) wtdsampl (I,R) Randomly sample from a vector with non-uniform weights. Similiar to random(draw=). Proc WSM, with example of using it.
(Jun-25-03) hhsim (M) Minimum distance estimation of Hall-Hayashi dynamic factor model. Uses simulated data, a runnable version of the hhex example. by Bronwyn Hall (EQSUB,SUR)
(Jun-23-03) gspd5 (P) Duplicate state variables for each industry.
(Jun-23-03) pdlpanel (P,D) PDL done via the PANEL command. (OLSQ,PANEL,ANALYZ)
(May-14-03) regarma (T,M) 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.
(May-08-03) wild (R) Wild bootstrap, used to approximate the distribution of a test statistic. (RANDOM)
(May-01-03) list7ch3 (R) Programming with subscripted lists, to choose up to 3 variables to add to a regression. To reproduce Levine-Renelt 1992 EBA results. (LIST)
(Apr-30-03) neural (R) Neural network regression on Stackloss dataset. Logistic function of RHS variables with 2 nodes. (LSQ)
(Nov-28-02) lp (I) Very simple linear programming, using SIML. Outdated by LP command in TSP 5.0.
(Nov-12-02) usbalme (G) Panel GMM with measurement errors
(Oct-28-02) archdiag (H) Diagnostic tests for asymmetry of ARCH residuals.
(Oct-26-02) bkf (T) Baxter-King filter.
(Sep-09-02) kleinf (I,B) Reproduces pseudo-F test for zero slopes in 2SLS, example using Klein Model I.
(Aug-11-02) gini (I) Gini index (income distribution).
(Jul-18-02) kerlin (R) Outline for computing Partially Linear Regression by Robinson. Should be revised to use KERNEL command in TSP 5.0.
(Jul-09-02) vratio2 (U) Revised code for vratio, with changed commands noted by question marks. The changes need to be checked against the original reference, and then merged with the main vratio example.
(Jun-19-02) tobr2 (J) R-squared for Tobit model, one possible formulation. (TOBIT)
(Jun-13-02) aids (M,B) Almost Ideal Demand System, with elasticities, Deaton and Muellbauer model, based on SAS example. (LSQ,EQSUB,ANALYZ)
(Jun-12-02) dwnl (T) Approximate P-value for Durbin-Watson in nonlinear model, using regression on first derivatives. (LSQ,DIFFER,REGOPT)
(May-22-02) tobpred (J) Predictions from Tobit model, conditional and unconditional. (TOBIT,GENR)
(Apr-12-02) probks2 (F,R) Semiparametric Probit (Klein and Spady) on large dataset (2339 obs.). Should revise to use KERNEL command in TSP 5.0. Matrix version.
(Apr-12-02) probks (F,R) Semiparametric Probit (Klein and Spady) on small dataset (32 obs.). DO loop version.
(Apr-10-02) dpdx3 (L) Mean and variance of dP/dX for Logit with 3 choices.
(Apr-05-02) lnormdl (D) Distributed lag with shape from lognormal density. (LSQ,GRAPH)
(Apr-05-02) gammadl (D) Distributed lag with shape from gamma density. (LSQ,GRAPH)
(Apr-05-02) adfbrk (U) ADF tests with trend breakpoints.
(Mar-22-02) spline3 (R,I) Cubic spline with 3 segments. Examples of fitting sin(6x) and log(.1+x). (LSQ,GRAPH)
(Mar-18-02) splsbic (R,I) Cubic spline which chooses the number of segments by minimizing SBIC. Examples of fitting sin(6x) and log(.1+x). (OLSQ,GRAPH)
(Mar-07-02) gir2 (V) Generalized Impulse Response, via LSQ and SOLVE. (extendable to structural VAR)
(Mar-05-02) divzero (B) reproduces DIVIND calculation with zero quantities.
(Feb-27-02) odr2 (I,R) Orthogonal Distance Regression - simpler estimation which avoids the N nuisance parameters. (ML)
(Feb-20-02) arelbon2 (G) Arellano-Bond example with 3 RHS variables.
(Feb-15-02) varira (V) Impulse Response SEs via ANALYZ. Hardcoded example for 3 equations, 4 lags, 6 periods.
(Dec-14-02) logitbc (L) Logit with approximate Bias Correction.
(Nov-29-02) formar1 (A) FRML with exact ML first observation for LSQ; includes Jacobian trick so that FIML is not needed.
(Nov-20-02) multinom (I) draws multinomial r.v.s for user specified probabilities. by Bronwyn Hall
(Nov-13-02) pr2 (F,L) McFadden's pseudo R-squared for Probit/Logit. In TSP 4.4 as "Kullback-Leibler R-squared" (@KLRSQ). Outdated by LOGIT in TSP 4.5, which stores Estrella's "Scaled R-squared".
(Nov-08-02) clt (I) Central Limit Theorem example - convergence of mean of uniform r.v.s to normality. (RANDOM,MSD,HIST)
(Oct-08-02) dotfile (I) using DOT loops to construct filename(s). Double DOTs to concatenate strings.
(Sep-18-02) feihat (P) hat matrix (leverage) for fixed effects model.
(Sep-25-01) bilin2 (T) second order bilinear model, by Wiedyo Pura Buana
(Aug-27-01) mnestlog2 (L) 2-level nested multinomial logit.
(Aug-27-01) nestlog2 (L) 2-level nested conditional logit.
(Aug-27-01) tobithet (J,F) Tobit and Probit, when heteroskedasticity is a function of variables. (ML)
(Aug-09-01) op3 (F) Ordered Probit - examines changes in Y for changes in a dummy variable. Example with 3 choices. (ORDPROB)
(Jul-25-01) kleinphi (B) reproduces 3SLS @PHI objective function with matrix commands.
(Jun-28-01) opfp (F) Ordered Probit forecasted probabilities. (ORDPROB)
(Jun-22-01) ar1w (A) weighted AR1 estimation via ML in TSP 4.5
(Jun-12-01) wtdrsq (B) reproduces @RSQ from a weighted OLS regression, using OLSQ on manually weighted data and MSD. (CORR,MATRIX)
(Jun-12-01) ar1fse (A) AR1 forecast standard errors, via ANALYZ.
(May-31-01) omnorm (I) Omnibus test for multivariate normality. Reproduces results from Doornik and Hansen (1994) for Fisher Iris data. (MATRIX)
(May-25-01) star (A,T) Smooth Transition AutoRegressive models. (FORM,EQSUB,LSQ)
(May-23-01) exog (I) Exogeneity test (Hausman-Wu), and also Breusch-Godfrey LM test for autocorrelation in 2SLS.
(Apr-25-01) glejser (R) Glejser and MSS tests for heteroskedasticity in quantile regression. by Bronwyn Hall (LAD)
(Apr-20-01) nestl (L) nested logit example from TSP User's Guide. Shows relation to mixed logit model.
(Apr-10-01) panrw (P) simulates Panel Random Walk with drift. (RANDOM)
(Apr-09-01) phe (F) Bivariate Probit with Hermite quadrature. Compared with random effects Probit model, and regular CNORM2() version.
(Apr-04-01) spatial (M) Proc which estimates Spatial Autocorrelation and Spatial Autoregressive models. User supplies W = spatial proximity weight matrix. (ML PROC,MATRIX)
(Mar-20-01) gir (V) Generalized Impulse Response - invariant to equation order. Reproduces results in Pesaran and Shin (1998) with KPSW data. (VAR,GRAPH)
(Feb-21-01) rantrunc (I) truncated normal r.v.s via inverted CDF.
(Feb-02-01) koyck2 (D,P) koyckp example applied to a different dataset. (LSQ,EQSUB)
(Feb-01-01) fixedse (P) standard errors for the intercept terms in a fixed effects model (balanced or unbalanced). Outdated by PANEL(FEPRINT) in TSP 5.0.
(Jan-26-01) kleinfe (P,E) 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. Outdated in TSP 5.0 by 2SLS(FEI), 3SLS(FEI).
(Jan-26-01) hetprob (F) LM test for heteroskedasticity in Probit. Follows Godfrey's book.
(Jan-25-01) frontp1 (Q,P) Frontier production function, unbalanced panel, error components, v_it - u_i. Follows Battese and Coelli, 1992. See frontp2 for a simpler version. (ML)
(Jan-24-01) koyckp (D,P) Koyck (geometric) distributed lag, with truncation terms for finite sample panel or time series. Example on Almon data. (LSQ,EQSUB)
(Jan-17-01) reub (E) Random Effects on UnBalanced data - ML estimation of one-way model. Written as a PROC, where you just supply a list of RHS variables. Outdated in TSP 5.0 by PANEL(REI).
(Jan-17-01) reubab (E) example of using the REUB Proc, on the Arellano-Bond model.
(Jan-12-01) gmac2 (R) Chow test with simple heteroskedasticity - MAC2 test from Thursby(1992), Proc example on Grunfeld data. Outdated by REGOPT CHOWHET in TSP 5.0.
(Jan-12-01) op1r1 (Q,F) 2 eqns: Ordered Probit (3 choices) and Regression / sample selection (ML)
(Jan-11-01) p1op1 (F,Q) 2 eqns: Probit and Ordered Probit, correlated, by Bronwyn Hall (ML)
(Dec-16-00) p1r2n (Q,F) 3 eqns: Probit and 2 Regression - non-selection, with simultaneity in Probit eqn (ML)
(Dec-16-00) p1r2s (Q,F) 3 eqns: Probit and 2 Regression - selection model (ML)
(Nov-30-00) biprob (F,Q) 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)
(Nov-21-00) dateloop (I,T) looping over a dated sample - simpler than doquart example, and explains 2 methods (DO,SELECT,SMPL)
(Nov-21-00) timediff (P) time dummies in first differenced equations (when differencing to remove individual effects)
(Nov-11-00) ovid (I,B) Overidentification tests in 2SLS - examples using Klein I (recently added to TSP 4.5)
(Nov-07-00) varmc (V) 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.
(Oct-13-00) submat (I) extract submatrix (Proc), given starting/ending row/column
(Oct-13-00) wilcoxon (R) Wilcoxon signed rank test, with p-value. Nonparametric test for symmetry of a series around a given value.
(Oct-12-00) signtest (R) Sign test for median of zero, with exact binomial p-value
(Sep-11-00) hamsimp (S) Markov chain model - simple 2-regime from Hamilton's book, via EM. By David Bivin
(Aug-17-00) opac (Q,R) Ordered Probit with AutoCorrelation-robust SEs (ORDPROB,DIFFER,GMM)
(Jul-24-00) coeftab (I) printing a small table of selected coefs and SEs from a large estimation, by using ANALYZ
(Jul-12-00) probitfe (P,F) Probit fixed effects - efficient iteration for large N. Outdated by PROBIT(FEI) in TSP 5.0.
(Jun-26-00) int (I) Integration using trapezoidal rule approximation in a DO loop.
(Jun-23-00) diaghet (P) Diagonal heteroskedasticity model (like SUR, but no off-diagonal terms); can be useful when N > T.
(Jun-21-00) skew (B) Reproduce Skewness and Kurtosis equations from MSD in manual.
(Jun-16-00) panw (P) Weighted fixed effects estimation.
(May-04-00) gapubal (G) Setting up a gapped SMPL for unbalanced stacked panel data, so that GMM(NMA=k) can be used.
(Apr-28-00) adfgls (U) GLS version of ADF unit root test with p-value (Elliott, Rothenberg, Stock (1992,1996)), by Yin-Wong Cheung.
(Mar-28-00) scls (J,R) 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.
(Mar-24-00) vratio (U) Variance ratio test for unit root. See vratio2 also.
(Mar-05-00) gnuplot (I) gnuplot graphics - .GIF file output only, unix versions. (PLOT,GRAPH)
(Mar-05-00) gnuploti (I) gnuplot graphics - X window output, unix versions. (PLOT,GRAPH)
(Mar-05-00) ss9b (I) gnuplot graphics - GRAPH of SAMPSEL LogL with multiple local optima.
(Feb-28-00) calendar (T) 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.
(Feb-07-00) panmeans (P) Removing individual or time means.
(Jan-05-00) cointarp (U) Cointegration test with AR(p) residuals - Stock-Watson(1993) and Phillips-Loretan(1991, p.424).
(Jan-03-00) biquad (M) Bivariate normal cdf - how to evaluate probabilities in all 4 quadrants, by changing signs of the arguments to CNORM2(z1,z2,rho).
(Dec-28-00) ovid (I) Computes several overidentification and pseudo-F tests in 2SLS. by Clint Cummins and Bronwyn Hall
(Dec-06-99) winsor (R) Winsorized residuals, and iterative M-estimation. A simple iterative version.
(Nov-16-99) igarch (H) Integrated GARCH(1,1), with constraint that alpha1+beta1=1.
(Nov-12-99) probitre (E,F) 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.
(Nov-09-99) markovrt (T,S) 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. (ML)
(Nov-02-99) g4 (E) 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. Outdated in TSP 5.0 by PANEL(REI,REIT).
(Oct-26-99) count (Q) 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)
(Oct-22-99) pansmpl (P) 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-14-99) ktau (R) 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.
(Oct-06-99) probder (F) 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) boxtid0 (M) Box-Tidwell regression when the RHS variables are sometimes zero. (LSQ)
(Sep-30-99) joh1 (U,B) Reproduces Johansen-Juselius cointegration results for Finnish data. Originally by David Cushman. (VAR,MATRIX)
(Sep-30-99) archf (H) ARCH forecasting for H_t. Revised slightly for TSP 4.5, where ARCH no longer estimates H(0) by default.
(Sep-27-99) changept (T,R) 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-07-99) logitlim (L) 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 (L) Logit - conditional, with shares as dependent variable, unbalanced data. Data has been "balanced" by running balu first.
(Sep-07-99) balu (P) Panel - "balances" unbalanced data by adding artificial observations with zeros for all variables.
(Aug-15-99) sbicpan (P) 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. Outdated by PANEL in TSP 5.0.
(Aug-14-99) bernanke (V) 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.
(Aug-12-99) ah (P) Anderson-Hsiao 2SLS for dynamic panel model (avoids finite sample bias in fixed effects estimator).
(Aug-03-99) rpl (L,M) Random Parameters (coefficients) Logit. Example with a fixed intercept and one additional RHS variable with a normally distributed random coefficient. (ML PROC)
(Jul-15-99) fixedubmv (P) How to convert PANEL's @FIXED matrix to a series, for the most general case, when the data is unbalanced and has missing values. Outdated by PANEL, which stores the series @AI in TSP 5.0.
(Jul-13-99) addfac (I) Add factor forecasting. Uses EQSUB to add the add factor variable to an existing estimated equation. (OLSQ,FORM,GENR)
(Jun-11-99) swprob (F,S) 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. (ML)
(Jun-11-99) swreg (S) Switching regression, regime unknown. Follows Maddala(1983), p.283. (ML)
(Jun-09-99) panchow (P) Chow test for panel data, within model, where both the coefficients and fixed effects vary across 2 periods.
(May-27-99) gmmns (U) GMM on non-stationary data. Follows Hamilton(1994), p.424 / Ogaki(1993). Estimates model as a function of detrended variables.
(May-11-99) panunit (U,P) 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.
(May-11-99) addfactor (I) 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). (LSQ,SIML)
(Mar-23-99) ssg1g (Q) sample selection model - demonstrates multiple local optima with grid search, following Nawata(1995). Graphs LogL vs. RHO. Outdated by SAMPSEL with automated grid search in TSP 4.5. (SAMPSEL,ML)
(Mar-01-99) tnp (F) 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.
(Mar-01-99) ar1fmlp (T,P) AR(1) (exact ML) for panel data, using the FIML command. Reproduces AR1(TSCS) results. Should be revised to use NODROPMISS option.
(Feb-23-99) egarch11 (H) EGARCH(1,1) estimation. Exponential GARCH, where log(h(t)) = alpha0 + alpha1*abs(e(t-1)) + beta1*log(h(t-1)).
(Feb-09-99) panboot (P,R) Panel bootstrapping. Draws residuals within an individual.
(Feb-04-99) ec3sls (E) 3SLS with 2-way error components, balanced panel. Uses transformed data with 3SLS commands. Much faster than old matrix versions.
(Feb-04-99) ec2sls (E) 2SLS with 2-way error components, balanced panel. Uses transformed data with 2SLS commands. Much faster than old matrix versions.
(Feb-04-99) ec3sm1 (E) 3SLS with 2-way error components, balanced panel, Old matrix version.
(Feb-04-99) ec2sm3 (E) 2SLS with 2-way error components, balanced panel, 3rd Matrix version.
(Jan-06-99) expsm2 (T,M) Double exponential smoothing with arbitrary smoothing parameter. Compares with ARIMA(0,2,2) model. (MODEL,SOLVE,BJEST)
(Nov-24-98) subsets (I) 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.
(May-16-98) fixediv (P) 2SLS with fixed effects. Efficient computation, by using PANEL in 2 stages. See kleinfe for an improved method. Outdated by 2SLS(FEI) in TSP 5.0.
(Nov-13-98) varst32 (V) Uses BJEST to check polynomial roots for stationarity of a VAR (3 variables, 2 lags). See varst21 for simpler version.
(Nov-03-98) ar1fml (A,M) AR(1) exact ML with the FIML and ML commands. Should be revised to use NODROPMISS option.
(Oct-30-98) condnum (I,B) 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.
(Oct-26-98) varbq (V) 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-02-98) shinfull (U) 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. (BJEST)
(Oct-02-98) sft (U) Tests shinfull on artificial data. Test P-values against published table of critical values. (RANDOM)
(Sep-11-98) kald (K) 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-04-98) jb (R,B) Reproduces Jarque-Bera normality test, starting from small-sample versions of @SKEW and @KURT stored by MSD.
(Aug-12-98) cubic (I) Equations for real roots of cubic equation. Also demonstrates imposing various constraints. (EQSUB,LSQ)
(Jul-28-98) boxcoxar (M,A) Box-Cox with AR(1) residual. Should be revised to use NODROPMISS option. (FIML)
(Jul-27-98) percent (I) Arbitrary quantiles (such as 5%, 95%), using sort.
(Jul-24-98) tob2lim (J) 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. Outdated by TOBIT(LOWER=,UPPER=) in TSP 5.0. (ML)
(Jul-09-98) listsort (I) Creates a LIST (R8 R5 R6 ...) from a vector of integers (8 5 6 ...).
(Jun-11-98) varsiml (V) Use SIML to create impulse responses, after a VAR command.
(Jun-11-98) varforc (V) Static forecast after VAR. Outdated by FORCST in TSP 4.5.
(Jun-11-98) nbsim (Q) Using RANDOM(NEGBIN) when the mean is different for each observation. Outdated by RANDOM(NEGBIN,MEAN=series) in TSP 5.0.
(May-29-98) boxcox0 (M) Box-Cox transformation when Y is zero
(May-26-98) student (R,M) regression with Student t residuals; see also stacklos example.
(May-05-98) probitac (F,G) Probit with SEs robust to autocorrelation (PROBIT,GMM).
(Apr-29-98) ar1hetub (P) version of ar1het for unbalanced data (Kmenta's GLS model using transformed data)
(Apr-28-98) interp (I) Linear interpolation of missing values, for very simple case of single isolated missing values. Discusses why this is not a very good idea. See interp2 for general case.
(Apr-17-98) arelbond (G) Simple Arellano-Bond example, 1-step and 2-step estimators (balanced panel data). Uses very simple artificial data.
(Apr-13-98) kalmanhp (K,M) Kalman filter HyperParameter estimation, using ML PROC. Estimates 2 variance parameters in the transition equation.
(Mar-11-98) rancoef (M) ML estimation of a regression with a single random coefficient. Outlines how to extend to multiple random coefficients.
(Feb-25-98) logitsh (L) Logit with shares as dependent variables. Was previously corrupted on examples disk and web page. (ML)
(Feb-19-98) sbic (V,I) 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-06-98) logitshp (L,P) 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). (ML)
(Dec-17-97) cov1step (G) Arellano-Bond 1-step COVOC matrix - GMM/panel
(Dec-05-97) spatcal (M,B) Example of running spatial.tsp on California plant species data. Reproduces results for Spatial AutoCorrelation and Spatial AutoRegression from Upton and Fingleton (1985).
(Dec-04-97) olsme (M) 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.
(Nov-26-97) unbalsu4 (M,P) (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) p3s (E) Example of using ec3sm1 on a real model (data files are not included).
(Nov-21-97) ar1het (P) 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-18-97) ec2sm1 (E) First matrix algebra version of ec2sls. Does not use transformed data. Notation differs a bit from Hsiao(1986).
(Nov-18-97) ec2sm2 (E) Second matrix algebra version of ec2sls. Uses transformed data; notation is close to Hsiao(1986).
(Nov-11-97) firstdif (G) Automates creation of first-differenced variables for GMM panel models, where the variables are named by time period, like y1 y2 y3, etc. (DOT)
(Oct-21-97) hptrend44 (T) 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. (MFORM,MATRIX)
(Oct-16-97) tab2 (I) Forms and print 2 x 2 contingency table (crosstab), with ChiSq(1) test for independence. Inputs are 2 dummy variables.
(Oct-16-97) tab2t (I) Examples of calling tab2.
(Oct-08-97) lm2test (G) like Arellano-Bond m2 statistic, tests AR(1) and AR(2), by Bronwyn Hall.
(Oct-08-97) lm2test2 (G) Alternative version of lm2test, using explicit lags. Unfortunately, it seems to be about 20% slower than lm2test.
(Sep-27-97) kleinlmc (B) 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-25-97) varsbici (V) Chooses optimal lag orders for VAR by minimizing @SBIC. Allows for different lags on different variables. Example with just 2 variables.
(Sep-18-97) cov2step (G) Arellano-Bond 2-step COVOC matrix - GMM/panel
(Sep-16-97) diseq104 (S) Disequilibrium model, with sample separation known. Section 10.4 of Maddala(1983), p.307-309. (LSQ)
(Sep-12-97) stacklos (R,M) LAD and Student's t residuals on classic Stack Loss dataset (LAD,ML)
(Sep-11-97) h3b (E) Hsiao(1986)'s Appendix 3B - verifies 2-way EC Omega inverse (MATRIX)
(Sep-11-97) varsbic (V) chooses optimal lag order for VAR by minimizing @SBIC
(Aug-21-97) finance (I) 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
(Aug-12-97) longley (B) 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-04-97) premaskg (G) creates mask for GMM with panel data
(Aug-04-97) premaskc (G) 2 examples of calling premaskg
(Aug-04-97) kercc (R) 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). Outdated by KERNEL in TSP 5.0.
(Jul-21-97) fiml5 (M) FIML via ML with 5 equations (like fiml4 and fiml11)
(Jul-11-97) pdlar (D,A) single PDL variable with AR(p) residuals (FORM,EQSUB,LSQ,ANALYZ)
(Jun-20-97) qtomw (T) Quarterly to Monthly conversion, using ratio to average, and weights (sum and average versions).
(Jun-20-97) qtomw2 (T) Examples of calling qtomw, converting forecasts from quarterly model into monthly forecasts.
(Jun-20-97) logitfe3 (L,P) fixed effects logit for panel data with 3 time periods (choice taken 1 or 2 times). Follows Hsiao(1986), p.162. (ML)
(Jun-17-97) mbbjex3 (R) moving blocks bootstrap (examples with OLS and LAD). Similar to plain bootstrap, but handles autocorrelation as well as heteroskedasticity. by Bernd Fitzenberger
(Jun-13-97) pdlar2 (D,A) example of calling pdlar
(Jun-12-97) garcia (P,M) Growth model, stochastic differential equations, unbalanced panel. Uses recursive EQSUB. This nonlinear panel growth model is used on tree heights. (ML)
(Jun-12-97) pdlar243 (D,A) example of using pdlar43 (calls pdlar43)
(Jun-12-97) pdlar43 (D,A) older version of pdlar, using TSP 4.3 commands
(Jun-05-97) prin (B) reproduces results from PRIN (principal components), with MATRIX commands
(May-23-97) analyzr (I) using the restricted coefs stored by ANALYZ
(May-20-97) apd (E) creates artificial panel data. balanced, one-way random effects, 2 Xs correlated with random effects (RANDOM)
(Apr-22-97) ml2stage (M) 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. (ML,DIFFER,MATRIX)
(Apr-02-97) tobrncf (J) Tobit with random coefficients, Ionnatos, JBES July 1995 (ML)
(Apr-01-97) testnlog (L) 2 level (5 x 10) nested logit, with artificial test data, by Bronwyn Hall
(Feb-25-97) ma (T) simple Proc to calculate moving average of length n
(Feb-21-97) gapbal (T) creates gapped smpl for balanced AR1(TSCS). Outdated by FREQ(PANEL) in TSP 4.4.
(Feb-13-97) panhaus (B,P) reproduces Hausman test of RE vs. FE in panel data (ANALYZ,MATRIX)
(Feb-11-97) dh (B,T) reproduces Durbin's h statistic
(Feb-05-97) ar4nl (A) AR(4) on single nonlinear equation (conditional ML) (EQSUB,LSQ)
(Jan-30-97) stack2 (I) Procs which stack 2 matrices (vertically or horizontally). Outdated by MMAKE in TSP 4.4 (for stacking 2 or more matrices horizontally).
(Dec-18-96) ub2wfere (E) 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. 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.
(Dec-18-96) data2way (E) generates artificial data for 2-way model (RANDOM)
(Dec-18-96) bal2wfe (P) balanced 2-way fixed effects
(Dec-02-96) unbalsu1 (M) unbalanced SUR -- 2 equations; some observations missing for the second equation. ML version only (easiest way to get estimates and proper standard errors). (ML)
(Nov-11-96) switch (S) Disequilibrium / switching regression model from 4.3 User's Guide, by Bronwyn Hall. Maddala p.298 (ML)
(Oct-31-96) wclogit (L) weighted conditional logit. (ML)
(Oct-24-96) ppmex (U) Phillips-Perron "z hat sub t" unit root test on Mexican data.
(Oct-24-96) ppenders (U,B) ppzt on data from 4 countries. Mostly reproduces table on p.263 of Enders, "Applied Economic Time Series", 1995
(Oct-24-96) ppzt (U) 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.
(Sep-25-96) logitmix (L) mixed logit via ML command; a standard TSP testrun
(Sep-12-96) logiteach (L) data setup code for conditional logit, where each alternative is chosen exactly once.
(Sep-05-96) kfllt (K) Kalman Filter on Local Linear Trend - Harvey(1989), p.170
(Jul-31-96) merge (I) Proc which merges two samples by ID variables
(Jul-22-96) kfarma11 (K) Evaluation of conditional likelihood function for ARMA(1,1) via the KALMAN command.
(Jul-18-96) kfma1 (K) Ditto, but for MA(1) model. Harvey, TSM, 1981, p.103
(Jun-21-96) kfloop2 (K) 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 (K) Kalman filter in a DO loop, to compute SEs for state vector at each period. 1 parameter in state vector, with user-supplied prior.
(May-23-96) grid (M) 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 (DO,RANDOM)
(May-20-96) logitf (L) forecasts from a multinomial logit model (picks most likely Y value for a set of X values). not tested. (LIST, DOT)
(May-16-96) coxpanel (P,Q) ML estimation of Cox proportional hazards model, balanced data example with 3 time periods. Uses lagged EQSUB feature.
(Mar-29-96) kwunit2 (U) 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-07-96) kfml (K,M) estimates Kalman Filter transition matrix via grid search (2 parameters). Compare with kalmanhp above.
(Feb-27-96) mask2 (G) 2 different ways to set up a large sparse MASK matrix for use in GMM (different instruments in different equations).
(Feb-13-96) tobendog (J) 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.
(Jan-30-96) bilinear (T,M) ML estimation of simple bilinear time series model. Uses recursive derivative code; could be made simpler with ML PROC.
(Jan-08-96) kwunit (U) KPSS unit root test, where stationarity is the null. Revised version - handles data of any frequency - uses current SMPL to determine range of data
(Dec-22-95) fiml11 (M) 11-equation FIML estimation, via the ML command. Just an extension of the old fiml4 example. (ML)
(Dec-15-95) unbalml (M) slightly more complicated version of unbalsu1. Probably not needed.
(Dec-15-95) bandm (I) creates a banded symmetric matrix from its first column. Outdated by MFORM(BAND) in TSP 4.4.
(Dec-14-95) kernel (R) gaussian kernel density estimation and regression, by Joao Santos-Silva (compare with kercc above). Outdated by KERNEL in TSP 5.0.
(Nov-13-95) varst21 (V) same as varst32, but 2 variables with 1 lag (much easier to read and understand)
(Nov-02-95) analyzf (I) computes an F-statistic for testing a group of variables with ANALYZ. Compares with the method of running the restricted regression. Outdated by ANALYZ in TSP 4.5.
(Oct-26-95) anova (I) Proc which prints a (formatted) "ANOVA table" after OLS
(Sep-01-95) probdist (I) compute various probability distributions and plot them. by Bronwyn Hall
(Aug-10-95) unbalsur (M) 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. (LSQ,ML)
(Aug-04-95) listsave (I) 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.
(Jun-30-95) rankcorr (R) 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.
(Jun-21-95) ar1tscs (T) easy way of creating the gapped SMPL for AR1(TSCS), from an ID variable, for balanced or unbalanced data. Outdated by FREQ(PANEL) in TSP 4.4.
(Jun-12-95) sortl (I) sorts a list of variable names, by the variables' values in a given period. Coding similar to listsave.
(Apr-24-95) freqsav (I) a way to save and restore the frequency (for use at start and end of a Proc). Outdated by FREQ and @FREQ in TSP 4.3.
(Jan-11-95) ridge (I) Bayesian mixed estimator (combines prior with estimated coefficients and VCOV), works for non-OLS models.
(Dec-06-94) nest31 (L) improved version of NEST3, can be changed for diff. model, by Paul Ruud (ML)
(Nov-30-94) nest3 (L) 3-level nested logit (see nest31 for improved version) (ML)
(Nov-16-94) bivord (Q) Bivariate Ordered Probit (without data). Could be improved in TSP 4.5 and higher by using CNORM(z1,z2,rho) function.
(Oct-05-94) delobs (I) deletes some observations permanently from a dataset
(Aug-04-94) quintile (I) sample Quintiles (20%, 40%, ...) via SORT. Similar to percent example.
(Jun-08-94) gmmvar (I) VCOV for GMM with non-optimal COVOC (Hansen Theorem 3.1). Outdated by GMM(NOOPTCOV) in TSP 4.4.
(Jun-02-94) dpdx (L) standard errors for @DPDX from Logit. ANALYZ can also do this.
(May-12-94) doquart (I,T) 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.
(Feb-16-94) odr (I,R) Orthogonal Distance Regression (errors in variables, when ratio of error variances in Ys and Xs is known). (FORM,EQSUB,ML)
(Dec-01-93) fiml4 (M) 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. Part of the original motivation for this was to have HITER=N and HCOV=N for a FIML model. In TSP 5.0, FIML(HITER=C,HCOV=C) is a convenient and accurate approximation to HITER=N,HCOV=N.
(Nov-05-93) nlogit (L) 2-level nested logit (ML)
(Aug-24-93) cn4 (Q) 4-dimensional cumulative normal integral, approximated with many random draws, CNORM(), CNORMI(), and Cholesky factorization.
(Apr-01-93) bivar (Q) approximation for Bivariate normal CDF in ML. Outdated by CNORM(z1,z2,rho) in TSP 4.5.
(Jan-01-93) median (I) median via SORT command. Outdated by MSD(ALL) in TSP 4.2B.
(Jan-01-93) phichow (I) Chow test for 2SLS (pseudo-F test for parameter stability, split sample)
(Jan-01-93) hazard (Q) log-linear hazard function with one time-varying covariate
(Dec-03-92) samsel2 (Q) sample selection with 2 selection equations (undocumented)
(Nov-06-92) tob2sur (J) 2-equation Tobit, but with no RHS endogenous variables
(Oct-05-92) illus41 (I) illustrative model from the TSP 4.2 manual (AR1,2SLS,LIML,LSQ,FIML,ANALYZ,SIML)

Group Codes

A - Autoregressive residuals with LSQ (nonlinear/multiequation)
B - Benchmarks - reproducing results
D - Distributed Lags (including PDL)
E - Panel - Error Components models
F - Probit models
G - Panel - GMM models
H - GARCH models
I - Miscellaneous
J - Tobit models
K - Kalman filter
L - Logit models
M - ML and ML PROC, and general nonlinear estimation
P - Panel - other than GMM and Error Components
Q - QDV - Qualitative Dependent Variables (other than above)
R - Robust (resistant to outliers or heteroskedasticity) and non-parametric
S - Switching regression models
T - Time series (miscellaneous)
U - Unit root and cointegration
V - VAR - Vector AutoRegression

tspex.zip Download all examples in unix .zip format. (On PC or Mac, use unzip -a to add proper end-of-line characters.)