Closed ejuliaschulz closed 3 weeks ago
I suspect that the model you are fitting is not well idenfified so that the regressor matrix, consisting of lagged values, is near-singlar.
You have 70 rows and 9 columns. Each time you lag you get 9 regressors, and lose one observation, so that
lag | obs | reg | dof
1 69 | 10 | 59
2 68 | 19 | 48
3 67 | 28 | 39
4 66 | 37 | 29
5 65 | 46 | 19
6 64 | 55 | 9
7 63 | 64 | --
At 7 lags you have perfect fit which is why the AIC and BIC get silly values. These are not meaningful and are down to numerical issues, which is you get you different values. For a data set of this size, one would not usually trust IC for more than 2 lags since the number of regressors should usually not be larger than sqrt of the sample size (which would really be 0 or 1, but could probably look at 2).
Thanks @bashtage, that is reasonable. However, it still does not really explain the difference in outputs for 2 different environments, no? Other users can reproduce my results in different environments with exactly the same outcome. Sorry if I get this wrong!
When you are in the area of numerical instability it is completely platform and compiler specific. In your case, the error covariance matrix is exactly 0 (theoretically) but will not be numerically exactly 0 (will be ~ 1e-15, but will look sort of like random tiny values), and will differ across platforms. This error variance is used in the AIC and BIC.
ok, thanks for the explanation!
Describe the bug
I build and fit a VAR model to obtain the best model order based on the AIC criterion. When running this code locally (Windows 11 Pro, statsmodel version 0.14.2, python 3.11), my best model order is calculated as 8, with AIC of -599.87597. I use this code in a deployed app with streamlit, which seems to use Linux, and also Python 3.11, same module versions as I use locally. In this app, the exact same code (same module versions) produces a different output, the best model order changes to 9 with AIC of -600.3351. Here are two screenshots of the same code output, once in the deployed app (Linux?), and once in the local version of my app (Windows)
Deployed app
Local app
Code Sample, a copy-pastable example if possible
Expected Output
The same code should provide the same output with the same data. I asked the same question in the streamlit community but suspect it might be something that is rather related to statsmodel than streamlit?
Output of
import statsmodels.api as sm; sm.show_versions()