我完全没有运气通过 RSRuby 和 R 使用 HoltWinters 函数。您到底是如何 1) 通过 RSRuby 创建时间序列对象以及 2) 成功地将其传递给 HoltWinters 以获得输出?
Example:
@r = RSRuby.instance
=> #<RSRuby:0x106bfe6c0 @proc_table={}, @class_table={}, @default_mode=-1, @cache={"get"=>#<RObj:0x106bfe580>, "helpfun"=>#<RObj:0x106bfd3d8>, "help"=>#<RObj:0x106bfd3d8>, "NaN"=>NaN, "FALSE"=>false, "TRUE"=>true, "F"=>false, "NA"=>-2147483648, "eval"=>#<RObj:0x106bfdf18>, "T"=>true, "parse"=>#<RObj:0x106bfe0d0>}, @caching=true>
@r.assign('mytime',@r.ts(:data => [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34], :frequency => 12, :start => [1993,3], :end => [1995,3]))
=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
@r.HoltWinters(@r.mytime)
RException: Error in decompose(ts(x[1L:wind], start = start(x), frequency = f), seasonal) :
time series has no or less than 2 periods
rsruby (0.5.1.1)
R版本2.12.2 (2011-02-25)
平台:x86_64-apple-darwin9.8.0/x86_64(64位)
:edit:仅 R 内的类似示例...如果我可以通过 RSRuby 从 HoltWinters 获得任何输出(错误除外),我会非常高兴
> z <- ts(1:34, frequency = 12, start = c(1993,3), end = c(1995,3))
> z
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
1993 1 2 3 4 5 6 7 8 9 10
1994 11 12 13 14 15 16 17 18 19 20 21 22
1995 23 24 25
> HoltWinters(z)
Holt-Winters exponential smoothing with trend and additive seasonal component.
Call:
HoltWinters(x = z)
Smoothing parameters:
alpha: 1
beta : 0
gamma: 0
Coefficients:
[,1]
a 2.500000e+01
b 1.000000e+00
s1 -8.141636e-16
s2 -8.141636e-16
s3 9.621933e-16
s4 2.738550e-15
s5 -8.141636e-16
s6 -8.141636e-16
s7 7.401487e-17
s8 -8.141636e-16
s9 9.621933e-16
s10 -8.141636e-16
s11 -8.141636e-16
s12 9.621933e-16