From wdunlap at tibco.com  Mon Jul 18 23:53:30 2011
From: wdunlap at tibco.com (William Dunlap)
Date: Mon, 18 Jul 2011 21:53:30 +0000
Subject: [Rd] filter(x,
	method="recursive") when there are NA's in x messes up
Message-ID: <E66794E69CFDE04D9A70842786030B93FBD7@PA-MBX04.na.tibco.com>

If x contains an NA then filter(x, f, method="recursive")
puts NA's and 0.0's in the output in an odd pattern.
It puts NA's in the length(f) positions ending at the position
of the input NA and it puts a run of length(f) 0.0's starting
at the position immediately after the input NA.  The values
after the 0.0's look like the recursion was restarted there.

I'd naively expect that all output values at and after the position
of the input NA to be NA, but it looks like it is trying to
restart the recursion.  I would not expect the output values
before the position of the input NA to depend on future values.
Are the NA's misplaced?

> x <- c(1:4, NA, 6:9)
> cbind(x, "1"=filter(x, 0.5, method="recursive"),
+          "2"=filter(x, c(0.5, 0.0), method="recursive"),
+          "3"=filter(x, c(0.5, 0.0, 0.0), method="recursive")) 
Time Series:
Start = 1 
End = 9 
Frequency = 1 
   x      1     2   3
1  1  1.000  1.00 1.0
2  2  2.500  2.50 2.5
3  3  4.250  4.25  NA
4  4  6.125    NA  NA
5 NA     NA    NA  NA
6  6  0.000  0.00 0.0
7  7  7.000  0.00 0.0
8  8 11.500  8.00 0.0
9  9 14.750 13.00 9.0

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 



[Rd] filter(x, method="recursive") when there are NA's in x messes up
William Dunlap