Skip to contents

Methods for as() in package sarima.

Methods

This section shows the methods for converting objects from one class to another, defined via setAs(). Use as(obj, "classname") to convert object obj to class "classname".

signature(from = "ANY", to = "Autocorrelations")

signature(from = "ANY", to = "ComboAutocorrelations")

signature(from = "ANY", to = "ComboAutocovariances")

signature(from = "ANY", to = "PartialAutocorrelations")

signature(from = "ANY", to = "PartialAutocovariances")

signature(from = "ANY", to = "PartialVariances")

signature(from = "ArmaSpec", to = "list")

signature(from = "Autocorrelations", to = "ComboAutocorrelations")

signature(from = "Autocorrelations", to = "ComboAutocovariances")

signature(from = "Autocovariances", to = "ComboAutocorrelations")

signature(from = "Autocovariances", to = "ComboAutocovariances")

signature(from = "BJFilter", to = "SPFilter")

signature(from = "numeric", to = "BJFilter")

Convert a numeric vector to a BJFilter object. This is a way to state that the coefficients follow the Box-Jenkins convention for the signs, see the examples.

signature(from = "numeric", to = "SPFilter")

Convert a numeric vector to an SPFilter object. This is a way to state that the coefficients follow the signal processing (SP) convention for the signs, see the examples.

signature(from = "PartialVariances", to = "Autocorrelations")

signature(from = "PartialVariances", to = "Autocovariances")

signature(from = "PartialVariances", to = "ComboAutocorrelations")

signature(from = "PartialVariances", to = "ComboAutocovariances")

signature(from = "SarimaFilter", to = "ArmaFilter")

signature(from = "SarimaModel", to = "list")

signature(from = "SPFilter", to = "BJFilter")

signature(from = "vector", to = "Autocorrelations")

signature(from = "vector", to = "Autocovariances")

signature(from = "vector", to = "PartialAutocorrelations")

signature(from = "vector", to = "PartialAutocovariances")

signature(from = "VirtualArmaFilter", to = "list")

signature(from = "VirtualSarimaModel", to = "ArmaModel")

Author

Georgi N. Boshnakov

Examples


## the default for ARMA model is BJ for ar and SP for ma:
mo <- new("ArmaModel", ar = 0.9, ma = 0.4, sigma2 = 1)
modelPoly(mo)
#> $ar
#> 1 - 0.9*x 
#> 
#> $ma
#> 1 + 0.4*x 
#> 

## here we declare explicitly that 0.4 uses the SP convention
##    (not necessary, the result is the same, but the intention is clear).
mo1 <- new("ArmaModel", ar = 0.9, ma = as(0.4, "SPFilter"), sigma2 = 1)
modelPoly(mo1)
#> $ar
#> 1 - 0.9*x 
#> 
#> $ma
#> 1 + 0.4*x 
#> 
identical(mo, mo1) ## TRUE
#> [1] TRUE

## if the sign of theta follows the BJ convention, this can be stated unambiguously.
##   This creates the same model:
mo2 <- new("ArmaModel", ar = 0.9, ma = as(-0.4, "BJFilter"), sigma2 = 1)
modelPoly(mo2)
#> $ar
#> 1 - 0.9*x 
#> 
#> $ma
#> 1 + 0.4*x 
#> 
identical(mo, mo2) ## TRUE
#> [1] TRUE

## And this gives the intended model whatever the default conventions:
ar3 <- as(0.9, "BJFilter")
ma3 <- as(-0.4, "BJFilter")
mo3 <- new("ArmaModel", ar = ar3, ma = ma3, sigma2 = 1)
modelPoly(mo3)
#> $ar
#> 1 - 0.9*x 
#> 
#> $ma
#> 1 + 0.4*x 
#> 
identical(mo, mo3) ## TRUE
#> [1] TRUE

## The coefficients can be extracted in any particular form,
## e.g. to pass them to functions with specific requirements:
modelCoef(mo3) # coefficients of the model with the default (BD) sign convention
#> $ar
#> [1] 0.9
#> 
#> $ma
#> [1] 0.4
#> 
modelCoef(mo3, convention = "BD") # same result
#> $ar
#> [1] 0.9
#> 
#> $ma
#> [1] 0.4
#> 
modelCoef(mo3, convention = "SP") # signal processing convention
#> $ar
#> [1] -0.9
#> 
#> $ma
#> [1] 0.4
#> 


## for ltsa::tacvfARMA() the convention is BJ, so:
co <- modelCoef(mo3, convention = "BJ") # Box-Jenkins convention

ltsa::tacvfARMA(co$ar, co$ma, maxLag = 6, sigma2 = 1)
#> [1] 9.894737 9.305263 8.374737 7.537263 6.783537 6.105183 5.494665
autocovariances(mo3, maxlag = 6) ## same
#> An object of class "Autocovariances"
#>    Lag_0    Lag_1    Lag_2    Lag_3    Lag_4    Lag_5    Lag_6 
#> 9.894737 9.305263 8.374737 7.537263 6.783537 6.105183 5.494665