Chapter 3: Parameter estimation, forecasting, gap filling
Here you can find the code listings in R
language from the corresponding chapter of the book.
You need to load Rssa
, ssabook
, lattice
, latticeExtra
, plyr
, fma
to run these examples.
Contents
- Chapter 3: Parameter estimation, forecasting, gap filling
- Fragment 3.1.1 (LRRs and roots of characteristic polynomials)
- Produced output
- Fragment 3.1.2 (Parameter estimation for ‘CO2’)
- Produced output
- Fragment 3.2.1 (Forecasting of ‘CO2’)
- Produced output
- Fragment 3.3.1 (Subspace-based gap filling)
- Produced output
- Fragment 3.3.2 (Iterative gap filling, one gap)
- Produced output
- Fragment 3.3.3 (Iterative gap filling, several gaps)
- Produced output
- Fragment 3.4.1 (Weighted Cadzow approximation)
- Produced output
- Fragment 3.4.2 (Accuracy of weighted Cadzow approximation)
- Produced output
- Fragment 3.5.1 (‘Elec’: trend forecasting and iossa)
- Produced output
- Fragment 3.5.2 (‘Elec’: combined forecasting)
- Produced output
- Fragment 3.5.3 (‘Cowtemp’: different methods of forecasting)
- Produced output
- Fragment 3.5.4 (Function for perturbed forecasting intervals)
- Fragment 3.5.5 (‘Total’: stability of forecasting)
- Produced output
- Fragment 3.5.6 (‘Glonass’: gap filling)
- Produced output
-
- Produced output
- Fragment 3.5.8 (‘FORT’: Cadzow iterations)
- Produced output
- Fragment 3.5.9 (‘FORT’: Estimation of parameters by Basic SSA)
- Produced output
- Fragment 3.5.10 (‘FORT’: Estimation of parameters by Cadzow iterations)
- Produced output
- Fragment 3.5.11 (‘FORT’: Estimation of parametric real-valued form)
- Produced output
- Fragment 3.5.12 (‘Sunspots’: Subspace tracking)
- Produced output
- Fragment 3.5.13 (Functions for the search of optimal parameters)
- Fragment 3.5.14 (‘Bookings’: Search for optimal parameters)
- Produced output
- Fragment 3.5.15 (‘Bookings’: Forecast with optimal parameters)
- Produced output
- Fragments 3.5.16 (‘Sweetwhite’: training and test periods) and 3.5.17 (‘Sweetwhite’: Search for SSA parameters)
- Fragment 3.5.18 (‘Sweetwhite’: Comparison of SSA, ARIMA and ETS)
- Produced output
Fragment 3.1.1 (LRRs and roots of characteristic polynomials)
Produced output
Exponential signal: One signal and four extraneous roots.
[1] 1.01
attr(,"class")
[1] "lrr"
[1] 1.01
[1] -1 2
attr(,"class")
[1] "lrr"
[1] 1.0000003 0.9999997
Fragment 3.1.2 (Parameter estimation for ‘CO2’)
Produced output
‘CO2’: Six signal roots.
period rate | Mod Arg | Re Im
11.995 0.000000 | 1.00000 0.52 | 0.86592 0.50019
period rate | Mod Arg | Re Im
11.995 0.000542 | 1.00054 0.52 | 0.86638 0.50047
-11.995 0.000542 | 1.00054 -0.52 | 0.86638 -0.50047
5.999 0.000512 | 1.00051 1.05 | 0.50015 0.86653
-5.999 0.000512 | 1.00051 -1.05 | 0.50015 -0.86653
Inf 0.000375 | 1.00037 0.00 | 1.00037 0.00000
Inf -0.008308 | 0.99173 -0.00 | 0.99173 -0.00000
Fragment 3.2.1 (Forecasting of ‘CO2’)
Produced output
‘CO2’: A set of recurrent forecasts.
‘CO2’: Forecast of trend.
‘CO2’: Backward forecast of the signal.
‘CO2’: Plots of confidence and prediction intervals for the forecast.
Fragment 3.3.1 (Subspace-based gap filling)
Produced output
‘CO2’: Subspace-based gap filling, from the left,
from the right, and their combination.
Fragment 3.3.2 (Iterative gap filling, one gap)
Produced output
‘CO2’: Iterative gap filling of trend.
‘CO2’: Iterative gap filling of trend: convergence.
Fragment 3.3.3 (Iterative gap filling, several gaps)
Produced output
[1] 0.1132225
[1] 0.1425962
‘CO2’: Iterative and simultaneous subspace-based gap filling of trend: randomly located gaps.
Fragment 3.4.1 (Weighted Cadzow approximation)
Produced output
‘CO2’: Approximation of rank 6 by the weighted Cadzow method and its forecast.
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,] 16472 73.537 41.096 12.29 4.674 0.044457 0
period rate | Mod Arg | Re Im
11.998 0.000525 | 1.00053 0.52 | 0.86643 0.50035
-11.998 0.000525 | 1.00053 -0.52 | 0.86643 -0.50035
Inf 0.000451 | 1.00045 0.00 | 1.00045 0.00000
5.998 0.000287 | 1.00029 1.05 | 0.49986 0.86644
-5.998 0.000287 | 1.00029 -1.05 | 0.49986 -0.86644
Inf -0.004623 | 0.99539 0.00 | 0.99539 0.00000
Fragment 3.4.2 (Accuracy of weighted Cadzow approximation)
Warning: this example takes a lot of computational time.
Produced output
err err.alpha
1 0.3753331 0.3222088
Fragment 3.5.1 (‘Elec’: trend forecasting and iossa)
Produced output
‘Elec’: Trend forecasting.
Fragment 3.5.2 (‘Elec’: combined forecasting)
Produced output
‘Elec’: Combined forecasting.
Fragment 3.5.3 (‘Cowtemp’: different methods of forecasting)
Produced output
[1] 5.711485
[1] 5.253602
[1] 4.785783
‘Cowtemp’: Basic SSA and Toeplitz SSA forecasting.
Fragment 3.5.4 (Function for perturbed forecasting intervals)
Fragment 3.5.5 (‘Total’: stability of forecasting)
Produced output
‘Total’: w-Correlations.
‘Total’: Sizes of 90% forecasting intervals in dependence on the number of components.
‘Total’: Perturbed forecasting intervals, ET1.
‘Total’: Perturbed forecasting intervals, ET1–12.
‘Total’: Perturbed forecasting intervals, ET1–14.
‘Total’: Comparison of forecasts by ET1–12 and ET1–14.
Fragment 3.5.6 (‘Glonass’: gap filling)
Produced output
‘Glonass’: Initial series with gaps.
‘Glonass’: A subseries with a gap (left) and with the suppressed gap (right).
‘Glonass’: Eigenvectors for the series with gaps, L=72.
‘Glonass’: A subseries with the filled gap.
‘Glonass’: Periodogram of the series with suppressed gaps.
‘Glonass’: Periodogram of the series with filled gaps.
Produced output
‘Glonass’: A subseries with the 12-hours periodicity; it is extracted from the series with filled gaps and L=52416.
Fragment 3.5.8 (‘FORT’: Cadzow iterations)
Produced output
‘FORT’: Approximation by a series of finite rank.
Fragment 3.5.9 (‘FORT’: Estimation of parameters by Basic SSA)
Produced output
period rate | Mod Arg | Re Im
5.972 0.004238 | 1.00425 1.05 | 0.49781 0.87218
-5.972 0.004238 | 1.00425 -1.05 | 0.49781 -0.87218
2.388 0.001744 | 1.00175 2.63 | -0.87403 0.48945
-2.388 0.001744 | 1.00175 -2.63 | -0.87403 -0.48945
4.000 0.000359 | 1.00036 1.57 | -0.00008 1.00036
-4.000 0.000359 | 1.00036 -1.57 | -0.00008 -1.00036
Inf -0.003318 | 0.99669 0.00 | 0.99669 0.00000
12.006 -0.005931 | 0.99409 0.52 | 0.86104 0.49680
-12.006 -0.005931 | 0.99409 -0.52 | 0.86104 -0.49680
3.015 -0.011285 | 0.98878 2.08 | -0.48570 0.86127
-3.015 -0.011285 | 0.98878 -2.08 | -0.48570 -0.86127
X1 X2 X3 X4 X5 X6
3969.23 -717.10 -927.57 105.52 137.98 -287.11
X7 X8 X9 X10 X11
215.64 -254.51 -205.12 90.44 10.95
Fragment 3.5.10 (‘FORT’: Estimation of parameters by Cadzow iterations)
Produced output
period rate | Mod Arg | Re Im
5.975 0.004986 | 1.00500 1.05 | 0.49863 0.87258
-5.975 0.004986 | 1.00500 -1.05 | 0.49863 -0.87258
2.389 0.003402 | 1.00341 2.63 | -0.87506 0.49102
-2.389 0.003402 | 1.00341 -2.63 | -0.87506 -0.49102
3.998 0.000311 | 1.00031 1.57 | -0.00076 1.00031
-3.998 0.000311 | 1.00031 -1.57 | -0.00076 -1.00031
Inf -0.003356 | 0.99665 0.00 | 0.99665 0.00000
12.009 -0.005985 | 0.99403 0.52 | 0.86105 0.49669
-12.009 -0.005985 | 0.99403 -0.52 | 0.86105 -0.49669
3.018 -0.010620 | 0.98944 2.08 | -0.48394 0.86301
-3.018 -0.010620 | 0.98944 -2.08 | -0.48394 -0.86301
X1 X2 X3 X4 X5 X6
4005.56 -721.77 -940.64 68.30 184.45 -269.52
X7 X8 X9 X10 X11
325.92 -251.10 -255.41 154.28 61.90
Produced output
[1] "trend:"
[1] "coefficient * modulus^n"
coefficients moduli
X1 4005.561 0.9966493
[1] "periodics:"
[1] "coefficient * modulus^n * cos(2 * pi* n/period + phase)"
periods phases coefficients moduli
1 12.008804 -2.225294 1185.6458 0.9940328
2 5.974637 1.216171 196.6835 1.0049988
3 3.998061 2.261753 422.9253 1.0003111
4 3.018060 -2.347688 358.1681 0.9894363
5 2.388825 0.381569 166.2372 1.0034081
Fragment 3.5.12 (‘Sunspots’: Subspace tracking)
Produced output
‘Sunspots’: Trend extraction (top), subspace tracking of residuals
with B=22 (middle) and B=44 (bottom).
'Sunspots': Heterogeneity matrices
B=22 (left) and B=44 (right).
Fragment 3.5.13 (Functions for the search of optimal parameters)
Fragment 3.5.14 (‘Bookings’: Search for optimal parameters)
Produced output
‘Bookings’: Dependence of RMSE on L for different numbers of components.
Fragment 3.5.15 (‘Bookings’: Forecast with optimal parameters)
Produced output
‘Bookings’: Forecast with optimal parameters.
‘Bookings’: Forecast with optimal parameters for last points.
Fragments 3.5.16 (‘Sweetwhite’: training and test periods) and 3.5.17 (‘Sweetwhite’: Search for SSA parameters)
Fragment 3.5.18 (‘Sweetwhite’: Comparison of SSA, ARIMA and ETS)
Produced output
Series: F.base
ARIMA(1,1,0)(2,0,0)[12]
Box Cox transformation: lambda= 0
Coefficients:
ar1 sar1 sar2
-0.4165 0.4847 0.2123
s.e. 0.0722 0.0765 0.0813
sigma^2 estimated as 0.03897: log likelihood=30.78
AIC=-53.55 AICc=-53.29 BIC=-41.22
ETS(M,N,M)
Call:
ets(y = F.base)
Smoothing parameters:
alpha = 0.5571
gamma = 1e-04
Initial states:
l = 123.5798
s=1.4262 1.2408 1.0236 1.0546 1.1188 1.0852
0.7795 0.8136 0.8903 0.8834 0.8241 0.8598
sigma: 0.1732
AIC AICc BIC
2026.600 2029.887 2072.913
[1] "SSA(L,r)" "108" "8"
[1] "ssa" "55.3572366330605"
[1] "sarima" "60.1534718580799"
[1] "ets" "54.2338009066311"
‘Sweetwhite’: ETS forecast with optimal parameters.
‘Sweetwhite’: ARIMA forecast with optimal parameters.
‘Sweetwhite’: SSA forecast with optimal parameters.