Skip to contents

Objects and methods for filters with more than one set of coefficients.

Objects from the Class

Objects can be created by calls of the form new("MultiFilter", coef, mc, order, sign).

Objects from this class represent periodic filters. A \(d\)-periodic filter relates an input series \(\varepsilon_{t}\) to an output series \(y_t\) by the following formula: $$ y_t = \sum_{i=1}^{p_t} \phi _t(i)y _{t-i} % + \sum_{i=1}^{q_t} \theta_t(i)\varepsilon_{t-i} + \varepsilon_t , $$ where the coefficients \(\phi_t(i)\) are \(d\)-periodic in \(t\), i.e. \(\phi_{t+d}(i)=\phi_t(i)\) and \(p_{t+d} = p_{t}\).

The periodicity means that it is sufficient to store the coefficients in a \(d \times p\) matrix, where \(p=\max(p_1,\dots,p_t)\). Slot coef contains such a matrix.

The filter may be specified either by its coefficients or by its multi-companion form.

Slots

mc:

the multi-companion form of the filter, an object of class "MultiCompanion"

coef:

the coefficients of the filter, an object of class "matrix", whose \(s\)th row contains the coefficients for \(t=k \times d +s\).

order:

the periodic order of the filter, a numeric vector giving the orders of the individual seasons.

sign:

1 or -1. The default value, 1, corresponds to the formula given in section "Objects from the Class". It can also be -1, if the sum on the right-hand side of that formula is preceded by a minus (usual convention in signal processing).

Methods

[

signature(x = "MultiFilter", i = "ANY", j = "ANY", drop = "ANY"): take subset of the coefficients of the filter in various forms.

To do: the function needs more work! Document the function and the additional arguments!

initialize

signature(.Object = "MultiFilter"): This function is called implicitly by new, see the signature for new above. One of mc and coef must be supplied, the other arguments are optional.

If mc is missing it is computed from coef. In this case, component mC.factorsmat of slot misc of mc is set to the companion factorisation of mc (essentially the reversed rows of coef).

If coef is missing it is computed from mc, see mc_factors.

mcStable

signature(x = "MultiFilter"): Check if the filter is stable.

See also the documentation for the following functions which are effectively methods for class "MuliFilter" but are not defined as formal methods: mf_period, mf_order, mf_poles, mf_VSform.

References

Boshnakov GN (2002). “Multi-companion matrices.” Linear Algebra Appl., 354, 53--83. ISSN 0024-3795, doi:10.1016/S0024-3795(01)00475-X .

Boshnakov GN, Iqelan BM (2009). “Generation of time series models with given spectral properties.” J. Time Series Anal., 30(3), 349--368. ISSN 0143-9782, doi:10.1111/j.1467-9892.2009.00617.x .

Author

Georgi N. Boshnakov

Examples

showClass("MultiFilter")
#> Class "MultiFilter" [package "mcompanion"]
#> 
#> Slots:
#>                                                                   
#> Name:              mc           coef          order           sign
#> Class: MultiCompanion         matrix        numeric        numeric

m <- mCompanion("sim",dim=3,mo=2)   # simulate a 3x3 2-comp. matrix
flt <- new("MultiFilter", mc = m )
flt[]
#>           [,1]      [,2]       [,3]
#> [1,] 0.9314670 1.0748286 -0.8247236
#> [2,] 0.8357038 0.7909081 -0.9945626
mf_period(flt)
#> [1] 2
mf_poles(flt)
#> [1] 0.9924983+0.0000000i 0.8258344+0.3800479i 0.8258344-0.3800479i
abs(mf_poles(flt))
#> [1] 0.9924983 0.9090869 0.9090869

mf_VSform(flt,form="U")
#> $Phi0
#>      [,1]       [,2]
#> [1,]    1 -0.8357038
#> [2,]    0  1.0000000
#> 
#> $Phi
#>           [,1]       [,2]       [,3] [,4]
#> [1,] 0.7909081 -0.9945626  0.0000000    0
#> [2,] 0.9314670  1.0748286 -0.8247236    0
#> 
mf_VSform(flt,form="L")
#> $Phi0
#> 2 x 2 Matrix of class "dgeMatrix"
#>            [,1] [,2]
#> [1,]  1.0000000    0
#> [2,] -0.8357038    1
#> 
#> $Phi
#>            [,1]      [,2] [,3]       [,4]
#> [1,]  1.0748286 0.9314670    0 -0.8247236
#> [2,] -0.9945626 0.7909081    0  0.0000000
#> 
mf_VSform(flt,form="I")
#> $Phi0
#>      [,1] [,2]
#> [1,]    1    0
#> [2,]    0    1
#> 
#> $Phi
#>          [,1]        [,2]       [,3] [,4]
#> [1,] 1.569339 -0.09632422 -0.6892247    0
#> [2,] 0.931467  1.07482860 -0.8247236    0
#> 
#> $Phi0inv
#>      [,1]      [,2]
#> [1,]    1 0.8357038
#> [2,]    0 1.0000000
#> 


# try arguments "coef" and "mc", for comparison
rfi <- sim_pcfilter(2,3) # period=2, order=c(3,3)
# per. filter from a multi-companion matrix
flt1 <- new("MultiFilter",mc=  mCompanion(zapsmall(rfi$mat)) )
flt1[]
#>            [,1]      [,2]         [,3]
#> [1,]  8.0593210 0.2601110 -0.705949000
#> [2,] -0.1030457 0.2342773 -0.003832683
mf_period(flt1)
#> [1] 2
mf_poles(flt1)
#> [1] -0.19899199+0.0641632i -0.19899199-0.0641632i  0.06189398+0.0000000i
abs(mf_poles(flt1))
#> [1] 0.20908069 0.20908069 0.06189398

mf_VSform(flt1,form="U")
#> $Phi0
#>      [,1]      [,2]
#> [1,]    1 0.1030457
#> [2,]    0 1.0000000
#> 
#> $Phi
#>           [,1]         [,2]      [,3] [,4]
#> [1,] 0.2342773 -0.003832683  0.000000    0
#> [2,] 8.0593210  0.260111000 -0.705949    0
#> 
mf_VSform(flt1,form="L")
#> $Phi0
#> 2 x 2 Matrix of class "dgeMatrix"
#>           [,1] [,2]
#> [1,] 1.0000000    0
#> [2,] 0.1030457    1
#> 
#> $Phi
#>              [,1]      [,2] [,3]      [,4]
#> [1,]  0.260111000 8.0593210    0 -0.705949
#> [2,] -0.003832683 0.2342773    0  0.000000
#> 
mf_VSform(flt1,form="I")
#> $Phi0
#>      [,1] [,2]
#> [1,]    1    0
#> [2,]    0    1
#> 
#> $Phi
#>           [,1]      [,2]      [,3] [,4]
#> [1,] -0.596201 -0.030636  0.072745    0
#> [2,]  8.059321  0.260111 -0.705949    0
#> 
#> $Phi0inv
#>      [,1]       [,2]
#> [1,]    1 -0.1030457
#> [2,]    0  1.0000000
#> 

# per. filter from coefficients, should be the same (numerically)
flt2 <- new("MultiFilter",coef=rfi$pcfilter)
flt2[]
#>            [,1]      [,2]        [,3]
#> [1,]  8.0593207 0.2601113 -0.70594925
#> [2,] -0.1030461 0.2342807 -0.00383217
mf_period(flt2)
#> [1] 2
mf_poles(flt2)
#> [1] -0.1989909+0.0641321i -0.1989909-0.0641321i  0.0618920+0.0000000i
abs(mf_poles(flt2))
#> [1] 0.2090701 0.2090701 0.0618920

mf_VSform(flt2,form="U")
#> $Phi0
#>      [,1]      [,2]
#> [1,]    1 0.1030461
#> [2,]    0 1.0000000
#> 
#> $Phi
#>           [,1]        [,2]       [,3] [,4]
#> [1,] 0.2342807 -0.00383217  0.0000000    0
#> [2,] 8.0593207  0.26011131 -0.7059493    0
#> 
mf_VSform(flt2,form="L")
#> $Phi0
#> 2 x 2 Matrix of class "dgeMatrix"
#>           [,1] [,2]
#> [1,] 1.0000000    0
#> [2,] 0.1030461    1
#> 
#> $Phi
#>             [,1]      [,2] [,3]       [,4]
#> [1,]  0.26011131 8.0593207    0 -0.7059493
#> [2,] -0.00383217 0.2342807    0  0.0000000
#> 
mf_VSform(flt2,form="I")
#> $Phi0
#>      [,1] [,2]
#> [1,]    1    0
#> [2,]    0    1
#> 
#> $Phi
#>            [,1]        [,2]        [,3] [,4]
#> [1,] -0.5962011 -0.03063563  0.07274533    0
#> [2,]  8.0593207  0.26011131 -0.70594925    0
#> 
#> $Phi0inv
#>      [,1]       [,2]
#> [1,]    1 -0.1030461
#> [2,]    0  1.0000000
#>