foreca: Forecastable Component Analysis

Description Usage Arguments Value Warning References Examples

View source: R/foreca.R

Description

foreca performs Forecastable Component Analysis (ForeCA) on \mathbf{X}_t – a K-dimensional time series with T observations. Users should only call foreca, rather than foreca.one_weightvector or foreca.multiple_weightvectors.

foreca.one_weightvector is a wrapper around several algorithms that solve the ForeCA optimization problem for a single weightvector \mathbf{w}_i and whitened time series \mathbf{U}_t.

foreca.multiple_weightvectors applies foreca.one_weightvector iteratively to \mathbf{U}_t in order to obtain multiple weightvectors that yield most forecastable, uncorrelated signals.

Usage

1
2
3
4
5
6
7
8
9
foreca(series, n.comp = 2, algorithm.control = list(type = "EM"), ...)

foreca.one_weightvector(U, f.U = NULL, spectrum.control = list(),
  entropy.control = list(), algorithm.control = list(),
  keep.all.optima = FALSE, dewhitening = NULL, ...)

foreca.multiple_weightvectors(U, spectrum.control = list(),
  entropy.control = list(), algorithm.control = list(), n.comp = 2,
  plot = FALSE, dewhitening = NULL, ...)

Arguments

series

a T \times K array with T observations from the K-dimensional time series \mathbf{X}_t. Can be a matrix, data.frame, or a multivariate ts object.

n.comp

positive integer; number of components to be extracted. Default: 2.

algorithm.control

list; control settings for any iterative ForeCA algorithm. See complete_algorithm_control for details.

...

additional arguments passed to available ForeCA algorithms.

U

a T \times K array with T observations from the K-dimensional whitened (whiten) time series \mathbf{U}_t. Can be a matrix, data.frame, or a multivariate ts object.

f.U

multivariate spectrum of class 'mvspectrum' with normalize = TRUE.

spectrum.control

list; control settings for spectrum estimation. See complete_spectrum_control for details.

entropy.control

list; control settings for entropy estimation. See complete_entropy_control for details.

keep.all.optima

logical; if TRUE, it keeps the optimal solutions of each random start. Default: FALSE (only returns the best solution).

dewhitening

optional; if provided (returned by whiten) then it uses the dewhitening transformation to obtain the original series \mathbf{X}_t and it uses that vector (normalized) as the initial weightvector which corresponds to the series \mathbf{X}_{t,i} with larges Omega.

plot

logical; if TRUE a plot of the current optimal solution \mathbf{w}_i^* will be shown and updated for each iteration i = 1, ..., n.comp of any iterative algorithm. Default: FALSE.

Value

An object of class foreca, which is similar to the output from princomp, with the following components (amongst others):

ForeCs are ordered from most to least forecastable (according to Omega).

Warning

Estimating Omega directly from the ForeCs \mathbf{F}_t can be different to the reported $Omega estimates from foreca. Here is why:

In theory f_y(λ) of a linear combination y_t = \mathbf{X}_t \mathbf{w} can be analytically computed from the multivariate spectrum f_{\mathbf{X}}(λ) by the quadratic form f_y(λ) = \mathbf{w}' f_{\mathbf{X}}(λ) \mathbf{w} for all λ (see spectrum_of_linear_combination).

In practice, however, this identity does not hold always exactly since (often data-driven) control setting for spectrum estimation are not identical for the high-dimensional, noisy \mathbf{X}_t and the combined univariate time series y_t (which is usually more smooth, less variable). Thus estimating \widehat{f}_y directly from y_t can give slightly different estimates to computing it as \mathbf{w}'\widehat{f}_{\mathbf{X}}\mathbf{w}. Consequently also Omega estimates can be different.

In general, these differences are small and have no relevant implications for estimating ForeCs. However, especially for rare occasions, the obtained ForeCs can have smaller Omega than the maximum Omega of the original series. In such a case users should not re-estimate Ω from the resulting ForeCs \mathbf{F}_t, but access them via $Omega provided by 'foreca' output (the univariate estimates are stored in $Omega.univ).

References

Goerg, G. M. (2013). “Forecastable Component Analysis”. Journal of Machine Learning Research (JMLR) W&CP 28 (2): 64-72, 2013. Available at jmlr.org/proceedings/papers/v28/goerg13.html.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
XX <- diff(log(EuStockMarkets[c(100:200),])) * 100
plot(ts(XX))
## Not run: 
ff <- foreca(XX[,1:4], n.comp = 2, plot = TRUE)
ff
summary(ff)
plot(ff)

## End(Not run)


PW <- whiten(XX)
one.weight.em <- foreca.one_weightvector(U = PW$U,
                                        dewhitening = PW$dewhitening,
                                        algorithm.control = 
                                          list(num.starts = 2,
                                               type = "EM"),
                                        spectrum.control = 
                                          list(method = 'wosa'))
plot(one.weight.em)

## Not run: 

PW <- whiten(XX)
ff <- foreca.multiple_weightvectors(PW$U, n.comp = 2,
                                    dewhitening = PW$dewhitening)
ff
plot(ff$scores)

## End(Not run)

Example output

Loading required package: ifultools
This is 'ForeCA' version 0.2.4. Please see the NEWS file and citation("ForeCA").
May the ForeC be with you.
ForeCA found the top 2 ForeCs of 'XX[, 1:4]' (4 time series).
Out of the top 2 ForeCs, 0 are white noise.

Omega(ForeC 1) = 3.32% vs. maximum Omega(XX[, 1:4]) = 3.26%.
This is an absolute increase of 0.06 percentage points (relative: 1.86%) in forecastability.

* * * * * * * * * * 
Use plot(), biplot(), and summary() for more details.

$p.value
ForeC1 ForeC2 
0.0056 0.0222 

$p.value.orig
   DAX    SMI    CAC   FTSE 
0.5204 0.0030 0.2594 0.8591 

$Omega
  ForeC1   ForeC2 
3.324637 2.194882 

$Omega.univ
[1] 3.318252 2.192656

$Omega.orig
      DAX       SMI       CAC      FTSE 
1.1730051 3.2576248 0.9435620 0.8751892 
attr(,"unit")
[1] "%"

$alpha
[1] 0.05

$lag
[1] 10

$selected
ForeC1 ForeC2 
     1      2 

$spectrum.control
$spectrum.control$method
[1] "wosa"

$spectrum.control$smoothing
[1] FALSE


$entropy.control
$entropy.control$base
[1] 100

$entropy.control$method
[1] "MLE"

$entropy.control$prior.probs
  [1] 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01
 [16] 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01
 [31] 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01
 [46] 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01
 [61] 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01
 [76] 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01
 [91] 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01

$entropy.control$prior.weight
[1] 0.001

$entropy.control$threshold
[1] 0


$algorithm.control
$algorithm.control$tol
[1] 1e-06

$algorithm.control$type
[1] "EM"

$algorithm.control$max.iter
[1] 50

$algorithm.control$num.starts
[1] 10


$weightvectors

Loadings:
     [,1]   [,2]  
[1,] -0.250 -0.647
[2,] -0.905  0.215
[3,] -0.285  0.330
[4,] -0.194 -0.653

               [,1] [,2]
SS loadings    1.00 1.00
Proportion Var 0.25 0.25
Cumulative Var 0.25 0.50

$scores
Time Series:
Start = 1 
End = 100 
Frequency = 1 
          ForeC1      ForeC2
  1  2.536575413 -0.09346581
  2  1.408359231  0.41438481
  3  0.365349115 -0.75432111
  4  0.717251097 -1.05799727
  5  1.489444650 -0.90881152
  6  1.693335452 -0.55812565
  7 -1.467085566  0.16899059
  8  1.053274363  1.16864019
  9  0.317724863  0.70812541
 10  1.330904049  0.38823139
 11  2.185186173 -0.58231473
 12 -1.406549919  1.16383383
 13 -1.194941294 -0.43075190
 14  1.392224006 -0.76909029
 15  0.233524140  0.05145612
 16 -0.488387480 -2.27481715
 17  0.420283857  0.24858251
 18  1.259966902  0.68399128
 19 -0.900185227 -0.86526066
 20 -1.250305767 -0.47360129
 21 -0.013421691  1.36099222
 22 -0.090244120  0.12602912
 23 -0.023153909 -0.02724060
 24  0.944066051  0.39655617
 25  0.778405410  0.57262762
 26  0.266693552 -0.03850779
 27 -2.026012804  2.43246223
 28  0.072600402 -0.07702124
 29  0.306662938  0.93199644
 30 -2.479223072 -2.32994756
 31 -0.976682042  0.30732697
 32  0.414111202 -2.55866492
 33  0.072600402 -0.07702124
 34  0.105037010 -2.64705959
 35 -2.858126226  1.45352134
 36 -0.498058904  1.48781609
 37  0.928089507  0.47240769
 38  0.965951095  1.53398375
 39 -1.615098398  0.11508496
 40 -0.544464203  0.08026223
 41  0.405236234 -1.98310957
 42 -1.010198677 -0.57875489
 43 -2.813255057 -0.98942763
 44  1.085529281 -1.46012339
 45  1.298285306 -0.95195947
 46 -0.002337001 -1.45777309
 47 -0.358015899  0.15588821
 48 -0.198779254  0.41995818
 49  0.291807153  0.21874259
 50  0.017043108  1.33007226
 51 -1.088003700 -1.33727999
 52  0.435814544  0.21826885
 53  1.434762538  0.13849039
 54  0.392486423 -1.68906836
 55 -0.444996556 -0.86627244
 56 -0.047755680 -0.32976078
 57 -0.003970903  0.66043359
 58 -0.863807453  0.70347585
 59 -1.098961560  1.08286398
 60 -0.142591776  0.62751290
 61 -0.401748793 -0.37136901
 62 -1.145148167  0.95385116
 63  0.442995921 -0.26399639
 64  0.074376616  0.98052092
 65  1.233743500 -0.43545738
 66 -0.440519922 -1.28612257
 67  0.015902418 -0.06049340
 68  0.892254717  0.99803554
 69 -0.818936489 -0.07067358
 70 -0.175908087  0.58814319
 71 -0.699452705 -1.33694869
 72  0.245190132  0.49769665
 73 -0.439396141 -1.57667249
 74 -0.433489280  0.34865761
 75 -1.004628936  0.30720813
 76  0.006729442 -0.04535918
 77 -0.207388385 -1.39664300
 78 -0.231712586  0.70706386
 79  0.862272402 -0.23388064
 80  1.521854561  0.33477606
 81  0.671769598 -1.33393789
 82 -0.216148684 -0.24248734
 83  0.849561084  1.83315578
 84  1.058600962  0.88041480
 85 -1.129529832  0.76570678
 86  0.476299603  0.08421154
 87 -1.405328197 -0.38835989
 88 -0.328742492  0.95209000
 89 -1.127073580  0.50384038
 90 -0.256840869  0.07848126
 91  1.246725907 -0.14884926
 92 -0.293701294 -0.35824344
 93 -0.130743501  0.90411337
 94 -0.343444913  0.15678031
 95  0.374786342  1.97328047
 96 -0.519178292 -0.40537876
 97  0.243802577  0.08324443
 98  0.714027107  1.39492209
 99 -0.652907604 -0.27540190
100  0.757104530  1.24862063

$h
[1] 0.9666925 0.9780082

$Omega
  ForeC1   ForeC2 
3.324636 2.194883 

$Omega.univ
[1] 3.318030 2.193565

$weights
$weights[[1]]
       Series 1   Series 2   Series 3   Series 4
[1,] -0.2502311 -0.9046294 -0.2852355 -0.1940896

$weights[[2]]
      Series 1  Series 2   Series 3
[1,] 0.6827558 0.4775337 -0.5529974


attr(,"class")
[1] "foreca.multiple_weightvectors"

ForeCA documentation built on May 29, 2017, 9:09 a.m.