If $y_t$ and $y_{t-1}$ are actually 30 observations apart, for AR(1) you can do the following:
lm( tail(df$y,-30) ~ head(df$y,-30) )
This assumes the first observation is the oldest. If your variable has the first observation being the newest, switch head
with tail
. This would also imply overlapping observations.
For AR(2) you would do
lm( tail(df$y,-60) ~ tail(head(df$y,-30),-30) + head(df$y,-60) )
If you wish to trade off the added estimation efficiency due to overlapping observations for computational efficiency, you may use every 30th data point as follows:
n=length(df$y)
m=floor(n/30)
index=seq(from=n,to=(n-m*30),by=-30)
g=df$y[index] # g contains every 30th observation of y dropping the oldest few
ar.ols(g, order.max = 1)) # for AR(1)
ar.ols(g, order.max = 2)) # for AR(2)