Compute autocovariances and periodic autocovariances
autocovariances-methods.Rd
Methods for the generic function autocovariances()
, which
computes autocovariances meaningful for the first argument. For
objects representing time series, it computes sample autocovariances
(univariate, multivariate, periodic, as appropriate). For objects
representing models, it computes the relevant theoretical
autocovariances.
Methods
signature(x = "numeric", maxlag = "ANY")
signature(x = "PeriodicArmaModel", maxlag = "ANY")
signature(x = "PeriodicArModel", maxlag = "ANY")
signature(x = "PeriodicAutocovarianceModel", maxlag = "ANY")
signature(x = "PeriodicTS", maxlag = "ANY")
signature(x = "VirtualPeriodicAutocovariances", maxlag = "ANY")
If
maxlag
is missing or equal tomaxLag(x)
,x
is returned unchanged. Otherwise the number of available lags is adjusted tomaxlag
.
See also
autocovariances
in package sarima
for further details.
autocorrelations
for autocorrelations;
Examples
## periodic ts object => peridic acvf
autocovariances(pcts(AirPassengers), maxlag = 10)
#> An object of class "SamplePeriodicAutocovariances"
#> Slot "modelCycle":
#> Object from built-in class 'MonthYearCycle'
#> Cycle start: January
#>
#> Slot "data":
#> An object of class "Lagged2d"
#> Slot *data*:
#> Lag_0 Lag_1 Lag_2 Lag_3 Lag_4 Lag_5 Lag_6
#> Jan 9357.021 7281.135 6713.656 7601.193 8713.974 10982.141 10844.250
#> Feb 7362.333 8285.417 6416.792 5910.458 6684.146 7663.104 9657.688
#> Mar 9269.472 8193.417 9249.958 7053.391 6510.794 7389.061 8463.578
#> Apr 10568.576 9814.486 8774.667 9903.771 7687.529 7082.272 8013.427
#> May 12068.139 11274.181 10521.028 9379.250 10592.708 8169.873 7532.303
#> Jun 16513.722 14057.778 13143.611 12309.472 10996.500 12414.417 9596.676
#> Jul 22545.222 19260.694 16434.722 15358.556 14338.861 12819.000 14491.167
#> Aug 22246.076 22344.889 19122.194 16306.681 15215.326 14286.069 12746.000
#> Sep 14084.243 17653.632 17798.194 15228.222 12994.569 12141.715 11368.514
#> Oct 11242.410 12565.257 15773.868 15904.389 13596.278 11622.764 10859.701
#> Nov 8305.306 9649.014 10798.986 13553.264 13647.389 11677.361 9977.889
#> Dec 9742.639 8982.722 10435.431 11686.819 14632.597 14764.306 12612.778
#> Lag_7 Lag_8 Lag_9 Lag_10
#> Jan 9390.208 7856.760 7194.995 7311.302
#> Feb 9545.917 8252.583 6892.292 6295.354
#> Mar 10690.235 10555.954 9178.907 7610.891
#> Apr 9157.685 11586.472 11421.185 9879.495
#> May 8538.140 9766.638 12372.091 12184.935
#> Jun 8846.787 10023.273 11494.366 14471.218
#> Jul 11223.935 10362.741 11751.505 13464.856
#> Aug 14391.271 11132.598 10300.258 11680.350
#> Sep 10132.167 11438.188 8774.117 8095.832
#> Oct 10129.903 9065.083 10235.146 7870.328
#> Nov 9302.014 8724.444 7776.417 8777.125
#> Dec 10777.472 10052.681 9414.111 8393.500
#>
#> Slot "n":
#> [1] 144
#>
#> Slot "varnames":
#> character(0)
#>
#> Slot "objectname":
#> [1] "pcts(AirPassengers)"
#>
## for "ts" or "numeric" objects the default is non-periodic acvf
autocovariances(AirPassengers, maxlag = 10)
#> An object of class "SampleAutocovariances"
#> Lag_0 Lag_1 Lag_2 Lag_3 Lag_4 Lag_5 Lag_6 Lag_7
#> 14291.973 13549.467 12513.692 11529.066 10756.502 10201.181 9743.318 9474.212
#> Lag_8 Lag_9 Lag_10
#> 9369.968 9589.176 10043.254
#> Slot n:
#> [1] 144
#> Slot varnames: <not set>
#> Slot objectname: x
autocovariances(as.numeric(AirPassengers))
#> An object of class "SampleAutocovariances"
#> Lag_0 Lag_1 Lag_2 Lag_3 Lag_4 Lag_5 Lag_6 Lag_7
#> 14291.973 13549.467 12513.692 11529.066 10756.502 10201.181 9743.318 9474.212
#> Lag_8 Lag_9 Lag_10 Lag_11 Lag_12 Lag_13 Lag_14 Lag_15
#> 9369.968 9589.176 10043.254 10622.369 10867.546 10185.330 9237.507 8374.002
#> Lag_16 Lag_17 Lag_18 Lag_19 Lag_20 Lag_21
#> 7688.441 7142.378 6699.134 6429.540 6311.747 6534.630
#> Slot n:
#> [1] 144
#> Slot varnames: <not set>
#> Slot objectname: x
## argument 'nseasons' forces periodic acvf
autocovariances(AirPassengers, maxlag = 10, nseasons = 12)
#> An object of class "SampleAutocovariances"
#> Lag_0 Lag_1 Lag_2 Lag_3 Lag_4 Lag_5 Lag_6 Lag_7
#> 14291.973 13549.467 12513.692 11529.066 10756.502 10201.181 9743.318 9474.212
#> Lag_8 Lag_9 Lag_10
#> 9369.968 9589.176 10043.254
#> Slot n:
#> [1] 144
#> Slot varnames: <not set>
#> Slot objectname: x
autocovariances(as.numeric(AirPassengers), maxlag = 10, nseasons = 12)
#> An object of class "SamplePeriodicAutocovariances"
#> Slot "modelCycle":
#> Object from class 'BareCycle'
#> Number of seasons:
#>
#> Slot "data":
#> An object of class "Lagged2d"
#> Slot *data*:
#> Lag_0 Lag_1 Lag_2 Lag_3 Lag_4 Lag_5 Lag_6
#> S1 9357.021 7281.135 6713.656 7601.193 8713.974 10982.141 10844.250
#> S2 7362.333 8285.417 6416.792 5910.458 6684.146 7663.104 9657.688
#> S3 9269.472 8193.417 9249.958 7053.391 6510.794 7389.061 8463.578
#> S4 10568.576 9814.486 8774.667 9903.771 7687.529 7082.272 8013.427
#> S5 12068.139 11274.181 10521.028 9379.250 10592.708 8169.873 7532.303
#> S6 16513.722 14057.778 13143.611 12309.472 10996.500 12414.417 9596.676
#> S7 22545.222 19260.694 16434.722 15358.556 14338.861 12819.000 14491.167
#> S8 22246.076 22344.889 19122.194 16306.681 15215.326 14286.069 12746.000
#> S9 14084.243 17653.632 17798.194 15228.222 12994.569 12141.715 11368.514
#> S10 11242.410 12565.257 15773.868 15904.389 13596.278 11622.764 10859.701
#> S11 8305.306 9649.014 10798.986 13553.264 13647.389 11677.361 9977.889
#> S12 9742.639 8982.722 10435.431 11686.819 14632.597 14764.306 12612.778
#> Lag_7 Lag_8 Lag_9 Lag_10
#> S1 9390.208 7856.760 7194.995 7311.302
#> S2 9545.917 8252.583 6892.292 6295.354
#> S3 10690.235 10555.954 9178.907 7610.891
#> S4 9157.685 11586.472 11421.185 9879.495
#> S5 8538.140 9766.638 12372.091 12184.935
#> S6 8846.787 10023.273 11494.366 14471.218
#> S7 11223.935 10362.741 11751.505 13464.856
#> S8 14391.271 11132.598 10300.258 11680.350
#> S9 10132.167 11438.188 8774.117 8095.832
#> S10 10129.903 9065.083 10235.146 7870.328
#> S11 9302.014 8724.444 7776.417 8777.125
#> S12 10777.472 10052.681 9414.111 8393.500
#>
#> Slot "n":
#> [1] 144
#>
#> Slot "varnames":
#> character(0)
#>
#> Slot "objectname":
#> [1] "as.numeric(AirPassengers)"
#>