16 Jul 2020

Posted on:

18 Jun 2020

1

ARIMA LLR_test and start_ar_lags

In the code for the LLR_test function the fit uses 11 lags for both fits. When I calculate the LLR p-value from just the results that I've already obtained with the minimum value for start_ar_lags (so as to not have to spend the time to fit every time I want to test this) I get different values. Does the start_ar_lags have to be the same for both fits in order to have a result that is reliable? Or is my approach equally valid?

Course code:

```def LLR_test(mod_1, mod_2, DF = 1):
L1 = mod_1.fit(start_ar_lags = 11).llf
L2 = mod_2.fit(start_ar_lags = 11).llf
LR = (2*(L2-L1))
p = chi2.sf(LR, DF).round(3)
return p```

Resulting in:

```0.018
0.117
```

My code:

```def LLR_test_results(res_1, res_2, DF = 1):
L1 = res_1.llf
L2 = res_2.llf
LR = (2*(L2-L1))
p = chi2.sf(LR, DF).round(3)
return p```

Resulting in:

```print(LLR_test_results(results[1, 1, 3], results[6, 1, 3], DF=5))
print(LLR_test_results(results[5, 1, 1], results[6, 1, 3], DF=3))```
```0.003
0.018
```