Learn R Programming

SpuriousMemory (version 1.0.0)

filterx: Filter a time series to reduce the short-memory dynamics using a low-order ARFIMA model

Description

Fits ARFIMA(p, d, q) models with \(p, q \in \{0, 1\}\) using fracdiff, selects the specification by AIC, and applies the corresponding linear filter to the series.

Usage

filterx(x, n = NULL)

Value

A numeric vector of length n containing the filtered series.

Arguments

x

A numeric vector containing the time series to be filtered.

n

An integer giving the length of the filtered series. If NULL, the length of x is used.

Details

The function considers ARFIMA(1, d, 1), ARFIMA(1, d, 0), ARFIMA(0, d, 1), and ARFIMA(0, d, 0) models, computes AIC for each, and selects the model with the smallest AIC. If the absolute value of the selected AR or MA coefficient is greater than or equal to 0.99, the procedure selects a pure fractional model ARFIMA(0, d, 0). The input series is centered before estimation.

Examples

Run this code
set.seed(123)
sim <- fracdiff::fracdiff.sim(
n = 1000,
ar = 0.3,     # AR(1) coefficient
ma = -0.4,    # MA(1) coefficient
d  = 0.25     # fractional differencing parameter
)
x <- sim$series
y <- filterx(x)

Run the code above in your browser using DataLab