[R] stl and NA
"Unternährer Thomas, uth"
uth at zhwin.ch
Thu Nov 27 14:26:57 CET 2003
Hi,
I try to figure out what the stl-function exactly do.
I was reading the paper by Cleveland et al. (1990) and tested some features of stl (the ability to decompose time series with missing values and the robustness feature).
I tried the following:
> data(co2)
> co2.na <- co2
> is.na(co2.na[c(50, 100)]) <- TRUE
> plot(stl(co2.na, s.window = 12, na.action = na.exclude))
With the error message:
"Error in stl(co2.na, s.window = 12, na.action = na.exclude) :
series is not periodic or has less than two periods"
The following works fine:
> plot(stl(co2, s.window = 12))
I had then a short look in the code of stl. Is it true that the argument na.action must be a generic function, one of ?na.fail?
The help of stl:
"na.action action on missing values." (Mmmh, not really helpful)
The other functions na.omit and na.pass do not what I was expecting?!
> plot(stl(co2.na, s.window = 12, na.action = na.omit))
Error in na.omit.ts(as.ts(x)) : time series contains internal NAs
Is this feature correctly implemented?
I do not found a bug report http://r-bugs.biostat.ku.dk/cgi-bin/R... So I assume that I'm missing something.
How can I handle NAs in stl() correctly?
Thanks for any hints and comments
Thomas
More information about the R-help
mailing list