Calculating a 12-month moving average of weekly series, but anchored at the last day of the month

Posted by richardh on Stack Overflow See other posts from Stack Overflow or by richardh
Published on 2010-05-25T01:04:40Z Indexed on 2010/05/25 1:11 UTC
Read the original article Hit count: 236

Filed under:

I have a zoo object oi.zoo with weekly data. I would like to sooth this with a 12-month moving average (easy enough), but I can't figure out how to anchor the right edge of the the moving average window at the end of the month (to correspond with the on which factors I am regressing). For example:

> head(oi.zoo)
1986-01-15 1986-01-31 1986-02-14 1986-02-28 1986-03-14 1986-03-31 
   2966182    2986748    2948045    2990979    2993453    2936038 
> head(mkt)
1926-07-31 1926-08-31 1926-09-30 1926-10-31 1926-11-30 1926-12-31 
      2.62       2.56       0.36      -3.43       2.44       2.77

I have some other factors and plan on using dynlm to regress.

Thanks!

© Stack Overflow or respective owner

Related posts about r