Skip to content

arima.sim

2 messages · James

#
Hi,

I have been using arima.sim from the stats package recently, and I'm
wondering why I get different results when using what seem to be the
same parameters. For example, I've given examples of three different
ways to run arima.sim with what I believe are the same parameters.
It's my understanding from the R documentation that rnorm is the
default function for rand.gen if not provided in innov.  So it would
seem that there's quite a bit of redundancy in the assignment to a1.
My expectation is that a1, a2, and a3 should be identical.  It turns
out that a1 is only partially identical to a2 and a3.  The first 56
values of a1 are different from a2 and a3, but the rest are the same.
What is it that makes an explicit declaration of the innov parameters
different from using the defaults?  At this point, my best guess is
that this might have something to do with n.start and the length of
the "burn-in" period.  Any suggestions as to why all three of these
aren't the same?  Thanks.

James

set.seed(2012)
a1 <- arima.sim(list(order = c(1, 0, 0), ar = 0.5), n = 250, innov =
rnorm(n = 250, mean = 0, sd = 0.1))
Min.  1st Qu.   Median     Mean  3rd Qu.     Max.
-0.45630 -0.11060 -0.03225 -0.02525  0.05484  0.27120

set.seed(2012)
a2 <- arima.sim(list(order = c(1, 0, 0), ar = 0.5), n = 250, sd = 0.1)
Min.  1st Qu.   Median     Mean  3rd Qu.     Max.
-0.31830 -0.10200 -0.03016 -0.02174  0.05593  0.27120

set.seed(2012)
a3 <- arima.sim(list(ar = 0.5), n = 250, sd = 0.1)
Min.  1st Qu.   Median     Mean  3rd Qu.     Max.
-0.31830 -0.10200 -0.03016 -0.02174  0.05593  0.27120
Time Series:
Start = 1
End = 250
Frequency = 1
  [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
 [22] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
 [43] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
FALSE FALSE FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 [64]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 [85]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
17 days later
#
Hi,

For the sake of completeness, I thought I might follow up my email
from earlier in the month with what I found out by digging into the
code.  The answer to my earlier question perhaps should have been
obvious to me from the "Usage" description from the documentation.

In the three examples I originally included, the difference between a1
and the other two AR(1) models (i.e. a2 and a3) is the sd parameter
for start.innov.  In a1, the sd for innov is set to 0.1, but the sd
for start.innov remains the default parameter for rnorm (i.e. sd = 1).
 In a2 and a3, by passing in sd as an additional argument via "...",
this sd is used by both innov and start.innov.  So a1 is equivalent
to:

set.seed(2012)
a4 <- arima.sim(list(order = c(1, 0, 0), ar = 0.5),
                n = 250,
                innov = rnorm(n = 250, mean = 0, sd = 0.1),
                n.start = 10,
                start.innov = rnorm(n = 10, mean = 0, sd = 1))

Whereas, a2 and a3 are equivalent to:

set.seed(2012)
a5 <- arima.sim(list(order = c(1, 0, 0), ar = 0.5),
                n = 250,
                innov = rnorm(n = 250, mean = 0, sd = 0.1),
                n.start = 10,
                start.innov = rnorm(n = 10, mean = 0, sd = 0.1))

The only difference being the sd used by start.innov.  Of course this
leads to an additional question, which is, why might someone choose to
use differing values for sd in innov and start.innov?  I'd love to
hear any insight into this as I'm still learning to use this tool.
Thanks.


James
On Mon, Oct 8, 2012 at 9:23 AM, J Toll <jctoll at gmail.com> wrote: