R/ardec.lm.R

Defines functions ardec.lm

Documented in ardec.lm

ardec.lm <-
function(x) {

 dat=x-mean(x)
 ndat=length(dat)
 
 p=ar(dat,method="burg")[[1]] # p=order of autoregressive model from AIC (burg method)

 # linear autoregressive model fit
 
 X=t(matrix(dat[rev(rep((1:p),ndat-p)+ rep((0:(ndat-p-1)),rep(p,ndat-p)))],p,ndat-p))   
 y=rev(dat[(p+1):ndat])    
 fit=lm(y~-1+X, x=TRUE)
 
 return(fit)
 }

Try the ArDec package in your browser

Any scripts or data that you put into this service are public.

ArDec documentation built on June 1, 2022, 1:06 a.m.