Berndt exercises (complete)
All the exercises in Berndt's The Practice of Econometrics
have been programmed in TSP and checked. They may provide some
useful examples of how to program different econometric techniques.
They are also intended to produce benchmark results that can be checked
against other packages or algorithms.
The exercises below assume that you have the datasets in the form of TSP
databanks. These databanks can be downloaded for the PC, or you
can download the program/data files to create them on other systems
(like unix and Mac).
Comments and corrections for all exercises.
1. Getting started
1e1 color tv (commands used: GENR, MSD, CORR, COVA, OLSQ, GRAPH, PLOT)
2. CAPM model
2e1 looking at return data (DOT, MSD, PLOT, SET)
2e2 t tests for alpha, beta (PROC, CDF, IF, THEN, ELSE, TITLE)
2e3 t tests for gold beta in 2 samples (CDF, SET)
2e4 OLS y on x and OLS x on y
2e5 t tests vs. 1 for portfolios (DOT, PROC, CDF, SET)
2e6 Chow tests over time and 2-3 companies
(REGOPT, SUPRES, PROC, CDF, PANEL, MMAKE, UNMAKE, RENAME) (long)
2e7 dummy variables (SELECT, OLSQ, MSD)
2e8 January dummy t and F tests (DUMMY, SELECT, OLSQ, SUPRES)
2e9 surprise variables F test (MSD, DOT, OLSQ, SET, CDF)
2e10 heteroskedasticity, autocorrelation, and normality testing;
regression with MA(1) residual
(REGOPT, DO, AR1, BJEST, MAT, FRML, WRITE/FORMAT) (long)
3. Costs, Learning curves, Scale economies
3e1 learning curve for Poly, TiO2 (GRAPH, OLSQ, FRML, ANALYZ)
3e2 t and F tests (OLSQ, SET, CDF, ANALYZ)
3e3 R-squared on Weird data (CORR, OLSQ, SET)
3e4 extracting nonlinear parameters (OLSQ, ANALYZ, CORR, PLOT, GRAPH)
3e5 F tests and nonlinear returns to scale (DUMMY, DOT, SELECT, ANALYZ)
3e6 F tests and nonlinear (DOT, DUMMY, TREND and INT() to create ID variable)
3e7 OLS, AR1, exact DW test (REGOPT, AR1, NOREPL)
3e8 DW test on ordered cross section,
other diagnostics for functional form and outliers (OLSQ, AR1, LAD, LMS)
3e9 F tests with 10 groups (PANEL, REGOPT(CHOWDATE=), also by hand with DOT,
splicing data from 2 databanks with via lags)
3e10 forecast and forecast variance,
(optional) lognormal adjustment for unbiased EXP() forecast
and asymmetric confidence band
(FORCST, SET, MAT)
4. Hedonic Price Indices
4e1 reproducing Waugh's OLS results (MSD(COVA), SET, MAT, READ(matrix))
4e2 R-squared and correlation coefficients (CORR, SET)
4e3 hedonic regressions for computers (DOT for logs and time dummies,
logical expressions for time range dummies, OLSQ(WEIGHT=))
4e4 F test for sum of coefs = 1, F test for time dummies vs. trend (ANALYZ, SET, CDF)
4e5 complicated F tests for stability across time, LR heteroskedasticity test (DOT, SELECT, SET, CDF)
4e6 chained price index, regression across 2 year samples (DOT, SELECT, MMAKE, UNMAKE)
4e7 Box-Tidwell regressions, LR, Wald tests (FIML, ANALYZ)
5. Log(Wage) regressions - schooling, sex/race/union dummy variables
5e1 means and ranges for different groups (HIST, MSD, SET, MFORM)
5e2 union and nonunion dummy variables
5e3 dummy interactions - male/female and single/married
5e4 experience-earnings profiles (UNMAKE, SET, GRAPH) (long)
5e5 union wage effect (MSD, UNMAKE, MATRIX) (long - includes significance of wage differentials)
5e6 wage discrimination by race (MSD, UNMAKE, MATRIX) (long - includes significance of wage differentials)
5e7 wage discrimination by gender (similar to 5e6, but code is shorter, because it uses DOT loop to repeat analysis in 1978 and 1985)
5e8 heteroskedasticity: robust SEs, estimation, White test (OLSQ(ROBUST), OLSQ(WEIGHT=), REGOPT)
6. Investment equations - estimation and forecasting
6e1 trends of data, depreciation, correlations (PRINT, MSD, CORR)
6e2 autocorrelation with lagged dependent variable - Durbin's h, m (REGOPT, ANALYZ, AR1)
6e3 autoregressive model: choosing lag length, using %RMSE, SBIC (DO, DOT, PROC)
6e4 cash flow model: choosing lag length and degree of PDLs, with SBIC (OLSQ, AR1, DO, PROC)
6e5 neoclassical model: choosing lag length and degree of PDLs, with SBIC (AR1, DO, IF, THEN)
6e6 Tobin's q model: choosing lag length, degree, and endpoint constraints of PDLs, with SBIC (AR1, DO, PROC, IF, THEN, GOTO)
6e7 Box-Jenkins/ARIMA modelling (BJIDENT, BJEST, BJFRCST)
6e8 2SLS and autocorrelation (2SLS, AR1(INST=))
6e9 levels, first differences, AR(1) and AR(2) with PDL lag lengths (AR1, EQSUB, PROC)
(very long, due to the last part, which is AR(2) with 2 PDL variables)
6e10 lag length/specification search across 3-5 models with SBIC and RMSE (AR1, DOT, DO, PROC) (long)
7. Electricity demand
7e1 looking at the UK data (PRINT, MSD, CORR)
7e2 looking at the US data (PRINT, PLOT, MSD, CORR)
7e3 weighted regression, income and price elasticities (and SEs) at mean and at specific data values (OLSQ(WEIGHT=), ANALYZ)
7e4 omitted variable bias (SET, OLSQ(SILENT))
7e5 forecasting (with SE) under different growth rates, testing Durbin-Watson (ANALYZ, AR1)
7e6 lagged dependent variable: power of autocorrelation tests, AR(1) multiple local optima (AR1, REGOPT, DO, GRAPH) (long)
7e7 exponential growth and smoothing, done with equivalent ARIMA (OLSQ, BJEST, BJFRCST)
7e8 forecasting RHS variables and growth rates (AR1, BJEST, BJFRCST, PROC, DO)
8. Advertising and Sales
8e1 exogeneity test, 2SLS by hand with bad SEs (DOT, OLSQ, ANALYZ, 2SLS)
8e2 90% duration level, converting data A to M, M to Q (OLSQ, ANALYZ, CONVERT)
8e3 lagged dependent variable vs. AR(1) specification - common factor test (OLSQ, REGOPT, ANALYZ, AR1)
8e4 share equations that add up, with 2 and 3 shares (OLSQ, MSD, DOT)
8e5 Granger causality - bivariate transfer function (BJIDENT, BJEST, BJFRCST, OLSQ, FORCST, CORR(PAIR), ACTFIT)
8e6 exogeneity test (OLSQ, 2SLS, AR1(INST=))
8e7 nonlinear regression, exponential forecast (LSQ, ANALYZ, OLSQ(WEIGHT=))
8e8 panel data with AR(1), het and lagged dependent variable (AR1, MMAKE, UNMAKE, PROC) (long)
9. Factor Demand Share systems - Production and Cost functions
9e1 looking at the KLEM data (MSD, CORR)
9e2 single equation Cobb-Douglas, CES (OLSQ, PROC)
9e3 equivalence of OLS/ZEF/IZEF for unrestricted (DOT, FRML, LSQ, SUR, MATRIX)
9e4 Translog with symmetry: invariance to dropped share equation (LSQ, 3SLS, 3SLS(MAXITW=500,WNAME=OWN), ANALYZ)
9e5 GL and Translog with symmetry: price and Allen elasticities (with SEs), curvature checks (LSQ, DOT, EQSUB, ANALYZ, MMAKE, MFORM, MATRIX, YLDFAC) (long)
9e6 Wald, LR, and LM tests on multiequation models, done in different ways (LSQ, ANALYZ, MATRIX)
9e7 LR test and system R-squared (LSQ, MATRIX)
9e8 autocorrelation in system estimation (LSQ, unnormalized FRMLs, lagged EQSUB)
9e9 Translog cost function with technical change; multifactor productivity growth, Wald, LR, LM (LSQ, ANALYZ, MATRIX, LIST, CONST)
10. Simultaneous equations - structural and reduced forms
10e1 Klein I - OLSQ, 2SLS, AR(1) (OLS, 2SLS, AR1, AR1(INST=) )
10e2 Lucas-Rapping - 2SLS in 2 stages, correct SEs (2SLS, OLSQ, FORCST, MATRIX, TSTATS)
10e3 Rational Expectations model (2SLS, OLSQ, 3SLS, BJEST, FORM)
10e4 Klein I - exogeneity test (OLSQ, ANALYZ, CDF)
10e5 Lucas-Rapping - Autocorrelation test in OLSQ and 2SLS with lagged dependent variable - Durbin's m, Breusch-Godfrey (OLSQ, 2SLS, REGOPT, ANALYZ)
10e6 Exactly identified model - equivalence of 2SLS, ILS, minimum distance, restricted reduced form (2SLS, OLSQ, LSQ, EQSUB)
10e7 Overidentified models (Klein I and Lucas-Rapping) - comparison of 2SLS, 3SLS, I3SLS (2SLS, 3SLS)
10e8 Klein I - FIML, restricted reduced form (FIML, LSQ, EQSUB, ANALYZ, VAR) (long)
10e9 Klein(1953) recursive model, lower triangular Jacobian (OLSQ, FIML, LSQ)
10e10 Rational Expectatios model - grid search with 2 MA parameters (LSQ, DO, DOT, IF, THEN) (long)
11. Labor Supply of Married Women - LFP and hours worked
11e1 looking at the PSID data, saving transformations (LIST, MSD, SELECT, OLSQ, OUT, KEEP)
11e2 OLS on truncated data, elasticities (SELECT, MSD, OLSQ, ANALYZ)
11e3 LFP - comparing OLS, PROBIT, LOGIT, probability derivatives (OLSQ, PROBIT, LOGIT, MATRIX)
11e4 OLSQ on positive data, Tobit, McDonald-Moffit decomposition, Tobit on positives (OLSQ(ROBUST), MATRIX, TSTATS, TOBIT)
11e5 Identification (Over, Exact, Under) with reservation wage equations (OLSQ, LSQ, EQSUB, ANALYZ) (long)
11e6 Sample Selection / Heckit model (PROBIT, OLSQ(ROBUST), SAMPSEL, 2SLS)
11e7 Sample Selection / Heckit with tax variables (PROBIT, 2SLS)
11e8 Simultaneous equations Tobit (LSQ, EQSUB, ML) (long)
Note: "(long)" means the file size is 3000 or more bytes.