3
$\begingroup$

This is a question about Mathematica's behavior. I give some background -- but you can skip to the code block below, which illustrates the behavior.

I am using Mathematica ("WL") to work through the time series examples in Stock and Watson's "Introductory Econometrics" and also to replicate the solutions for those examples in Hanck et al "Using R for 'Introductory Econometrics'". It's fun and I'm learning my way around the WL time series modules.

But a puzzle. I import a spreadsheet via SemanticImport[] into a DataSet and then extract the quarterly dates and GDP levels (via Normal[]) into a TimeSeries object.

I transform this TS object into a "GDP Percentage Growth" object by applying 400 Differences[Log[gdplogts]] to the GDP level series.

After imposing a 1962-2012 window on the percentage growth series, I estimate Stock and Watson's AR(1) model (their results: GDPGGsubT = 1.991 + 0.344 GDPGRsubT-1) two different ways:

1: gdpgr6212AR1 = TimeSeriesModelFit[gdpgrpctts6212, {"AR", {1}}]. The intercept, coefficient, and error variance returned are ARProcess[2.023891, {0.3371512}, 9.924687], which are close to the Stock and Watson values, but quite distinguishable from them.

2: I extracted the GDP Growth for 1962:2012 into a list, create level and lag versions of the lists, combine them into a coordinate array with MapThread[], and then submit this array to LinearModelFit[]. Here the Normal[] reduction of the FittedModel returns 1.990784 + 0.3436466 x, which rounds exactly to the Stock and Watson textbook result.

My question is, why do these methods produce different results? There are analogous approaches in R to what I did above (none of which match the Stock & Watson result as well as WL LinearModelFit[]), but all of them ultimately seem to be wrappers for the core R lm() ("linear model") estimator and they all return the same results.

In WL, I can't tell whether I am inadvertently introducing the variability, or whether different estimators are used by LinearModelFit[] and EstimateProcess[] (which seems to be what TimeSeriesModelFit[] is pointing to, so I go right to it in the code snippet below).

The code below replicates my actions with a small snippet of the GDP Percentage Growth value list.

Code

(* 10 obs of base series*)
basetestdata = {2845.453, 2873.169, 2843.718, 2770., 2788.278, 
   2852.741, 2919.47, 2973.782, 3046.096, 3040.235};  
(* 10 obs at Lag 1*)
lagtestdata = {2851.778, 2845.453, 2873.169, 2843.718, 2770., 
   2788.278, 2852.741, 2919.47, 2973.782, 3046.096} ;
(* Calculate percentage growth*)
tdgrowthpct = 400  Log[basetestdata/lagtestdata] (* 10 obs*)

(* Method 1: Submit to Estimateprocess[] *)
tdgrowthpctEProc = 
 EstimatedProcess[tdgrowthpct, 
  ARProcess[1]] (* Lag will reduce to 9 obs *)
(* Output is : ARProcess[1.537332, {0.3994062}, 33.70502] *)

(* Method 2: form pairs and submit to LinearModelFit[] R *)
basetdgrowthpct = Take[tdgrowthpct, {2, 10}] (* Get down to 9 obs *)
lagtdgrowthpct = Take[tdgrowthpct, {1, 9}] (* Get down to 9 obs *)
data2 = MapThread[
  List, {lagtdgrowthpct, basetdgrowthpct}] (* Create nine pairs *)
tdgrowthpctLM1 = 
 LinearModelFit[data2, x, x]  // Normal  (* Submit nine pairs *)
(* Output is 1.745164 + 0.408785 x *) 
```
$\endgroup$

1 Answer 1

0
$\begingroup$

I'm disappointed that this post received no replies. To close the entry off, I will attempt to answer my own question. I will be more than happy to retract the following if a better answer appears.

As far as I can tell LinearModelFit[ ] and the stack of functions such as TimeSeriesModelFit[ ] that boil down to a call to EstimatedProcess[ ] use different estimation routines which produce different results for the same basic OLS-preferred scenarios. LinearModelFit[ ] consistently matches (at least to two decimal points) the small sample results of other packages; TimeSeriesModelFit[ ] does not. The results are not hugely different -- they typically have the same p-values -- but since the differences are unexplainable, it's hard to see how how TimeSeriesModelFit[ ] could be used in original econometric research involving time series or in projects seeking to replicate the results of time series studies conducted on other platforms. This is a shame, because Mathematica is an excellent platform for math-based original and replication projects, but it in the case of econometric projects, it seems it must be used with great care.

Postscript: I appreciate the respinse from @JimB. Based on these, I retract the above conclusion. I was assuming a parallel in usage between TimeSeriesModelFit' and LinearModelFit` which does not really hold.

$\endgroup$
4
  • 3
    $\begingroup$ It's more than different estimation routines: LinearModelFit and EstimatedProcess assume different models for the error structure. $\endgroup$
    – JimB
    Commented Sep 14 at 5:38
  • $\begingroup$ Thanks, @JimB, for the response. I checked out some of your other answers on "Fit" issues and realized I'm in a bit over my head here. But do you think my general "Don't use TimeSeriesModelFit for econometric replication" was on target or too simplistic or just wrong? I would be greatful for some pointers to the next level. TB $\endgroup$
    – Tom Barson
    Commented Sep 14 at 12:58
  • 1
    $\begingroup$ All estimation routines as associated with a data generating model. One should start with a well-defined question & model, then the data, and then the estimation process. "the process of re-examining published research to verify results, identify errors, and test the generalizability of findings" is what you apparently mean by "economic replication". But that definition seems to ignore the initial assumptions and how the data was collected. But to answer your question: your general statement is wrong. When a model and data calls for 'TimeSeriesModelFit`, use it. When it doesn't, don't. $\endgroup$
    – JimB
    Commented Sep 14 at 14:26
  • $\begingroup$ Thanks again @JimB for the input. I think my error (not so obvious from the simplified sample data I submitted) was in thinking of` TimeSeriesModelFIT` as in part analogous to LinearModelFit -- only for time series. (The parallel in R would be dynlm() vs. lm().). Instead, TimeSeriesModelFit is closer to R arima(). Fair enough. I'll update my answer and the issue can be closed. $\endgroup$
    – Tom Barson
    Commented Sep 15 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.