I am trying to determine the optimal model for time series data (1592 observations). When I run TimeSeriesModelFit
, Mathematica selects $AR(1)$ model, the estimated $a_1$ coefficient is -0.067, and the Akaike Information Criterion (AIC) is supposed to be 8380 (I obtained this result using the "CandidateSelectionTable"
Property). However, when I ran the regression of the $AR(1)$ model in Stata (OLSMLE), I got AIC of 12 888898.8508 but the estimate of the $a_1$ coefficient was almost exactly the same as well as the estimate of the intercept. At this point, I downloaded Gretl, ran the model again (OLSMLE), and got AIC of 12 888898.8508, i.e. the same as Stata had computed. Does Mathematica compute the AIC in a wrong way or am I doing a mistake somewhere? Also the Bayesian Information Criterion (BIC) differs significantly for the respective models in Mathematica and Stata. The data that I use is data=Differences[FinancialData["^GSPC","Close",{{2009,1,1},{2015,5,1}}][[All, 2]]]
, i.e. daily close price differences of the S&P 500 index.
EDIT: I suspect there is something wrong in the computation of log-likelihood by the TimeSeriesModelFit
which is essential in determining the AIC. One should calculate it as $2k-2\ln\left(L\right)$, where $\ln\left(L\right)$ is the log-likelihood and $k$ number of estimated parameters. If I separately run LogLikelihood[ARProcess[0.788, {-0.067}, 192.514], data]
(the numbers inside the ARProcess
are those obtained from TimeSeriesModelFit
and are almost the same as what Stata estimates), I get -6446.04 - that is the same as in Stata. This is most likely the correct result, but TimeSeriesModelFit
probably computes different log-likelihood and hence wrong AIC.