J Nov 17 06 hurdle2 Double Hurdle model. Tobit is single hurdle; this is like Tobit with and additional selection equation . I Apr 24 06 test_suits Suits transformation of dummy variables (average effect for first dummy, difference from average for others). By Bronwyn Hall. P Apr 13 06 gcoefi Panel OLS model where some coefficients vary by individual, and others do not. Includes a PROC to automate this. R Mar 12 06 vuongf Vuong test, example with FIML. R Mar 12 06 vuong Vuong test of non-nested models. Computed from difference in LogL for each observations. Example with OLS. I Oct 14 05 wls_tx04 standard errors for predicted values from WLS PM Sep 14 05 pstr Panel Smooth Transition Regression. 2 regimes. grid search and ML PROC estimation QP Jul 28 05 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) F Feb 3 05 opdydx dy/dx for Ordered Probit. Computes change in histogram of predicted dependent variable, for changes in a given X variable. T Dec 3 04 arma41ml regression with ARMA(4,1) residual. exact ML. Sunspot data. T Dec 3 04 ar1mlp regression with AR(1) residual. Reproduces AR1 command with ML PROC and new BJEST option. BT Nov 28 04 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. M Oct 29 04 gammas gamma simulation of rainfall model, where trace values below 0.1 are truncated to zero. M Oct 29 04 gammar gamma estimation of rainfall model. Uses ML PROC and CDF to evaluate igamma() function. V Oct 19 04 vardif VAR on differenced series, but compute impulse response for original series P Oct 6 04 pansd computes standard deviation of a panel series within each individual, and stores result as a series TI Sep 16 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) I Sep 7 04 kleinchow multiequation Chow tests on Klein-I model - parameter stability in SUR and 3SLS using LR and QLR tests. A May 27 04 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) I May 12 04 pi Various infinite series for computing pi to arbitrary precision. I Apr 26 04 fisher Paasche, Laspeyres and Fisher price/quantity indices. Compare with DIVIND command. (original 12/95, updated 4/04 to document plist, qlist) T Apr 20 04 dl Approximation to dL (lower critical value for Durbin-Waston, using NOB and K1. Q Apr 13 04 fronte Efficiency term for Frontier model from Battesse and Coelli (1988) (original 3/02, updated 4/04) R Apr 8 04 lad2sk 2-stage LAD estimation of Klein-I consumption equation SF Mar 29 04 msprobit Real Markov switching Probit model, by Masahito Kobayashi. S Mar 29 04 regime Real Markov switching regression model, by Masahito Kobayashi. M Mar 17 04 boxcoxj Jacobian term for testing log vs. level and general Box-Cox model. B Mar 2 04 dw245 Compute DW 5% critical values for n=245, k=2 to 10, using CDF(WTDCHI). B Mar 2 04 dw200 Verify DW 5% critical values for n=200, k'=2,3,4, using CDF(WTDCHI). B Mar 2 04 dw10 Verify DW critical values for n=10, k'=1, using CDF(WTDCHI). F Nov 19 03 ebiprob Bivariate probit where Y2 is not observed unless Y1=1. Artificial data. S Nov 19 03 swregun Switching with unknown regime and unknown sample separation, by Augustin de Coulon. IR Sep 19 03 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). M Jun 25 03 hhsim Minimum distance estimation of Hall-Hayashi dynamic factor model. Uses simulated data, a runnable version of the hhex example. P Jun 23 03 gspd5 Duplicate state variables for each industry. (original 1/94, updated 6/03 to remove unavailable data files) PD Jun 23 03 pdlpanel PDL done via the PANEL command. (original 9/94, updated 6/03 to use FREQ(PANEL) ). TM May 14 03 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) R May 8 03 wild Wild bootstrap, used to approximate the distribution of a test statistic. R May 1 03 list7ch3 Programming with subscripted lists, to choose up to 3 variables to add to a regression. To reproduce Levine-Renelt 1992 EBA results. R Apr 30 03 neural Neural network regression on Stackloss dataset. Logistic function of RHS variables with 2 nodes. I Nov 28 02 lp Very simple linear programming, using SIML. G Nov 12 02 usbalme Panel GMM with measurement errors (original 3/93, corrected MASK for second model, correct comments 11/02) H Oct 28 02 archdiag Diagnostic tests for asymmetry of ARCH residuals. T Oct 26 02 bkf Baxter-King filter. (original 5/01, corrected 10/02) IB Sep 9 02 kleinf Pseudo-F test for zero slopes in 2SLS, example using Klein Model I. I Aug 11 02 gini Gini index (income distribution). (original 11/92, corrected 8/02, added Proc Lorenz to plot Lorenz curve) R Jul 18 02 kerlin Outline for computing Partially Linear Regression by Robinson. Should be revised to use KERNEL command in TSP 5.0. U Jul 9 02 vratio2 Revised code for vratio, with changed commands noted by question marks. J Jun 19 02 tobr2 R-squared for Tobit model, one possible formulation. MB Jun 13 02 aids Almost Ideal Demand System, with elasticities, Deaton and Muellbauer model, based on SAS example. T Jun 12 02 dwnl Approximate P-value for Durbin-Watson in nonlinear model, using regression on first derivatives. J May 22 02 tobpred Predictions from Tobit model, conditional and unconditional. FR Apr 12 02 probks2 Semiparametric Probit (Klein and Spady) on large dataset (2339 obs.). Should revise to use KERNEL command in TSP 5.0. FR Apr 12 02 probks Semiparametric Probit (Klein and Spady) on small dataset (32 obs.). L Apr 10 02 dpdx3 Mean and variance of dP/dX for Logit with 3 choices. (original 3/99, revised 4/02 to draw artificial data) D Apr 5 02 lnormdl Distributed lag with shape from lognormal density. D Apr 5 02 gammadl Distributed lag with shape from gamma density. U Apr 5 02 adfbrk ADF tests with trend breakpoints. (original 2/02, revised 4/02) RI Mar 22 02 spline3 Cubic spline with 3 segments. Examples of fitting sin(6x) and log(.1+x). RI Mar 18 02 splsbic Cubic spline which chooses the number of segments by minimizing SBIC. Examples of fitting sin(6x) and log(.1+x). V Mar 7 02 gir2 Generalized Impulse Response, via LSQ and SOLVE. (extendable to structural VAR) B Mar 5 02 divzero reproduces DIVIND calculation with zero quantities. IR Feb 27 02 odr2 Orthogonal Distance Regression - simpler estimation which avoids the N nuisance parameters. G Feb 20 02 arelbon2 Arellano-Bond example with 3 RHS variables. V Feb 15 02 varira Impulse Response SEs via ANALYZ. Hardcoded example for 3 equations, 4 lags, 6 periods. L Dec 14 02 logitbc Logit with approximate Bias Correction. A Nov 29 02 formar1 FORM with exact ML first observation for LSQ; includes Jacobian trick so that FIML is not needed. I Nov 20 02 multinom draws multinomial r.v.s for user specified probabilities. FL Nov 13 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) I Nov 8 02 clt Central Limit Theorem example - convergence of mean of uniform r.v.s to normality. I Oct 8 02 dotfile using DOT loops to construct filename(s). T Sep 25 02 bilin2 second order bilinear model. P Sep 18 02 feihat hat matrix (leverage) for fixed effects model. L Aug 27 01 mnestlog2 2-level nested multinomial logit. L Aug 27 01 nestlog2 2-level nested conditional logit. JF Aug 27 01 tobithet Tobit and Probit, when heteroskedasticity is a function of variables. F Aug 9 01 op3 Ordered Probit - examines changes in Y for changes in a dummy variable. B Jul 25 01 kleinphi reproduces 3SLS @PHI objective function with matrix commands. F Jun 28 01 opfp Ordered Probit forecasted probabilities. A Jun 22 01 ar1w weighted AR1 estimation via ML in TSP 4.5 B Jun 12 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) A Jun 12 01 ar1fse AR1 forecast standard errors, via ANALYZ. I May 31 01 omnorm Omnibus test for multivariate normality. Reproduces results from Doornik and Hansen (1994) for Fisher Iris data. AT May 25 01 star Smooth Transition AutoRegressive models. I May 23 01 exog Exogeneity test (Hausman-Wu), and also Breusch-Godfrey LM test for autocorrelation in 2SLS. (Original 12/98, updated 5/01) R Apr 25 01 glejser Glesjer and MSS tests for heteroskedasticity in quantile regression. L Apr 20 01 nestl nested logit example from TSP User's Guide. Shows relation to mixed logit model. P Apr 10 01 panrw simulates Panel Random Walk with drift. F Apr 9 01 phe Bivariate Probit with Hermite quadrature. M Apr 4 01 spatial Proc which estimates Spatial Autocorrelation and Spatial Autoregressive models. User supplies W = spatial proximity weight matrix. (Original: 12/97; updated 4/01) V Mar 20 01 gir Generalized Impulse Response - invariant to equation order. Reproduces results in Pesaran and Shin (1998) with KPSW data. I Feb 21 01 rantrunc truncated normal r.v.s via inverted CDF. DP Feb 2 01 koyck2 koyckp example applied to a different dataset. P Feb 1 01 fixedse standard errors for the intercept terms in a fixed effects model (balanced or unbalanced) (Original: 11/96; updated comments 2/01) PE Jan 26 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. F Jan 26 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) QP Jan 25 01 frontp1 Frontier production function, unbalanced panel, error components, v_it - u_i. Follows Battese and Coelli, 1992. DP Jan 24 01 koyckp Koyck (geometric) distributed lag, with truncation terms for finite sample panel or time series. Example on Almon data. E Jan 17 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 E Jan 17 01 reubab example of using the REUB Proc, on the Arellano-Bond model. R Jan 12 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) QF Jan 12 01 op1r1 2 eqns: Ordered Probit and Regression / sample selection FQ Jan 11 01 p1op1 2 eqns: Probit and Ordered Probit, correlated, by Bronwyn Hall QF Dec 16 00 p1r2n 3 eqns: Probit and 2 Regression - non-selection, with simultaneity in Probit eqn QF Dec 16 00 p1r2s 3 eqns: Probit and 2 Regression - selection model FQ Nov 30 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) IT Nov 21 00 dateloop looping over a dated sample - simpler than doquart example, and explains 2 methods P Nov 21 00 timediff time dummies in first differenced equations (when differencing to remove individual effects) IB Nov 11 00 ovid Overidentification tests in 2SLS - examples using Klein I (recently added to TSP 4.5) V Nov 7 00 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) I Oct 13 00 submat extract submatrix (Proc), given starting/ending row/column R Oct 13 00 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) R Oct 12 00 signtest Sign test for median of zero, with exact binomial p-value S Sep 11 00 hamsimp Markov chain model - simple 2-regime from Hamilton's book, via EM. By David Bivin QR Aug 17 00 opac Ordered Probit with AutoCorrelation-robust SEs I Jul 24 00 coeftab printing a small table of selected coefs and SEs from a large estimation, by using ANALYZ PF Jul 12 00 probitfe Probit fixed effects - efficient iteration for large N. I Jun 26 00 int Integration using trapezoidal rule approximation in a DO loop. P Jun 23 00 diaghet Diagonal heteroskedasticity model (like SUR, but no off-diagonal terms); can be useful when N > T. B Jun 21 00 skew Reproduce Skewness and Kurtosis equations from MSD in manual. P Jun 16 00 panw Weighted fixed effects estimation. G May 4 00 gapubal Setting up a gapped SMPL for unbalanced stacked panel data, so that GMM(NMA=k) can be used. U Apr 28 00 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). JR Mar 28 00 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). U Mar 24 00 vratio Variance ratio test for unit root. (original: 7/98, updated 3/00 to add some comments, see vratio2 also). I Mar 5 00 gnuplot gnuplot graphics - .GIF file output only I Mar 5 00 gnuploti gnuplot graphics - X window output I Mar 5 00 ss9b gnuplot graphics - GRAPH of SAMPSEL LogL with multiple local optima. T Feb 28 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). P Feb 7 00 panmeans Removing individual or time means. (original: 8/98, updated 2/00 to use PANEL(WITHIN) to remove individual means). U Jan 5 00 cointarp Cointegration test with AR(p) residuals - Stock-Watson(1993) and Phillips-Loretan(1991, p.424). M Jan 3 00 biquad Bivariate normal cdf - how to evaluate probabilities in all 4 quadrants, by changing signs of the arguments to CNORM2(z1,z2,rho). I Dec 28 00 ovid Overidentification test in 2SLS. R Dec 6 99 winsor Winsorized residuals, for robust/bounded influence estimation. A simple iterative version. H Nov 16 99 igarch Integrated GARCH(1,1), with constraint that alpha1+beta1=1. EF Nov 12 99 probitre Probit with Random Effects - the Borjas-Sueyoshi 2-stage model. Extensive comments on the Pooled vs. Random Effects estimators. TS Nov 9 99 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. E Nov 2 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. Q Oct 26 99 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. P Oct 22 99 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. R Oct 14 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.) F Oct 6 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). M Oct 6 99 boxtid0 Box-Tidwell regression when the RHS variables are sometimes zero. UB Sep 30 99 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) H Sep 30 99 archf ARCH forecasting. Revised slightly for TSP 4.5, where ARCH no longer estimates H(0) by default. TR Sep 27 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. L Sep 7 99 logitlim Same as logitcsu, but includes code which takes limits of ratios, to avoid EXP(xb) overflow, when xb is larger than 88. L Sep 7 99 logitcsu Logit - conditional, with shares as dependent variable, unbalanced data. Data has been "balanced" by running balu first. P Sep 7 99 balu Panel - "balances" unbalanced data by adding artificial observations with zeros for all variables. P Aug 15 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. V Aug 14 99 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.) P Aug 12 99 ah Anderson-Hsiao 2SLS for dynamic panel model (avoids finite sample bias in fixed effects estimator). LM Aug 3 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. P Jul 15 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) I Jul 13 99 addfac Add factor forecasting. Uses EQSUB to add the add factor variable to an existing estimated equation. FS Jun 11 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. S Jun 11 99 swreg Switching regression, regime unknown. Follows Maddala(1983), p.283. P Jun 9 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) U May 27 99 gmmns GMM on non-stationary data. Follows Hamilton(1994), p.424 / Ogaki(1993). Estimates model as a function of detrended variables. UP May 11 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) I May 11 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). Q Mar 23 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. F Mar 1 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. TP Mar 1 99 ar1fmlp AR(1) (exact ML) for panel data, using the FIML command. Reproduces AR1(TSCS) results. H Feb 23 99 egarch11 EGARCH(1,1) estimation. Exponential GARCH, where log(h(t)) = alpha0 + alpha1*abs(e(t-1)) + beta1*log(h(t-1)). PR Feb 9 99 panboot Panel bootstrapping. Draws residuals within an individual. E Feb 4 99 ec3sls 3SLS with 2-way error components, balanced panel. Uses transformed data with 3SLS commands. Much faster than old matrix versions. E Feb 4 99 ec2sls 2SLS with 2-way error components, balanced panel. Uses transformed data with 2SLS commands. Much faster than old matrix versions. E Feb 4 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) E Feb 4 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) TM Jan 8 99 regarma2 OLS with ARMA(8,2) errors, exact ML. Does not currently work, because there is an error in computing the numeric derivatives. TM Jan 6 99 expsm2 Double exponential smoothing with arbitrary smoothing parameter. Compares with ARIMA(0,2,2) model. I Nov 24 98 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. P May 16 98 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. V Nov 13 98 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) AM Nov 3 98 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. IB Oct 30 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) V Oct 26 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. U Oct 02 98 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. U Oct 02 98 sft Tests shinfull on artificial data. Test P-values against published table of critical values. K Sep 11 98 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). RB Sep 04 98 jb Jarque-Bera normality test, starting from small-sample versions of @SKEW and @KURT stored by MSD. I Aug 12 98 cubic Equations for real roots of cubic equation, with positive constraints. MA Jul 28 98 boxcoxar Box-Cox with AR(1) residual I Jul 27 98 percent Arbitrary quantiles (such as 5%, 95%), using sort. J Jul 24 98 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) I Jul 09 98 listsort Creates a LIST (R8 R5 R6 ...) from a vector of integers (8 5 6 ...). V Jun 11 98 varsiml Use SIML to create impulse responses, after a VAR command. Corrects the original version dated 8/94. V 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) Q Jun 11 98 nbsim Using RANDOM(NEGBIN) when the mean is different for each observation M May 29 98 boxcox0 Box-Cox transformation when Y is zero RM May 26 98 student regression with Student t residuals; see also stacklos example. FG May 05 98 probitac Probit with SEs robust to autocorrelation (uses GMM). P Apr 29 98 ar1hetub version of ar1het for unbalanced data I Apr 28 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. G Apr 17 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) KM Apr 13 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) M Mar 11 98 rancoef ML estimation of a regression with a single random coefficient. Outlines how to extend to multiple random coefficients. L Feb 25 98 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) VI Feb 19 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. LP Feb 6 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). G Dec 17 97 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) MB Dec 5 97 spatcal Example of running spatial.tsp on California plant species data. Reproduces results for Spatial AutoCorrelation and Spatial AutoRegression from Upton and Fingleton (1985). M Dec 4 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. MP Nov 26 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. E Nov 26 97 p3s Example of using ec3sls on a real model (data files are not included). P Nov 21 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. E Nov 18 97 ec2sm1 First matrix algebra version of ec2sls. Does not use transformed data. Notation differs a bit from Hsiao(1986). (Original version 9/97). E Nov 18 97 ec2sm2 Second matrix algebra version of ec2sls. Uses transformed data; notation is close to Hsiao(1986). G Nov 11 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. T Oct 21 97 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. I Oct 16 97 tab2 Forms and print 2 x 2 contingency table, with ChiSq(1) test for independence. Inputs are 2 dummy variables. I Oct 16 97 tab2t Examples of calling tab2. G Oct 8 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. G Oct 8 97 lm2test2 Alternative version of lm2test, using explicit lags. Unfortunately, it seems to be about 20% slower than lm2test. B Sep 27 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. V Sep 25 97 varsbici Chooses optimal lag orders for VAR by minimizing @SBIC. Allows for different lags on different variables. Example with just 2 variables. G Sep 18 97 cov2step Arellano-Bond 2-step COVOC matrix - GMM/panel S Sep 16 97 diseq104 Disequilibrium model, with sample separation known. Section 10.4 of Maddala(1983), p.307-309. RM Sep 12 97 stacklos LAD and Student's t residuals on classic Stack Loss dataset E Sep 11 97 h3b Hsiao(1986)'s Appendix 3B - verifies 2-way EC Omega inverse V Sep 11 97 varsbic chooses optimal lag order for VAR by minimizing @SBIC I Aug 21 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 B Aug 12 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) G Aug 4 97 premaskg creates mask for GMM with panel data G Aug 4 97 premaskc 2 examples of calling premaskg R Aug 4 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). M Jul 21 97 fiml5 FIML via ML with 5 equations (like fiml4 and fiml11) DA Jul 11 97 pdlar single PDL variable with AR(p) residuals (4.4) T Jun 20 97 qtomw Quarterly to Monthly conversion, using ratio to average, and weights (sum and average versions). T Jun 20 97 qtomw2 Examples of calling qtomw, converting forecasts from quarterly model into monthly forecasts. LP Jun 20 97 logitfe3 fixed effects logit for panel data with 3 time periods (choice taken 1 or 2 times). Follows Hsiao(1986), p.162. R Jun 17 97 mbbjex3 moving blocks bootstrap (OLS or LAD), by Bernd Fitzenberger. Similar to plain bootstrap, but handles autocorrelation as well as heteroskedasticity. DA Jun 13 97 pdlar2 example of calling pdlar PM Jun 12 97 garcia Growth model, stochastic differential equations, unbalanced panel. Uses recursive EQSUB. This nonlinear panel growth model is used on tree heights. DA Jun 12 97 pdlar243 4.3 code version of pdlar2 (calls pdlar43) DA Jun 12 97 pdlar43 4.3 code version of pdlar B Jun 5 97 prin reproduces results from PRIN (principal components), via MAT commands I May 23 97 analyzr using the restricted coefs stored by ANALYZ E May 20 97 apd creates artificial panel data. balanced, one-way random effects, 2 Xs correlated with random effects M Apr 22 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. J Apr 2 97 tobrncf Tobit with random coefficients, Ionnatos, JBES July 1995 L Apr 1 97 testnlog 2 level (5 x 10) nested logit, with artificial test data, by Bronwyn Hall T Feb 25 97 ma simple Proc to calculate moving average of length n T Feb 21 97 gapbal creates gapped smpl for balanced AR1(TSCS) (obsolete in 4.4 and later versions) BP Feb 13 97 panhaus reproduces Hausman test of RE vs. FE in panel data BT Feb 11 97 dh reproduces Durbin's h statistic A Feb 5 97 ar4nl AR(4) on single nonlinear equation (conditional ML) I Jan 30 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. E Dec 18 96 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. E Dec 18 96 data2way generates artificial data for 2-way model P Dec 18 96 bal2wfe balanced 2-way fixed effects M Dec 02 96 unbalsur1 unbalanced SUR -- 2 equations; some observations missing for the second equation. ML version only (easiest way to get estimates and proper standard errors). S Nov 11 96 switch Disequilibrium / switching regression model from 4.3 User's Guide, by Bronwyn Hall. Maddala p.298 L Oct 31 96 wclogit weighted conditional logit. (originally written Mar 94) U Oct 24 96 ppmex Phillips-Perron "z hat sub t" unit root test on Mexican data. Uses ppzt.tsp. UB Oct 24 96 ppenders ppzt on data from 4 countries. Mostly reproduces table on p.263 of Enders, "Applied Economic Time Series", 1995 U 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. L Sep 25 96 logitmix mixed logit via ML command; a standard TSP testrun L Sep 12 96 logiteach data setup code for conditional logit, where each alternative is chosen exactly once. K Sep 05 96 kfllt Kalman Filter on Local Linear Trend - Harvey(1989), p.170 I Jul 31 96 merge Proc which merges two samples by ID variables K Jul 22 96 kfarma11 Evaluation of conditional likelihood function for ARMA(1,1) via the KALMAN command. K Jul 18 96 kfma1 Ditto, but for MA(1) model. Harvey, TSM, 1981, p.103 K Jun 21 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. K 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. M May 23 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 L May 20 96 logitf forecasts from a multinomial logit model (picks most likely Y value for a set of X values). not tested. PQ May 16 96 coxpanel ML estimation of Cox proportional hazards model, balanced data example with 3 time periods. Uses lagged EQSUB feature. U Mar 29 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. KM Mar 07 96 kfml estimates Kalman Filter transition matrix via grid search (2 parameters). Compare with kalmanhp above. G Feb 27 96 mask2 2 different ways to set up a large sparse MASK matrix for use in GMM (different instruments in different equations). J Feb 13 96 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. TM Jan 30 96 bilinear ML estimation of simple bilinear time series model. Uses recursive derivative code; could be made simpler with ML PROC. U Jan 08 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 M Dec 22 95 fiml11 11-equation FIML estimation, via the ML command. Just an extension of the old fiml4 example. M Dec 15 95 unbalml slightly more complicated version of unbalsur1. Probably not needed. I Dec 15 95 bandm creates a banded symmetric matrix from its first column. Outdated - use MFORM(BAND) in TSP 4.4. R Dec 14 95 kernel gaussian kernel density estimation and regression, by Joao Santos-Silva (compare with kercc above) V Nov 13 95 varst21 same as varst32, but 2 variables with 1 lag (much easier to read and understand) I Nov 02 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. I Oct 26 95 anova Proc which prints a (formatted) "ANOVA table" after OLS I Sep 1 95 probdist compute various probability distributions and plot them. M Aug 10 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. I Aug 04 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. R Jun 30 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) T Jun 21 95 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. I Jun 12 95 sortl sorts a list of variable names, by the variables' values in a given period. Coding similar to listsave. I Apr 24 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. I Jan 11 95 ridge Bayesian mixed estimator (combines prior with estimated coefficients and VCOV), works for non-OLS models. L Dec 6 94 nest31 improved version of NEST3, can be changed for diff. model L Nov 30 94 nest3 3-level nested logit Q Nov 16 94 bivord Bivariate Ordered Probit (without data). Could be improved in TSP 4.5 and higher by using CNORM(z1,z2,rho) function. I Oct 5 94 delobs deletes some observations permanently from a dataset I Aug 4 94 quintile sample Quintiles (20%, 40%, ...) via SORT I Jun 8 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. L Jun 2 94 dpdx standard errors for @DPDX from Logit IT May 12 94 doquart DO loop over time periods with quarterly data IR Feb 16 94 odr Orthogonal Distance Regression (errors in variables, when ratio of error variances in Ys and Xs is known) M Dec 1 93 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. L Nov 5 93 nlogit 2-level nested logit Q Aug 24 93 cn4 4-dimensional cumulative normal integral, approximated with many random draws, CNORM(), CNORMI(), and Cholesky factorization. Q Apr 1 93 bivar approximation for Bivariate normal CDF in ML. Outdated in TSP 4.5 and higher, where CNORM(z1,z2,rho) can be used. I Jan 1 93 median median via SORT command. Outdated by MSD(ALL) in 4.2B and higher. I Jan 1 93 phichow Chow test for 2SLS (pseudo-F test for parameter stability, split sample) Q Jan 1 93 hazard log-linear hazard function with one time-varying covariate Q Dec 3 92 samsel2 sample selection with 2 selection equations (undocumented) J Nov 6 92 tob2 2-equation (bivariate) simultaneous Tobit J Nov 6 92 tob2sur 2-equation Tobit, but with no RHS endogenous variables I Oct 5 92 illus41 illustrative model from the manual (slightly dated)