This example models the expenditure time series as a function of exogenous variables (income and investment) and the AR and MA parameters. The function chooses the order and lag of the variables according to the degree of complexity, typically a trade-off between accuracy and over-fitting.
Input
- finance_data3, as in VARMAX Example 1: No Exogenous Model
SQL Call
SELECT * FROM VARMAX ( ON finance_data3 AS "data" PARTITION BY id ORDER BY period USING ResponseColumns ('expenditure') ExogenousColumns ('income', 'investment') PartitionColumns ('id') PDQ ('1, 1, 1') Lag (3) ExogenousOrder (3) IncludeMean ('false') StepAhead (3) ) AS dt ORDER BY id;
Output
The model converges for all three decades.
id | coef | coef_value | stepahead | predict_expenditure |
---|---|---|---|---|
1 | coef | 1, 1, 1, 0, 0, 0, 3 | ||
1 | ar_params | [[-0.11048447321369022]] | ||
1 | ma_params | [[-0.1925561123625604]] | ||
1 | exogenous_params | [[0.15184265006071107, -0.6548579365873168]], [[3.4356161960447644, -3.8815455917944566]], [[1.352629223976695, 1.6692441091760393]] | ||
1 | seasonal_ar_params | |||
1 | seasonal_ma_params | |||
1 | period | 0 | ||
1 | lag | 3 | ||
1 | sigma | [[21815.169519750183]] | ||
1 | aic | 10.400617266572384 | ||
1 | bic | 10.74186068116308 | ||
1 | iterations | 18 | ||
1 | converged | true | ||
1 | 1 | 4601.67249271766 | ||
1 | 2 | 6375.70446779608 | ||
1 | 3 | 6353.20194246941 | ||
2 | coef | 1, 1, 1, 0, 0, 0, 3 | ||
2 | ar_params | [[0.7135109382825823]] | ||
2 | ma_params | [[0.8116168306474483]] | ||
2 | exogenous_params | [[-1.3199094913183353, 3.7663680262105013]], [[0.8573542123886598, -2.361564228588058]], [[0.7742458737629424, -2.39596174873262]] | ||
2 | seasonal_ar_params | |||
2 | seasonal_ma_params | |||
2 | period | 0 | ||
2 | lag | 3 | ||
2 | sigma | [[41347.85268103083]] | ||
2 | aic | 11.040032179034085 | ||
2 | bic | 11.381275593624782 | ||
2 | iterations | 18 | ||
2 | converged | true | ||
2 | 1 | 1738.29815872784 | ||
2 | 2 | 1683.52303336657 | ||
2 | 3 | 1737.17454282084 | ||
3 | coef | 1, 1, 1, 0, 0, 0, 3 | ||
3 | ar_params | [[0.7034293980424465]] | ||
3 | ma_params | [[-0.5320720491694714]] | ||
3 | exogenous_params | [[0.21057556006931047, -0.5831916151232963]], [[-0.09419582311809366, 0.2501649697569839]], [[0.4552695851877213, -1.121807842101149]] | ||
3 | seasonal_ar_params | |||
3 | seasonal_ma_params | |||
3 | period | 0 | ||
3 | lag | 3 | ||
3 | sigma | [[1.2480831335136702E-25]] | ||
3 | aic | -55.88847298918466 | ||
3 | bic | -55.59909460896767 | ||
3 | iterations | 25 | ||
3 | converged | true | ||
3 | 1 | 2321.97511577896 | ||
3 | 2 | 2404.77038121072 | ||
3 | 3 | 2433.88438933071 |