0

I have a 10 year daily time series of air temperatures:

x <- c(rep((seq(-3,5,by=0.85)),365),NA)

I converted it to a time series object like this:

x <- ts(x, frequency=10, start=1)

and ran stlm

stlm(x, s.window=365, robust=TRUE, allow.multiplicative.trend=TRUE, level=0.95)

which produced the error

error in na.fail.default(as.ts(x)) : missing values in object

This is very strange, because meteorological time series are highly seasonal. What could I do to fix that? Is there a problem with the zeros?

Any help appreciated. UPDATE: There was one missing value in my time series, which produced the error. The partial code

robust=TRUE, allow.multiplicative.trend=TRUE, level=0.95

produced another error and the arguments obviously cannot be used.

How can I decompose my time series adequately into season and trend in order to identify the trend which eventually changed during the 10 years?

yPennylane
  • 760
  • 1
  • 9
  • 27
  • I get `Error in etsmodel(y, errortype[i], trendtype[j], seasontype[k], damped[l], : unused argument (level = 0.95)`, and when I remove the `level` argument, I get good results. So this is not currently reproducible – Rich Scriven Apr 09 '16 at 21:09
  • I edited my question. – yPennylane Apr 09 '16 at 21:59
  • *produced another error*.... so what's the new error? Error messages are often very informative (your first one sure was!). Have you tried leaving out your missing value? – Gregor Thomas Apr 09 '16 at 22:36
  • Yes I did. But then the error occured that the code contains unused arguments. It said: error in etsmodel(y, errortype [i], trendtype [j], seasontype [k], damped [l]: unused argument (allow.multiplicative.trend = TRUE) – yPennylane Apr 09 '16 at 22:56

1 Answers1

0

you could also try using the dsa package, which is explicitly designed to handle daily data. You have to convert your data first to xts, but then, you'll be fine,

library(dsa); library(xts)
x <- c(rep((seq(-3,5,by=0.85)),365),NA) # I didn't change these strange  looking data ;-)

# Converting to xts
dates <- seq(as.Date("2010-01-01"),length=length(x),by="days")
x <- xts(x, order.by=dates)

result <- dsa(x, fourier_number=24) # if no monthly recurring cycle is visible
                                    # fourier_number can be reduced or left empty.

sa <- result$output[,1]             # This is the seasonally adjusted series
xtsplot(result$output[,c(2,1)], names=c("original series", "seasonally adjusted series"))