Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

fracdiff.sim

Simulate fractional ARIMA Time Series


Description

Generates simulated long-memory time series data from the fractional ARIMA(p,d,q) model. This is a test problem generator for fracdiff.

Note that the MA coefficients have inverted signs compared to other parametrizations, see the details in fracdiff.

Usage

fracdiff.sim(n, ar = NULL, ma = NULL, d,
             rand.gen = rnorm, innov = rand.gen(n+q, ...),
             n.start = NA, backComp = TRUE, allow.0.nstart = FALSE,
             start.innov = rand.gen(n.start, ...),
             ..., mu = 0)

Arguments

n

length of the time series.

ar

vector of autoregressive parameters; empty by default.

ma

vector of moving average parameters; empty by default.

d

fractional differencing parameter.

rand.gen

a function to generate the innovations; the default, rnorm generates white N(0,1) noise.

innov

an optional times series of innovations. If not provided, rand.gen() is used.

n.start

length of “burn-in” period. If NA, the default, the same value as in arima.sim is computed.

backComp

logical indicating if back compatibility with older versions of fracdiff.sim is desired. Otherwise, for d = 0, compatibility with R's arima.sim is achieved.

allow.0.nstart

logical indicating if n.start = 0 should be allowed even when p + q > 0. This not recommended unless for producing the same series as with older versions of fracdiff.sim.

start.innov

an optional vector of innovations to be used for the burn-in period. If supplied there must be at least n.start values.

...

additional arguments for rand.gen(). Most usefully, the standard deviation of the innovations generated by rnorm can be specified by sd.

mu

time series mean (added at the end).

Value

a list containing the following elements :

series

time series

ar, ma, d, mu, n.start

same as input

See Also

fracdiff, also for references; arima.sim

Examples

## Pretty (too) short to "see" the long memory
fracdiff.sim(100, ar = .2, ma = .4, d = .3)

## longer with "extreme" ar:
r <- fracdiff.sim(n=1500, ar=-0.9, d= 0.3)
plot(as.ts(r$series))

## Show that  MA  coefficients meaning is inverted
## compared to   stats :: arima :

AR <- 0.7
MA <- -0.5
n.st <- 2

AR <- c(0.7, -0.1)
MA <- c(-0.5, 0.4)
n <- 512 ; sd <- 0.1
n.st <- 10

set.seed(101)
Y1 <- arima.sim(list(ar = AR, ma = MA), n = n, n.start = n.st, sd = sd)
plot(Y1)

# For our fracdiff, reverse the MA sign:
set.seed(101)
Y2 <- fracdiff.sim(n = n, ar = AR, ma = - MA, d = 0,
                   n.start = n.st, sd = sd)$series
lines(Y2, col=adjustcolor("red", 0.5))
## .. no, you don't need glasses ;-)  Y2 is Y1 shifted slightly

##' rotate left by k (k < 0: rotate right)
rot <- function(x, k) {
  stopifnot(k == round(k))
  n <- length(x)
  if(k <- k %% n) x[c((k+1):n, 1:k)] else x
}
k <- n.st - 2
Y2.s <- rot(Y2, k)
head.matrix(cbind(Y1, Y2.s))
plot(Y1, Y2.s); i <- (n-k+1):n
text(Y1[i], Y2.s[i], i, adj = c(0,0)-.1, col=2)

## With  backComp = FALSE,  get *the same* as arima.sim():
set.seed(101)
Y2. <- fracdiff.sim(n = n, ar = AR, ma = - MA, d = 0,
                    n.start = n.st, sd = sd, backComp = FALSE)$series
stopifnot( all.equal( c(Y1), Y2., tolerance= 1e-15))

fracdiff

Fractionally Differenced ARIMA aka ARFIMA(P,d,q) Models

v1.5-1
GPL (>= 2)
Authors
Martin Maechler [aut, cre] (<https://orcid.org/0000-0002-8685-9910>), Chris Fraley [ctb, cph] (S original; Fortran code), Friedrich Leisch [ctb] (R port, <https://orcid.org/0000-0001-7278-1983>), Valderio Reisen [ctb] (fdGPH() & fdSperio()), Artur Lemonte [ctb] (fdGPH() & fdSperio()), Rob Hyndman [ctb] (residuals() & fitted(), <https://orcid.org/0000-0002-2140-5352>)
Initial release
2020-01-20

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.