Learn R Programming

pcts (version 0.15.8)

pcMean-methods: Compute periodic mean

Description

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, ...)

Value

numeric or matrix for the methods described here, see section

‘Details’.

Arguments

object

an object for which periodic mean makes sense.

nseasons

number of seasons.

...

further arguments for methods.

Author

Georgi N. Boshnakov

Methods

signature(object = "matrix")

signature(object = "numeric")

signature(object = "PeriodicMTS")

signature(object = "PeriodicTS")

signature(object = "VirtualPeriodicArmaModel")

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).

See Also

pcApply which applies an arbitrary function by season

Examples

Run this code
pcMean(pcts(presidents))
pcMean(pcts(presidents), na.rm = TRUE)

pcMean(pcts(dataFranses1996)[2:5], na.rm = TRUE)

pcMean(1:20, nseasons = 4)
m <- matrix(1:20, nrow = 4)
all(apply(m, 1, mean) == pcMean(1:20, nseasons = 4)) # TRUE

Run the code above in your browser using DataLab