Skip to contents

Create ARMA objects.

Usage

ArmaModel(...)
ArModel(...)
MaModel(...)

Arguments

...

the arguments are passed to new(). Typical arguments are ar, ma and mean.

Value

an object representing an ARMA, AR or MA model

Author

Georgi N. Boshnakov

Examples

## MA
( ma2a1 <- MaModel(ma = c(0.3, 0.7), sigma2 = 1) )
#> An object of class "MaModel"
#> mean:  0 
#> sigmaSq:  1 
#> 
#> slot "ar":
#> An object of class "BJFilter"
#> order:  0 
#> Coefficients: 
#> numeric(0)
#> 
#> slot "ma":
#> An object of class "SPFilter"
#> order:  2 
#> Coefficients: 
#> [1] 0.3 0.7
autocorrelations(ma2a1, maxlag = 6)
#> An object of class "Autocorrelations"
#>         0         1         2         3         4         5         6 
#> 1.0000000 0.3227848 0.4430380 0.0000000 0.0000000 0.0000000 0.0000000 
partialAutocorrelations(ma2a1, maxlag = 6)
#> An object of class "PartialAutocorrelations"
#>       Lag_0       Lag_1       Lag_2       Lag_3       Lag_4       Lag_5 
#>  1.00000000  0.32278481  0.37825873 -0.27488077 -0.14556210  0.21468510 
#>       Lag_6 
#>  0.03073491 
autocovariances(ma2a1, maxlag = 6)
#> An object of class "Autocovariances"
#> Lag_0 Lag_1 Lag_2 Lag_3 Lag_4 Lag_5 Lag_6 
#>  1.58  0.51  0.70  0.00  0.00  0.00  0.00 
partialVariances(ma2a1, maxlag = 6)
#> An object of class "PartialVariances"
#>        0        1        2        3        4        5        6 
#> 1.580000 1.415380 1.212868 1.121224 1.097467 1.046885 1.045896 

## sigma2 is set to NA if not specified
## but things that don't depend on it are computed:
( ma2a2 <- MaModel(ma = c(0.3, 0.7)) )
#> An object of class "MaModel"
#> mean:  0 
#> sigmaSq:  NA 
#> 
#> slot "ar":
#> An object of class "BJFilter"
#> order:  0 
#> Coefficients: 
#> numeric(0)
#> 
#> slot "ma":
#> An object of class "SPFilter"
#> order:  2 
#> Coefficients: 
#> [1] 0.3 0.7
autocorrelations(ma2a2, maxlag = 6)
#> An object of class "Autocorrelations"
#>         0         1         2         3         4         5         6 
#> 1.0000000 0.3227848 0.4430380 0.0000000 0.0000000 0.0000000 0.0000000 
partialAutocorrelations(ma2a2, maxlag = 6)
#> An object of class "PartialAutocorrelations"
#>       Lag_0       Lag_1       Lag_2       Lag_3       Lag_4       Lag_5 
#>  1.00000000  0.32278481  0.37825873 -0.27488077 -0.14556210  0.21468510 
#>       Lag_6 
#>  0.03073491 

## AR
( ar2a1 <- ArModel(ar = c(-0.3, -0.7), sigma2 = 1) )
#> An object of class "ArModel"
#> mean:  0 
#> sigmaSq:  1 
#> 
#> slot "ar":
#> An object of class "BJFilter"
#> order:  2 
#> Coefficients: 
#> [1] -0.3 -0.7
#> 
#> slot "ma":
#> An object of class "SPFilter"
#> order:  0 
#> Coefficients: 
#> numeric(0)
autocorrelations(ar2a1, maxlag = 6)
#> An object of class "Autocorrelations"
#>          0          1          2          3          4          5          6 
#>  1.0000000 -0.1764706 -0.6470588  0.3176471  0.3576471 -0.3296471 -0.1514588 
partialAutocorrelations(ar2a1, maxlag = 6)
#> An object of class "PartialAutocorrelations"
#>         Lag_0         Lag_1         Lag_2         Lag_3         Lag_4 
#>  1.000000e+00 -1.764706e-01 -7.000000e-01 -1.123440e-16  1.123440e-16 
#>         Lag_5         Lag_6 
#> -1.123440e-16 -5.617200e-17 
autocovariances(ar2a1, maxlag = 6)
#> An object of class "Autocovariances"
#>      Lag_0      Lag_1      Lag_2      Lag_3      Lag_4      Lag_5      Lag_6 
#>  2.0238095 -0.3571429 -1.3095238  0.6428571  0.7238095 -0.6671429 -0.3065238 
partialVariances(ar2a1, maxlag = 6)
#> An object of class "PartialVariances"
#>        0        1        2        3        4        5        6 
#> 2.023810 1.960784 1.000000 1.000000 1.000000 1.000000 1.000000 

## ARMA
( arma2a1 <- ArmaModel(ar = 0.5, ma = c(0.3, 0.7), sigma2 = 1) )
#> An object of class "ArmaModel"
#> mean:  0 
#> sigmaSq:  1 
#> 
#> slot "ar":
#> An object of class "BJFilter"
#> order:  1 
#> Coefficients: 
#> [1] 0.5
#> 
#> slot "ma":
#> An object of class "SPFilter"
#> order:  2 
#> Coefficients: 
#> [1] 0.3 0.7
autocorrelations(arma2a1, maxlag = 6)
#> An object of class "Autocorrelations"
#>          0          1          2          3          4          5          6 
#> 1.00000000 0.76434426 0.59733607 0.29866803 0.14933402 0.07466701 0.03733350 
partialAutocorrelations(arma2a1, maxlag = 6)
#> An object of class "PartialAutocorrelations"
#>       Lag_0       Lag_1       Lag_2       Lag_3       Lag_4       Lag_5 
#>  1.00000000  0.76434426  0.03154068 -0.40352478  0.10241517  0.22187563 
#>       Lag_6 
#> -0.13073299 


## modelCoef() returns a list with components 'ar' and 'ma'
modelCoef(arma2a1)
#> $ar
#> [1] 0.5
#> 
#> $ma
#> [1] 0.3 0.7
#> 
modelCoef(ma2a1)
#> $ar
#> numeric(0)
#> 
#> $ma
#> [1] 0.3 0.7
#> 
modelCoef(ar2a1)
#> $ar
#> [1] -0.3 -0.7
#> 
#> $ma
#> numeric(0)
#> 

## modelOrder() returns a list with components 'ar' and 'ma'
modelOrder(arma2a1)
#> $ar
#> [1] 1
#> 
#> $ma
#> [1] 2
#> 
modelOrder(ma2a1)
#> $ar
#> [1] 0
#> 
#> $ma
#> [1] 2
#> 
modelOrder(ar2a1)
#> $ar
#> [1] 2
#> 
#> $ma
#> [1] 0
#> 

as(ma2a1, "ArmaModel")  # success, as expected
#> An object of class "ArmaModel"
#> mean:  0 
#> sigmaSq:  1 
#> 
#> slot "ar":
#> An object of class "BJFilter"
#> order:  0 
#> Coefficients: 
#> numeric(0)
#> 
#> slot "ma":
#> An object of class "SPFilter"
#> order:  2 
#> Coefficients: 
#> [1] 0.3 0.7
as(ar2a1, "ArModel")  # success, as expected
#> An object of class "ArModel"
#> mean:  0 
#> sigmaSq:  1 
#> 
#> slot "ar":
#> An object of class "BJFilter"
#> order:  2 
#> Coefficients: 
#> [1] -0.3 -0.7
#> 
#> slot "ma":
#> An object of class "SPFilter"
#> order:  0 
#> Coefficients: 
#> numeric(0)
as(ArmaModel(ar = c(-0.3, -0.7)), "ArModel")
#> An object of class "ArModel"
#> mean:  0 
#> sigmaSq:  NA 
#> 
#> slot "ar":
#> An object of class "BJFilter"
#> order:  2 
#> Coefficients: 
#> [1] -0.3 -0.7
#> 
#> slot "ma":
#> An object of class "SPFilter"
#> order:  0 
#> Coefficients: 
#> numeric(0)
## But these fail:
## as(ma2a1, "ArModel") # fails
## as(arma2a1, "ArModel") # fails
## as(arma2a1, "MaModel") # fails