Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R tsclean影响ts对象中的一个值_R_Forecasting - Fatal编程技术网

R tsclean影响ts对象中的一个值

R tsclean影响ts对象中的一个值,r,forecasting,R,Forecasting,在ts(timeseries)对象上使用“tsclean”函数时,只有一个值(2013年12月)作为一个整体受到影响。不知道为什么 如您所见,“2013年12月”值从29232更改为51654.24。其余的都没有动过 > myts Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 2013 44568 48528 46404 47772 57600 46116 20016 3

在ts(timeseries)对象上使用“tsclean”函数时,只有一个值(2013年12月)作为一个整体受到影响。不知道为什么

如您所见,“2013年12月”值从29232更改为51654.24。其余的都没有动过

> myts
       Jan   Feb   Mar   Apr   May   Jun   Jul   Aug   Sep   Oct   Nov   Dec
2013       44568 48528 46404 47772 57600 46116 20016 36504 47052 50076 29232
2014 52956 40284 51264 45180 42552 54972 47376 25128 34776 44892 44280 41076
2015 45036 50796 49572 39710 41045 62729 44424 18000 41642 42661 38487 51590
2016 38702 44803 58228 47556 48492 56449 34925 16812 48630 46008 40140 62028
> ifelse(tsclean(myts)<0, myts, tsclean(myts))
          Jan      Feb      Mar      Apr      May      Jun      Jul      Aug      Sep      Oct      Nov      Dec
2013          44568.00 48528.00 46404.00 47772.00 57600.00 46116.00 20016.00 36504.00 47052.00 50076.00 51654.24
2014 52956.00 40284.00 51264.00 45180.00 42552.00 54972.00 47376.00 25128.00 34776.00 44892.00 44280.00 41076.00
2015 45036.00 50796.00 49572.00 39710.00 41045.00 62729.00 44424.00 18000.00 41642.00 42661.00 38487.00 51590.00
2016 38702.00 44803.00 58228.00 47556.00 48492.00 56449.00 34925.00 16812.00 48630.00 46008.00 40140.00 62028.00
> 
>myts
一月二月三月四月五月六月七月八月九月十月十一月十二月
2013       44568 48528 46404 47772 57600 46116 20016 36504 47052 50076 29232
2014 52956 40284 51264 45180 42552 54972 47376 25128 34776 44892 44280 41076
2015 45036 50796 49572 39710 41045 62729 44424 18000 41642 42661 38487 51590
2016 38702 44803 58228 47556 48492 56449 34925 16812 48630 46008 40140 62028
>ifelse(tsclean(myts)
当我尝试将相同的值作为子集传递给tsclean时,它不会受到影响

> window(myts, c(2013,12), c(2013,12))
       Dec
2013 29232

> tsclean(window(myts, c(2013,12), c(2013,12)))
       Dec
2013 29232


> ifelse(tsclean(window(myts, c(2013,12), c(2013,12)))<0, window(myts, c(2013,12), c(2013,12)), tsclean(window(myts, c(2013,12), c(2013,12))))
       Dec
2013 29232
>窗口(myts,c(2013,12),c(2013,12))
12月
2013 29232
>tsclean(窗口(myts,c(2013,12),c(2013,12)))
12月
2013 29232

>ifelse(tsclean(窗口(myts,c(2013,12),c(2013,12)))tsclean函数返回经季节性调整的时间序列,必要时从数据中删除季节性成分。查看每个月的最小值和最大值之间的差异,最大差异出现在12月,因为2013年12月的值异常低,这就是函数调整此部分的原因。 下面是R使用的函数: