[R] Replication of linear model/autoregressive model
Miguel Manese
jjonphl at gmail.com
Sun Jun 17 02:18:55 CEST 2012
Hi Al, Michael,
On Sat, Jun 16, 2012 at 11:01 AM, R. Michael Weylandt
<michael.weylandt at gmail.com> wrote:
> On Fri, Jun 15, 2012 at 6:56 AM, Al Ehan <aehan3616 at gmail.com> wrote:
>> Hi,
>>
>> I would like to make a replication of 10 of a linear, first order
>> Autoregressive function, with respect to the replication of its innovation,
>> e. for example:
>>
>> #where e is a random variables of innovation (from GEV distribution-that
>> explains the rgev)
>> #by using the arima.sim model from TSA package, I try to produce Y
>> replicates, with respect to every replicates of e,
>> #means for e[,1], I want to have say Y[,1].
>>
>> The code:
>>
>> e=replicate(10,rgev(20,xi=0.2,mu= 931.1512,sigma= 168.2702 ))
>> Y=replicate(10,ts(arima.sim(list(ar=0.775),n=20,innov=e,start.innov=e)))
>>
>> what I get is the same random variables for every replicates of Y.
>
> Well, what would you expect? You're passing the same values of e each
> time. What you probably want to do is to put the rgev call as the
> innov argument to arima.sim(). Take a look at the second example of
> ?arima.sim to see how its done (change the rt to rgev and you're good
> to go.
>
More specifically, you'd do something like
Y <- replicate(10, ts(arima.sim(list(ar=0.775), n=20, rand.gen=rgev,
xi=0.2, mu=931.1512, sigma=168.2702)))
- Jon
More information about the R-help
mailing list