[R] Naive Q re applying AR(p) models to matrix data

Laura Quinn laura at env.leeds.ac.uk
Tue Oct 14 17:41:23 CEST 2003


As a total beginner still, I am having great difficulty trying to apply
ar models to column data in a matrix.

As each matrix has 20 columns (and some of these contain NA data) it is
obviously a long, slow process to calculate ar models for each column
individually, though I am (probably extremely stupidly) struggling to see
how I am doing this wrong.

I have tried using:

for (i in 1:20)
apply(mydata,c(,i),ar(mydata[!is.na(mydata)],order.max=3))

and

apply(mydata,ar(mydata[!is.na(mydata)],order.max=3))

and

apply(mydata,c(,1:20),ar(mydata[,1:20][!is.na(mydata[,1:20])],order.max=3))

and none of these work - can someone tell me what I am doing wrong??

Thank you in advance, and excuse me for my stupidity..
Laura




More information about the R-help mailing list