[R] how do I do the autocovariance of a moving average?

R. Michael Weylandt michael.weylandt at gmail.com
Tue Jan 24 03:22:54 CET 2012


the filter() command puts NAs on the ends.

acf(na.omit(v))

Michael

On Mon, Jan 23, 2012 at 7:27 PM, Rampagegrl
<takaishi_blackwings at hotmail.com> wrote:
> Hi guys,
>
> I'm trying to do the autocovariance of a moving average but it's giving me
> errors.  Here is my code:
>
>> w=rnorm(500,0,1)
>> v=filter(w, sides=2, rep(1/3,3))
>> acf(w, lag.max=20)  <=that printed out a nice graph.
>> acf(v, lag.max=20)
> Error in na.fail.default(as.ts(x)) : missing values in object
>
> thanks a lot.
>
> --
> View this message in context: http://r.789695.n4.nabble.com/how-do-I-do-the-autocovariance-of-a-moving-average-tp4322558p4322558.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list