[R] ar function in stats
Gabor Grothendieck
ggrothendieck at gmail.com
Tue Feb 6 00:42:12 CET 2007
Try:
> ar(testSeries, demean = FALSE, method = "burg", var.method = 2)
Call:
ar(x = testSeries, method = "burg", demean = FALSE, var.method = 2)
Coefficients:
1 2 3 4 5 6
0.0888 0.0063 0.0654 -0.0169 0.0215 0.0950
Order selected 6 sigma^2 estimated as 5.194e-09
On 2/5/07, Leeds, Mark (IED) <Mark.Leeds at morganstanley.com> wrote:
> I had a couple of questions about the ar function that i was hoping
> someone could answer.
>
> I have the structure below
>
> testSeries<-structure(c(-3.88613620955214e-05, 0, -7.77272551011343e-05,
>
> 0, -0.000194344573539562, -0.000116624876218163, -3.88779814601281e-05,
> 0, 3.88779814601281e-05, -0.000155520995647807, -0.000116656621367561,
> -3.88885648225368e-05, -3.88900772017586e-05, 7.77786420242954e-05,
> 0, 7.77725929772544e-05, 0, 0, -3.88855404165889e-05,
> -0.000155557284283514,
> 0.000116670231722849, 7.77725929772544e-05, 0, 0, 3.88840283903069e-05,
> -0.000116656621367561, -7.77786420242954e-05, 0.000233317779873343,
> -0.000155539137849048, 0, 0, -3.88885648225368e-05, 0, 0,
> 0.000116661157799791,
> 3.88840283903069e-05, 0, -3.88840283903069e-05, 7.77665448717935e-05,
> 7.77604977061919e-05, 0.000155502857678291, 0, 0, 7.77423618523176e-05,
> -7.77423618523176e-05, 3.88719364105006e-05, 3.88704254418171e-05,
> -3.88704254418171e-05, 3.88704254418171e-05, 0.0002331908288839,
> -7.77242344552342e-05, 0, -7.7730275981791e-05, -7.77363184468749e-05,
> -7.77423618523176e-05, 0, -0.000116624876218163, -3.88779814601281e-05,
> -0.000233299635555240, 7.77725929772544e-05, 7.77665448717935e-05,
> 0.00011663847916632, 7.7751428721684e-05, 0, 3.88734474964791e-05,
> 3.88719364105006e-05, 7.77393400321347e-05, 3.88674038565573e-05,
> -3.88674038565573e-05, 0, 7.77332970969269e-05, -3.88658932403696e-05,
> -3.88674038565573e-05, 0, 0, 3.88674038565573e-05, 7.7730275981791e-05,
> -7.7730275981791e-05, 0, 7.7730275981791e-05, 0, 0,
> 0.000233154582543582,
> 0.000194253968248181, 3.88462659076660e-05, 7.76880050110673e-05,
> -7.76880050110673e-05, 0, 7.76880050110673e-05, -3.88432480773471e-05,
> 0, 3.88432480773471e-05, 0, 0, 0, -3.88432480773471e-05,
> -0.000194238875579067,
> 0, -3.88523029751786e-05, -3.88538125353222e-05, -0.000116570496139390,
> -3.8859851948958e-05, 0, 0, 0.000155430348088348, 0,
> 3.88538125353222e-05,
> 0, 3.88523029751786e-05, 0, 3.88507935322746e-05, 3.88492842067212e-05,
> 0, 0, -7.77000777389958e-05, 0, 0, -3.88523029751786e-05,
> -3.88538125353222e-05,
> 0, 0.000155406193249497, 0, -0.000155406193249497,
> -0.000116570496139390,
> -3.8859851948958e-05, -7.77242344552342e-05, -3.88643827414215e-05,
> 3.88643827414215e-05, 3.88628723597129e-05, -7.77272551011343e-05,
> -3.88658932403696e-05, 0.000116593148341504, 0, 7.77212140444794e-05,
> 0, 0, 0, 3.88583419195232e-05, 7.77121542198667e-05, 0, 0,
> 7.77061155105008e-05,
> 0, 7.77000777389958e-05, 0, 0, -7.77000777389958e-05,
> 7.77000777389958e-05,
> 0, -7.77000777389958e-05, 3.88507935322746e-05, 3.88492842067212e-05,
> -7.77000777389958e-05, 7.77000777389958e-05, -7.77000777389958e-05,
> 7.77000777389958e-05, -3.88492842067212e-05, 3.88492842067212e-05,
> 0, 0, 0, 3.88477749986849e-05, -3.88477749986849e-05, 0, 0,
> -3.88492842067212e-05,
> 0, -3.88507935322746e-05, 0, 0, -0.000155418269730367, 0,
> 3.88568320072724e-05,
> -3.88568320072724e-05, 0, 0, 0, 0, 0, -7.77181938684812e-05,
> -7.77242344552342e-05, 7.77242344552342e-05, 0, 7.77181938684812e-05,
> 0, -7.77181938684812e-05, 3.8859851948958e-05, 0, 0,
> -3.8859851948958e-05,
> 0, 0, 0, -7.77242344552342e-05, -0.000233208956280984,
> -0.000155502857678291,
> 0.000155502857678291, -3.88734474964791e-05, 0, 3.88734474964791e-05
> ), index = structure(c(1115056920, 1115056980, 1115057040, 1115057100,
> 1115057160, 1115057220, 1115057280, 1115057340, 1115057400, 1115057460,
> 1115057520, 1115057580, 1115057640, 1115057700, 1115057760, 1115057820,
> 1115057880, 1115057940, 1115058000, 1115058060, 1115058120, 1115058180,
> 1115058240, 1115058300, 1115058360, 1115058420, 1115058480, 1115058540,
> 1115058600, 1115058660, 1115058720, 1115058780, 1115058840, 1115058900,
> 1115058960, 1115059020, 1115059080, 1115059140, 1115059200, 1115059260,
> 1115059320, 1115059380, 1115059440, 1115059500, 1115059560, 1115059620,
> 1115059680, 1115059740, 1115059800, 1115059860, 1115059920, 1115059980,
> 1115060040, 1115060100, 1115060160, 1115060220, 1115060280, 1115060340,
> 1115060400, 1115060460, 1115060520, 1115060580, 1115060640, 1115060700,
> 1115060760, 1115060820, 1115060880, 1115060940, 1115061000, 1115061060,
> 1115061120, 1115061180, 1115061240, 1115061300, 1115061360, 1115061420,
> 1115061480, 1115061540, 1115061600, 1115061660, 1115061720, 1115061780,
> 1115061840, 1115061900, 1115061960, 1115062020, 1115062080, 1115062140,
> 1115062200, 1115062260, 1115062320, 1115062380, 1115062440, 1115062500,
> 1115062560, 1115062620, 1115062680, 1115062740, 1115062800, 1115062860,
> 1115062920, 1115062980, 1115063040, 1115063100, 1115063160, 1115063220,
> 1115063280, 1115063340, 1115063400, 1115063460, 1115063520, 1115063580,
> 1115063640, 1115063700, 1115063760, 1115063820, 1115063880, 1115063940,
> 1115064000, 1115064060, 1115064120, 1115064180, 1115064240, 1115064300,
> 1115064360, 1115064420, 1115064480, 1115064540, 1115064600, 1115064660,
> 1115064720, 1115064780, 1115064840, 1115064900, 1115064960, 1115065020,
> 1115065080, 1115065140, 1115065200, 1115065260, 1115065320, 1115065380,
> 1115065440, 1115065500, 1115065560, 1115065620, 1115065680, 1115065740,
> 1115065800, 1115065860, 1115065920, 1115065980, 1115066040, 1115066100,
> 1115066160, 1115066220, 1115066280, 1115066340, 1115066400, 1115066460,
> 1115066520, 1115066580, 1115066640, 1115066700, 1115066760, 1115066820,
> 1115066880, 1115066940, 1115067000, 1115067060, 1115067120, 1115067180,
> 1115067240, 1115067300, 1115067360, 1115067420, 1115067480, 1115067540,
> 1115067600, 1115067660, 1115067720, 1115067780, 1115067840, 1115067900,
> 1115067960, 1115068020, 1115068080, 1115068140, 1115068200, 1115068260,
> 1115068320, 1115068380, 1115068440, 1115068500, 1115068560, 1115068620,
> 1115068680, 1115068740, 1115068800, 1115068860), class = c("POSIXt",
> "POSIXct")), class = "zoo")
>
> I call the ar function with aic=TRUE as below so that it picks the order
> of the ar model based on BIC. Yet it returns with no coefficients as the
> best model.
> I do the same call using many, series in a loop ( besides just the one
> above ) and it returns zero coefficients quite a bit of the time.
>
> 1) can this be possible ? because i don't see how zero coefficients
> could be better than one or some ?
>
> ARest<-ar(testSeries,aic=TRUE,demean=FALSE,order.max=4,method="ols")
>
> 2) also, is there a way to calculate the t-stats for the coefficients
> that come back ?
>
> it would probably be easier for me to just call arima over and over in a
> loop while decreasing the number of lags each time by 1 but
> i am not clever enough in R to do this ? i imagine it requires some form
> of the use of embed but i looked at the code for ar and it
> was pretty beyond me. if anyone happens to have code for doing this type
> of thing, that would be great also. thank you very much.
> --------------------------------------------------------
>
> This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list