R:我应该如何在 R 的 arima 函数中指定 "init" 和 "fixed" 参数?
R: How should I specify the "init" and "fixed" parameters in the arima function in R?
我无法理解 init
和 fixed
参数是如何在 R 的 arima
函数中指定的。
例如,我将使用R的内置数据集lh
来说明这个想法:
下面的行工作正常
arima(lh, order = c(1,0,0))
但是这一行没有按预期工作并生成了以下错误消息:
arima(lh, order = c(1,0,0), init=c(0.17))
Error in arima(lh, order = c(1, 0, 0), init = c(0.17)) :
'init' is of the wrong length
由于我指定的是 ARMA(1,0) 模型,因此 init
应该只采用一个参数。那为什么这不起作用? init
的预期 "model parameters" 是多少?这真是令人困惑。
我在 arima
中的 fixed
参数也遇到了同样的问题。我相信他们实际上是同一个问题。所以,如果其中一个解决了,另一个也会自动解决。
请仔细阅读文档。 help(arima)
明确告诉你init
与参数的初值有关:
init
optional numeric vector of initial parameter values. Missing
values will be filled in, by zeroes except for regression
coefficients. Values already specified in fixed will be ignored.
同样,fixed
也涉及参数:
fixed
optional numeric vector of the same length as the total number
of parameters. If supplied, only NA entries in fixed will be varied.
transform.pars = TRUE will be overridden (with a warning) if any AR
parameters are fixed. It may be wise to set transform.pars = FALSE
when fixing MA parameters, especially near non-invertibility.
请注意,您认为您传递的初始值 Y0、Y-1、...取自系列本身的实际值。
尝试在
的 return 上调用 coef
arima(lh, order = c(1,0,0))
看看你可能需要初始化多少个参数。
我无法理解 init
和 fixed
参数是如何在 R 的 arima
函数中指定的。
例如,我将使用R的内置数据集lh
来说明这个想法:
下面的行工作正常
arima(lh, order = c(1,0,0))
但是这一行没有按预期工作并生成了以下错误消息:
arima(lh, order = c(1,0,0), init=c(0.17))
Error in arima(lh, order = c(1, 0, 0), init = c(0.17)) :
'init' is of the wrong length
由于我指定的是 ARMA(1,0) 模型,因此 init
应该只采用一个参数。那为什么这不起作用? init
的预期 "model parameters" 是多少?这真是令人困惑。
我在 arima
中的 fixed
参数也遇到了同样的问题。我相信他们实际上是同一个问题。所以,如果其中一个解决了,另一个也会自动解决。
请仔细阅读文档。 help(arima)
明确告诉你init
与参数的初值有关:
init
optional numeric vector of initial parameter values. Missing values will be filled in, by zeroes except for regression coefficients. Values already specified in fixed will be ignored.
同样,fixed
也涉及参数:
fixed
optional numeric vector of the same length as the total number of parameters. If supplied, only NA entries in fixed will be varied. transform.pars = TRUE will be overridden (with a warning) if any AR parameters are fixed. It may be wise to set transform.pars = FALSE when fixing MA parameters, especially near non-invertibility.
请注意,您认为您传递的初始值 Y0、Y-1、...取自系列本身的实际值。
尝试在
的 return 上调用coef
arima(lh, order = c(1,0,0))
看看你可能需要初始化多少个参数。