【问题标题】:seasonal decomposition loess daily temperature time series季节分解黄土日温时间序列
【发布时间】:2016-04-09 20:59:36
【问题描述】:

我有一个 10 年的每日气温时间序列:

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

我将它转换为这样的时间序列对象:

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

然后运行 ​​stlm

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

产生了错误

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

这很奇怪,因为气象时间序列具有很强的季节性。我能做些什么来解决这个问题?零点有问题吗?

任何帮助表示赞赏。 更新:我的时间序列中有一个缺失值,这产生了错误。部分代码

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

产生了另一个错误,参数显然不能使用。

如何将我的时间序列充分分解为季节和趋势,以识别在 10 年内最终发生变化的趋势?

【问题讨论】:

  • 我得到Error in etsmodel(y, errortype[i], trendtype[j], seasontype[k], damped[l], : unused argument (level = 0.95),当我删除level 参数时,我得到了很好的结果。所以这目前无法重现
  • 我编辑了我的问题。
  • 产生了另一个错误....那么新的错误是什么?错误消息通常非常有用(您的第一个肯定是!)。您是否尝试过忽略缺失值?
  • 是的,我做到了。但随后发生错误,即代码包含未使用的参数。它说:etsmodel中的错误(y,errortype [i],trendtype [j],seasontype [k],damped [l]:未使用的参数(allow.multiplicative.trend = TRUE)

标签: r forecasting decomposition


【解决方案1】:

您也可以尝试使用 dsa 软件包,该软件包专门用于处理日常数据。您必须先将数据转换为 xts,然后就可以了,

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"))  

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-13
    • 1970-01-01
    • 2016-03-31
    • 2014-12-15
    • 1970-01-01
    • 1970-01-01
    • 2019-01-16
    相关资源
    最近更新 更多