Skip to contents

Filter time series with periodic arma filters with or options for periodic and non-periodic intercepts.

Usage

pc.filter.xarma(x, eps, phi, theta, period, p, q, n, from,
              seasonof1st = 1, intercept = NULL, nintercept = NULL)

Arguments

x

the time series to be filtered, a vector.

eps

the innovations, a vector.

phi

the autoregression parameters, a matrix.

theta

the moving average parameters, a matrix.

period

the period (number of seasons in a year).

p

the autoregression orders, recycled to period if length(p)=1.

q

the moving average orders, recycled to period if length(q)=1.

n

a positive integer, the time index of the last observation to be filtered.

from

a positive integer, the time index of the first observation to be filtered.

seasonof1st

a positive integer, the season of the time index of x[1], see Details.

intercept

the intercepts of the seasons, a vector of length period.

nintercept

intercepts, a vector of the same length as x.

Details

pc.filter.xarma is somewhat lower level. The user level function is pc.filter which uses pc.filter.xarma to do the computations.

pc.filter.xarma filters the time series x by the following formula (for t=from,...,n): $$ x_t = c_t + \sum_{i=1}^{p_t} \phi _t(i)x _{t-i} + \sum_{i=1}^{q_t} \theta_t(i)\varepsilon_{t-i} + \varepsilon_t, $$ where \(c_t\) is the overall intercept at time \(t\), see below. Values of x[t] for t outside the range from,n, if any, are left unchanged. Values for t<from are used as initial values when needed.

Two intercepts are provided for convenience and some flexibility. The periodic intercept, intercept, is a vector of length period. It is replicated to length n, taking care to ensure that the first element of the resulting vector, say \(a\), starts with intercept[seasonof1st]. nintercept can be an arbitrary vector of length n. It can be used to represent trend or contributions from covariates. nintercept is not necessarilly periodic and argument seasonof1st does not affect its use. The overall intercept is obtained as the sum c = a + nintercept.

Usually x is a numeric vector but it can also be a matrix in which each column represents the data for one ``year''. Also, the length of x is typically, but not necessarilly, equal to n. It is prudent to ensure that length(x) >= n and this must be done if x is a matrix.

Argument phi is ignored if p==0, argument theta is ignored if q==0.

pc.filter.xarma is meant to be called by other functions whose task is to prepare the arguments with proper checks. It does not make much sense to repeat the checks in pc.filter.xarma. In particular, no check is made to ensure that from and n are correctly specified.

This is a low level function meant to be used with basic vectors and matrices. TODO: Implement in C/C++. In the current implementation. it accesses the elements of the arguments with straightforward indexing, so objects from classes may be used as well, provided that x[t], eps[t], phi[t,i], theta[t,i], as well as assignment to x[t], are defined for scalar indices.

Value

Returns x with x[from] to x[n] filled with the filtered values and values outside the interval from,...,n left unchanged. The mode of x is left unchanged. In particular, x may be a matrix with each row representing the data for a season. This is convenient since periodic time series are often more easily processed in this form.

Author

Georgi N. Boshnakov

Level

0 (base)

See also