blob: e6f5bd2d06ef394da72847ee3d50b7f006b9f747 [file] [log] [blame]
/* -----------------------------------------------------------------------------
* ARIMA Install Check.
* -------------------------------------------------------------------------- */
DROP TABLE IF EXISTS mini_ts;
CREATE TABLE mini_ts(
id integer,
val float8
);
COPY mini_ts(id, val) FROM stdin;
1 100.8
2 81.599999999999994
3 66.5
4 34.799999999999997
5 30.600000000000001
6 7
7 19.800000000000001
8 92.5
9 154.40000000000001
10 125.90000000000001
11 84.799999999999997
12 68.099999999999994
13 38.5
14 22.800000000000001
15 10.199999999999999
16 24.100000000000001
17 82.900000000000006
18 132
19 130.90000000000001
20 118.09999999999999
21 89.900000000000006
22 66.599999999999994
23 60
24 46.899999999999999
25 41
26 21.300000000000001
27 16
28 6.4000000000000004
29 4.0999999999999996
30 6.7999999999999998
31 14.5
32 34
33 45
34 43.100000000000001
35 47.5
36 42.200000000000003
37 28.100000000000001
38 10.1
39 8.0999999999999996
40 2.5
41 0
42 1.3999999999999999
43 5
44 12.199999999999999
45 13.9
46 35.399999999999999
47 45.799999999999997
48 41.100000000000001
49 30.399999999999999
\.
-- TRUE, ARRAY[1,0,1]
drop table if exists tsa_out;
drop table if exists tsa_out_summary;
drop table if exists tsa_out_residual;
select arima_train('mini_ts', 'tsa_out', 'id', 'val', NULL, TRUE, ARRAY[1,0,1]);
select assert(relative_error(ar_params, ARRAY[0.685268276058]) < 1e-2, 'ARIMA: wrong ar_params') from tsa_out;
select assert(relative_error(ar_std_errors, ARRAY[0.103996616127]) < 1e-2, 'ARIMA: wrong ar_std_errors') from tsa_out;
select assert(relative_error(ma_params, ARRAY[0.730629026211]) < 1e-2, 'ARIMA: wrong ma_params') from tsa_out;
select assert(relative_error(ma_std_errors, ARRAY[0.0979481470864]) < 1e-2, 'ARIMA: wrong ma_std_errors') from tsa_out;
select assert(relative_error(mean, 38.6009250545) < 1e-2, 'ARIMA: wrong mean') from tsa_out;
select assert(relative_error(mean_std_error, 13.2499230619) < 1e-2, 'ARIMA: wrong mean_std_errors') from tsa_out;
select assert(relative_error(residual_variance, 281.669418496) < 1e-2, 'ARIMA: wrong residual_variance') from tsa_out_summary;
select assert(relative_error(log_likelihood, -207.725973784) < 1e-2, 'ARIMA: wrong log_likelihood') from tsa_out_summary;
-- FALSE, ARRAY[1,0,1]
drop table if exists tsa_out;
drop table if exists tsa_out_summary;
drop table if exists tsa_out_residual;
select arima_train('mini_ts', 'tsa_out', 'id', 'val', NULL, FALSE, ARRAY[1,0,1]);
select assert(relative_error(ar_params, ARRAY[0.831752901064]) < 1e-2, 'ARIMA: wrong ar_params') from tsa_out;
select assert(relative_error(ar_std_errors, ARRAY[0.0695053543058]) < 1e-2, 'ARIMA: wrong ar_std_errors') from tsa_out;
select assert(relative_error(ma_params, ARRAY[0.701393608306]) < 1e-2, 'ARIMA: wrong ma_params') from tsa_out;
select assert(relative_error(ma_std_errors, ARRAY[0.0969171335486]) < 1e-2, 'ARIMA: wrong ma_std_errors') from tsa_out;
select assert(relative_error(residual_variance, 304.217719576) < 1e-2, 'ARIMA: wrong residual_variance') from tsa_out_summary;
select assert(relative_error(log_likelihood, -209.61270701) < 1e-2, 'ARIMA: wrong log_likelihood') from tsa_out_summary;
-- FALSE, ARRAY[1,1,1]
drop table if exists tsa_out;
drop table if exists tsa_out_summary;
drop table if exists tsa_out_residual;
select arima_train('mini_ts', 'tsa_out', 'id', 'val', NULL, FALSE, ARRAY[1,1,1]);
select assert(relative_error(ar_params, ARRAY[0.16327119476]) < 1e-2, 'ARIMA: wrong ar_params') from tsa_out;
select assert(relative_error(ar_std_errors, ARRAY[0.211608737666]) < 1e-2, 'ARIMA: wrong ar_std_errors') from tsa_out;
select assert(relative_error(ma_params, ARRAY[0.630297255402]) < 1e-2, 'ARIMA: wrong ma_params') from tsa_out;
select assert(relative_error(ma_std_errors, ARRAY[0.163395070851]) < 1e-2, 'ARIMA: wrong ma_std_errors') from tsa_out;
select assert(relative_error(residual_variance, 322.217055379) < 1e-2, 'ARIMA: wrong residual_variance') from tsa_out_summary;
select assert(relative_error(log_likelihood, -206.714459277) < 1e-2, 'ARIMA: wrong log_likelihood') from tsa_out_summary;
-- FALSE, ARRAY[1,0,0]
drop table if exists tsa_out;
drop table if exists tsa_out_summary;
drop table if exists tsa_out_residual;
select arima_train('mini_ts', 'tsa_out', 'id', 'val', NULL, FALSE, ARRAY[1,0,0]);
select assert(relative_error(ar_params, ARRAY[0.90180701677]) < 1e-2, 'ARIMA: wrong ar_params') from tsa_out;
select assert(relative_error(ar_std_errors, ARRAY[0.0524855716423]) < 1e-2, 'ARIMA: wrong ar_std_errors') from tsa_out;
select assert(relative_error(residual_variance, 501.798665305) < 1e-2, 'ARIMA: wrong residual_variance') from tsa_out_summary;
select assert(relative_error(log_likelihood, -221.873862993) < 1e-2, 'ARIMA: wrong log_likelihood') from tsa_out_summary;
-- FALSE, ARRAY[0,0,1]
drop table if exists tsa_out;
drop table if exists tsa_out_summary;
drop table if exists tsa_out_residual;
select arima_train('mini_ts', 'tsa_out', 'id', 'val', NULL, FALSE, ARRAY[0,0,1]);
select assert(relative_error(ma_params, ARRAY[0.794860003635]) < 1e-2, 'ARIMA: wrong ma_params') from tsa_out;
select assert(relative_error(ma_std_errors, ARRAY[0.0625911839965]) < 1e-2, 'ARIMA: wrong ma_std_errors') from tsa_out;
select assert(relative_error(residual_variance, 1436.32174849) < 1e-2, 'ARIMA: wrong residual_variance') from tsa_out_summary;
select assert(relative_error(log_likelihood, -247.639087319) < 1e-2, 'ARIMA: wrong log_likelihood') from tsa_out_summary;