mf_VSform: Extract properties of multi-filters

View source: R/class_MF.R

mf_VSformR Documentation

Extract properties of multi-filters

Description

Extract properties for scalar and vector of seasons forms of multi-filters.

Usage

mf_order(x, i = "max", form = "pc", perm)
mf_period(x)
mf_poles(x, blocks = FALSE)
mf_VSform(x, first = 1, form = "U", perm)

Arguments

x

the filter, an object of class "MultiFilter".

i

index, integer vector or a string.

first

the first season of the year.

form

the form of the filter to which the result refers, one of "pc", "I", "U", or "L", see Details.

perm

permutation of the seasons within the year.

blocks

request lengths of Jordan chains.

Details

With the default i=="max" the function mf_order returns a single number, the order of the filter in the representation requested by form. The orders of the components may be obtained with the setting i=="all" which gives a vector whose j-th element is the order of the j-th component of the filter. A subset of these may be obtained with numeric i which is treated as standard index vector. Values for i other than the default are meaningful mainly for form="pc".

mf_VSform arranges the filter coefficients in one of the vector of seasons forms (todo: cite me). The component Phi of the result is a matrix obtained by putting the coefficient matrices next to each other, [A1 ... Ad]. If perm is provided, then the result is the same for "U" and "L".

mf_VSform is called implicitly by the subscripting operation ("[") when needed, it is more flexible and is recommended for general use.

For the vector forms ("I", "U", and "L") the argument perm specifies the arrangement of the components of the filter in that form. For the I- and U-forms the default is mf_period(x):1, for the L-form it is 1:mf_period(x).

Currently perm may take on values that can be obtained from the default by rotation, e.g. if the period is 4, perm may be one of (4,3,2,1), (1,4,3,2), (2,1,4,3), (3,2,1,4) for the U-form, and (1,2,3,4), (4,1,2,3), (3,4,1,2), (2,3,4,1) for the L-form. Other permutations may be usefull in some situations but may not result in U- or L- forms (without further transformations). For I-form any permutation should be permissible when implemented (todo:).

For mf_order the argument perm affects the computation only, not the ordering in the result. The result (if vector) is not permuted unless the argument i asks for this. For mf_VSform however such a behaviour would be very peculiar and the rows of the result are for the permuted seasons. In short, the i-th element of the result of mf_order (if vector) gives the order (in the requested form) of the i-th season but the i-th row of any of the matrices returned by mf_VSform depends on perm and form.

Note: the terminology here reflects application to pc processes, probably should be made more neutral in this respect.

todo: (2013-03-26) mf_order seems unfinished.

Value

For mf_order, if i = "max" a positive integer, otherwise a vector of positive integers.

For mf_period the period of the filter, a positive integer.

For mf_poles, if blocks = FALSE, a vector of the eigenvalues of the associated multi-companion matrix, each eigenvalue repeated according to its algebraic multiplicity. If blocks = TRUE, a 2-column matrix with the eigenvalues in the first column and the lengths of the Jordan chains in the second. There is one row for each chain (i.e. multiple eigenvalues are repeated according to their geometric multiplicity).

For mf_VSform a list with components:

Phi0

the zero lag coefficient, a matrix,

Phi

the remaining coefficients, a matrix,

Phi0inv

(form=="I" only) the inverse of the zero lag coefficient matrix of the vs-form, a matrix. (TODO: the name of this component is misleading since in the case form = "I" Phi0 is the identity matrix and Phi0inv is not equal to the inverse of Phi0.)

Author(s)

Georgi N. Boshnakov

References

\insertRef

boshnakov2002mcmcompanion

\insertRef

boshnakov2009genmcompanion

See Also

MultiFilter and the examples there, mcStable

Examples

## simulate a 3x3 2-companion matrix
##  and turn it into a multi-filter
(m <- mCompanion("sim", dim=3, mo=2))
(flt <- new("MultiFilter", mc = m ))
mf_period(flt)
mf_poles(flt)
abs(mf_poles(flt))
mf_VSform(flt,form="U")
mf_VSform(flt,form="L")
mf_VSform(flt,form="I")

## simulate a pc filter (2 seasons)
## and turn it into a multi-filter object
(rfi <- sim_pcfilter(2, 3))
(flt <- new("MultiFilter", coef = rfi$pcfilter))
mf_period(flt)
mf_poles(flt)
abs(mf_poles(flt))
mf_VSform(flt, form="U")
mf_VSform(flt, form="I")
mf_VSform(flt, form="L")

## indexing can be used  to extract filter coefficients
flt[]
flt[1,]
## the rest are some checks of numerical performance.
rfi
rfi$mat==0

zapsmall(rfi$mat)
mCompanion(zapsmall(rfi$mat))
unclass(mCompanion(zapsmall(rfi$mat)))
unclass(mCompanion(rfi$mat))

flt1 <- new("MultiFilter", mc = mCompanion(zapsmall(rfi$mat)))
flt2 <- flt

flt1[]
flt2[]
flt1[] - flt2[]
rfi$pcfilter - rfi$mat[1:2,]

mf_poles(flt1)
abs(mf_poles(flt1))

svd(rfi$mat)
rcond(rfi$mat)
Matrix::rcond(Matrix::Matrix(rfi$mat),"O")
1/Matrix::rcond(Matrix::Matrix(rfi$mat),"O")

mcompanion documentation built on Sept. 22, 2023, 5:12 p.m.