Skip to contents

Compute periodic mean, generic function.

Usage

pcMean(object, ...)

# S4 method for numeric
pcMean(object, nseasons, ...)

# S4 method for matrix
pcMean(object, nseasons, ...)

# S4 method for PeriodicTS
pcMean(object, ...)

# S4 method for PeriodicMTS
pcMean(object, ...)

Arguments

object

an object for which periodic mean makes sense.

nseasons

number of seasons.

...

further arguments for methods.

Details

For univariate periodic time series, pcMean computes the mean for each season and returns a named vector. For multivariate periodic time series, the result is a matrix with one column for each variable.

The methods for "numeric" and "matrix" are equivalent to those for "PeriodicTS" and "PeriodicMTS", respectively. The difference is that the latter two don't need argument nseasons and take the names of the seasons from object.

Argument na.rm = TRUE can be used to omit NA's.

In the univariate case, when length(object) is an integer multiple of the number of seasons the periodic mean is equivalent to computing the row means of matrix(object, nrow = nseasons).

Value

numeric or matrix for the methods described here, see section Details.

Author

Georgi N. Boshnakov

Methods

signature(object = "matrix")

signature(object = "numeric")

signature(object = "PeriodicMTS")

signature(object = "PeriodicTS")

signature(object = "VirtualPeriodicArmaModel")

See also

Examples

pcMean(pcts(presidents))
#> Quarter_1 Quarter_2 Quarter_3 Quarter_4 
#>        NA  56.43333        NA        NA 
pcMean(pcts(presidents), na.rm = TRUE)
#> Quarter_1 Quarter_2 Quarter_3 Quarter_4 
#>  58.44828  56.43333  57.22222  53.07143 

pcMean(pcts(dataFranses1996)[2:5], na.rm = TRUE)
#>           USTotalIPI CanadaUnemployment GermanyGNP UKTotalInvestment
#> Quarter_1   75.70312           796.5000   301.3194          11816.85
#> Quarter_2   77.24375           711.1786   312.0774          11160.44
#> Quarter_3   77.95625           656.9643   326.7194          11744.68
#> Quarter_4   77.96563           664.8929   331.5903          12489.09

pcMean(1:20, nseasons = 4)
#> S1 S2 S3 S4 
#>  9 10 11 12 
m <- matrix(1:20, nrow = 4)
all(apply(m, 1, mean) == pcMean(1:20, nseasons = 4)) # TRUE
#> [1] TRUE