问题
I'm trying to understand my "decomposition of additive time series" graph. Here's my code:
dbs_discs <- ts(RC$Disconnects, frequency =12, start=c(2013,1))
discs_dbs <- decompose(dbs_discs)
plot(discs_dbs)
discs_dbs
and my results:
$trend
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2013 NA NA NA NA NA NA 301.8891 302.4746 302.6317 303.1842 304.2663 304.2212
2014 304.6779 306.3847 309.0182 310.5303 309.9420 309.1160 307.1276 304.2277 302.4454 301.2108 300.1494 299.7908
2015 299.5936 299.2328 298.4888 297.8479 297.3363 296.2674 NA NA NA NA NA NA
As a result, my trend graph shows nothing plotted until mid 2013. Is there a reason why it's showing NA? What does it mean? Why would there be no values?
Thanks!
回答1:
It seems the decompose
function uses a 12-month 2-way moving average to determine the trend component of the series. (See ?filter
and the code underneath decompose
). That is, the trend value in July 2013 will be the moving average for the 6 months before and 6 months after (inclusive).
If you want to perform trend-cycle decomposition but don't want to trim off your end-points, perhaps it's worth looking at the mFilter
package, which implements several filters. Note that in basically all trend-cycle decompositions there are end-point issues (ie. mistaking trend and cycle), so buyer beware.
来源:https://stackoverflow.com/questions/33194922/na-results-in-decomposition-of-additive-time-series-in-r