# [R] Not able to understand the behaviour of boot

Ajay Shah ajayshah at mayin.org
Sun May 27 06:59:43 CEST 2007

```Folks,

I have a time-series of 875 readings of the weekly returns of a stock
market index (India's Nifty). I am interested in the AR(1)
coefficient. When I do arima(r, order=c(1,0,0)) I get a statistically
significant AR1 coefficient.

If we apply the ordinary bootstrap to this problem, this involves
sampling with replacement, which destroys the time-series
structure. Hence, if we do bootstrap inference (using the ordinary
bootstrap) we ought to get a 95% confidence interval which is roughly

The program:

---------------------------------------------------------------------------
library(boot)
AR1.boot <- function(x, d) { arima(x[d], order=c(1,0,0))\$coef[1] }
arima(r, order=c(1,0,0))
b <- boot(r, AR1.boot, R=5000)
boot.ci(b, type="basic")
---------------------------------------------------------------------------

gives me:

---------------------------------------------------------------------------
> arima(r, order=c(1,0,0))

Call:
arima(x = r, order = c(1, 0, 0))

Coefficients:
ar1  intercept
0.0718     0.3061
s.e.  0.0337     0.1392

sigma^2 estimated as 14.61:  log likelihood = -2414.86,  aic = 4835.72
> b <- boot(r, AR1.boot, R=R)
> boot.ci(b, type="basic")
BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
Based on 5000 bootstrap replicates

CALL :
boot.ci(boot.out = b, type = "basic")

Intervals :
Level      Basic
95%   ( 0.0760,  0.2109 )
Calculations and Intervals on Original Scale
---------------------------------------------------------------------------

I find it very strange that the 95% confidence interval runs from
0.076 to 0.2109. I had expected that it should be symmetric about
0. What am I missing?

As an aside, how would you set about using tsboot() to obtain
inference for this AR(1) coefficient?

--
Ajay Shah                                      http://www.mayin.org/ajayshah
ajayshah at mayin.org                             http://ajayshahblog.blogspot.com
<*(:-? - wizard who doesn't know the answer.

```