help(ar) should tell you how to get the coefficients. If, like me, you don't read help files, you can use str() to look at the structure of ar's output.
> str(a <- ar(sin(1:30), aic=TRUE)) List of 14 $ order : int 2 $ ar : num [1:2] 1.011 -0.918 $ var.pred : num 0.0654 $ x.mean : num 0.00934 $ aic : Named num [1:15] 61.215 53.442 0 0.985 2.917 ... ..- attr(*, "names")= chr [1:15] "0" "1" "2" "3" ... $ n.used : int 30 $ order.max : num 14 $ partialacf : num [1:14, 1, 1] 0.5273 -0.9179 -0.1824 -0.0477 -0.0393 ... $ resid : num [1:30] NA NA -0.0145 -0.0734 -0.0725 ... $ method : chr "Yule-Walker" $ series : chr "sin(1:30)" $ frequency : num 1 $ call : language ar(x = sin(1:30), aic = TRUE) $ asy.var.coef: num [1:2, 1:2] 0.00583 -0.00308 -0.00308 0.00583 - attr(*, "class")= chr "ar" > a$ar [1] 1.0112512 -0.9178554 Bill Dunlap TIBCO Software wdunlap tibco.com On Thu, Jun 16, 2016 at 4:34 AM, T.Riedle <tr...@kent.ac.uk> wrote: > Hi everybody, > > I am trying to run an AR1 model using the ar() function as shown below. > > > rollingarma<-rollapply(data,width=36,function(data) ar(data,aic=TRUE)) > > head(rollingarma,50) > order ar var.pred x.mean aic n.used order.max > partialacf resid method series > [1,] 1 0.7433347 1.382908 49.99861 Numeric,16 36 15 > Numeric,15 Numeric,36 "Yule-Walker" "data" > [2,] 1 0.7410181 1.565755 49.94778 Numeric,16 36 15 > Numeric,15 Numeric,36 "Yule-Walker" "data" > [3,] 1 0.7636966 1.660581 49.86861 Numeric,16 36 15 > Numeric,15 Numeric,36 "Yule-Walker" "data" > > > I get the table as shown above if I use head(). > > How can I extract the ar coefficients from this table? I have already > tried coef() and rollingarma$ar but both do not work. > What can I do? > > Thanks for your help. > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.