| fracdiff.sim {fracdiff} | R Documentation | 
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,
 | 
| innov | an optional times series of innovations.  If not
provided,  | 
| n.start | length of “burn-in” period.  If  | 
| backComp | logical indicating if back compatibility with older
versions of  | 
| allow.0.nstart | logical indicating if  | 
| start.innov | an optional vector of innovations to be used for
the burn-in period.  If supplied there must be at least
 | 
| ... | additional arguments for  | 
| 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))