Skip to content

Help needed please

2 messages · Jaymin Shah, ilai

#
Your script is rather inefficient with spurious cbind calls. Any
particular reason not to use
?ar directly ?

Call:
ar.yw.default(x = simtimeseries, order.max = 4)

Coefficients:
      1        2        3        4
 1.9440  -1.9529   0.8450  -0.2154

Order selected 4  sigma^2 estimated as  15.29

To repeat the sim, you could use a for() loop but ?sapply is better:

out<- sapply(1:100,function(...){
          simtimeseries <- arima.sim(n=1024,list(order=c(4,0,0),
                                ar=c(2.7607, -3.8106, 2.6535,
-0.9258),sd=sqrt(1)))
          aryule <- ar.yw(simtimeseries,order.max=4)
          c( c(aryule$ar,NA)[1:4] , aryule$var.pred )
          }
        )
rowMeans(out[1:4,])   # mean phi(1),...,4 see ?rowMeans for dealing with NA's
mean(out[5,])            # mean sig^2

Cheers
On Fri, Feb 10, 2012 at 6:42 AM, Jaymin Shah <jayminshah1 at hotmail.com> wrote: