Skip to contents

A class for filters following the Box-Jenkins sign convention

Objects from the Class

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

Slots

coef:

Object of class "matrix" ~~

order:

Object of class "numeric" ~~

Extends

Class "PeriodicMonicFilterSpec", directly. Class "VirtualBJFilter", directly. Class "VirtualMonicFilterSpec", by class "PeriodicMonicFilterSpec", distance 2. Class "VirtualMonicFilter", by class "VirtualBJFilter", distance 2.

Methods

filterCoef

signature(object = "PeriodicBJFilter", convention = "character"): ...

coerce

signature(from = "matrix", to = "PeriodicBJFilter"): ...

coerce

signature(from = "PeriodicBJFilter", to = "PeriodicSPFilter"): ...

coerce

signature(from = "PeriodicSPFilter", to = "PeriodicBJFilter"): ...

filterPoly

signature(object = "PeriodicBJFilter"): ...

filterPolyCoef

signature(object = "PeriodicBJFilter"): ...

show

signature(object = "PeriodicBJFilter"): ...

Author

Georgi N. Boshnakov

See also

PeriodicSPFilter

filterCoef for more details on the generics

Examples

## a toy filter of order c(3, 3, 3, 3) and 4 seasons
co <- matrix(c(1, 1, 0,
               2, 2, 2,
               3, 0, 0,
               4, 4, 4), nrow = 4, ncol = 3)

## these are equivalent:
bj1 <- new("PeriodicBJFilter", coef = co)
bj1b <- new("PeriodicBJFilter", coef = co, order = 3)
bj1c <- new("PeriodicBJFilter", coef = co, order = c(3, 3, 3, 3))
identical(bj1b, bj1c) # TRUE
#> [1] TRUE
identical(bj1, bj1b) # FALSE but only because classbj1@order is "integer"
#> [1] FALSE

# \dontshow{
    ## redundant wrap with show() below since pkgdown::build_site()
    ## throws errors without that.
# }    
## a more refined spec. for the order:
show( new("PeriodicBJFilter", coef = co, order = c(2, 3, 1, 3)) )
#> An object of class "PeriodicBJFilter"
#> order:  2 3 1 3 
#> Coefficients:
#>      [,1] [,2] [,3]
#> [1,]    1    2    0
#> [2,]    1    2    4
#> [3,]    0    3    4
#> [4,]    2    0    4
#>      [,1] [,2] [,3]
#> [1,]    1    2    0
#> [2,]    1    2    4
#> [3,]    0    3    4
#> [4,]    2    0    4

## as()
show( as(co, "PeriodicBJFilter") )
#> An object of class "PeriodicBJFilter"
#> order:  3 3 3 3 
#> Coefficients:
#>      [,1] [,2] [,3]
#> [1,]    1    2    0
#> [2,]    1    2    4
#> [3,]    0    3    4
#> [4,]    2    0    4
#>      [,1] [,2] [,3]
#> [1,]    1    2    0
#> [2,]    1    2    4
#> [3,]    0    3    4
#> [4,]    2    0    4
show( as(co, "PeriodicSPFilter") )
#> An object of class "PeriodicSPFilter"
#> order:  3 3 3 3 
#> Coefficients:
#>      [,1] [,2] [,3]
#> [1,]    1    2    0
#> [2,]    1    2    4
#> [3,]    0    3    4
#> [4,]    2    0    4
#>      [,1] [,2] [,3]
#> [1,]    1    2    0
#> [2,]    1    2    4
#> [3,]    0    3    4
#> [4,]    2    0    4

## change the sign convention:
sp1 <- as(bj1, "PeriodicSPFilter")

## the two parameterisations have different signs:
bj1
#> An object of class "PeriodicBJFilter"
#> order:  3 3 3 3 
#> Coefficients:
#>      [,1] [,2] [,3]
#> [1,]    1    2    0
#> [2,]    1    2    4
#> [3,]    0    3    4
#> [4,]    2    0    4
sp1
#> An object of class "PeriodicSPFilter"
#> order:  3 3 3 3 
#> Coefficients:
#>      [,1] [,2] [,3]
#> [1,]   -1   -2    0
#> [2,]   -1   -2   -4
#> [3,]    0   -3   -4
#> [4,]   -2    0   -4

## nevertheless, bj1 and sp1 represent the same filter
filterPoly(bj1)
#> List of polynomials:
#> [[1]]
#> 1 - x - 2*x^2 
#> 
#> [[2]]
#> 1 - x - 2*x^2 - 4*x^3 
#> 
#> [[3]]
#> 1 - 3*x^2 - 4*x^3 
#> 
#> [[4]]
#> 1 - 2*x - 4*x^3 
#> 
filterPoly(sp1)
#> List of polynomials:
#> [[1]]
#> 1 - x - 2*x^2 
#> 
#> [[2]]
#> 1 - x - 2*x^2 - 4*x^3 
#> 
#> [[3]]
#> 1 - 3*x^2 - 4*x^3 
#> 
#> [[4]]
#> 1 - 2*x - 4*x^3 
#> 
identical(filterPoly(bj1), filterPoly(sp1)) # TRUE
#> [1] FALSE

filterPolyCoef(bj1)
#>      [,1] [,2] [,3] [,4]
#> [1,]    1   -1   -2    0
#> [2,]    1   -1   -2   -4
#> [3,]    1    0   -3   -4
#> [4,]    1   -2    0   -4
filterPolyCoef(sp1)
#>      [,1] [,2] [,3] [,4]
#> [1,]    1   -1   -2    0
#> [2,]    1   -1   -2   -4
#> [3,]    1    0   -3   -4
#> [4,]    1   -2    0   -4
identical(filterPolyCoef(bj1), filterPolyCoef(sp1)) # TRUE
#> [1] TRUE

filterOrder(bj1)
#> [1] 3 3 3 3
nSeasons(bj1)
#> [1] 4