# simulate dummy data
t = 1:30 # times series
Z = rnorm(30) # random independent variable
x = .2*Z + (.05*t) # generate dependent effects
x[2:30] = x[2:30] + .2*x[1:29] # add autocorrelation
# fit the AR model, using Z as a covariate
(AR = fitAR(x ~ Z))
# get specific components
AR$residuals
AR$coefficients
AR$pval
# now using time as a covariate
(AR.time <- fitAR(x ~ t))
# source variable from a dataframe
df = data.frame(y = x, t.scaled = t/30, Z = Z)
fitAR(y ~ t.scaled + Z, data = df)
## Methods
summary(AR)
residuals(AR)
coefficients(AR)
Run the code above in your browser using DataLab