[英]garchFit function in R: Multivariate data inputs require lhs for the formula
df=structure(list(X.1 = 1:10, X = c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L), json_data.time.updated = structure(1:10, .Label = c("Jan 19, 2019 15:18:00 UTC",
"Jan 19, 2019 15:19:00 UTC", "Jan 19, 2019 15:51:00 UTC", "Jan 19, 2019 15:52:00 UTC",
"Jan 19, 2019 15:54:00 UTC", "Jan 19, 2019 15:55:00 UTC", "Jan 19, 2019 15:57:00 UTC",
"Jan 19, 2019 15:58:00 UTC", "Jan 19, 2019 16:00:00 UTC", "Jan 19, 2019 16:01:00 UTC"
), class = "factor"), json_data.time.updatedISO = structure(1:10, .Label = c("2019-01-19T15:18:00+00:00",
"2019-01-19T15:19:00+00:00", "2019-01-19T15:51:00+00:00", "2019-01-19T15:52:00+00:00",
"2019-01-19T15:54:00+00:00", "2019-01-19T15:55:00+00:00", "2019-01-19T15:57:00+00:00",
"2019-01-19T15:58:00+00:00", "2019-01-19T16:00:00+00:00", "2019-01-19T16:01:00+00:00"
), class = "factor"), json_data.time.updateduk = structure(1:10, .Label = c("Jan 19, 2019 at 15:18 GMT",
"Jan 19, 2019 at 15:19 GMT", "Jan 19, 2019 at 15:51 GMT", "Jan 19, 2019 at 15:52 GMT",
"Jan 19, 2019 at 15:54 GMT", "Jan 19, 2019 at 15:55 GMT", "Jan 19, 2019 at 15:57 GMT",
"Jan 19, 2019 at 15:58 GMT", "Jan 19, 2019 at 16:00 GMT", "Jan 19, 2019 at 16:01 GMT"
), class = "factor"), code = structure(c(1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L), .Label = "USD", class = "factor"), rate = structure(c(6L,
7L, 10L, 5L, 9L, 8L, 4L, 3L, 1L, 2L), .Label = c("3,734.2833",
"3,734.4950", "3,734.9117", "3,734.9600", "3,735.3200", "3,735.7750",
"3,735.9150", "3,736.0750", "3,736.7717", "3,736.9100"), class = "factor"),
description = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L), .Label = "United States Dollar", class = "factor"),
rate_float = c(3735.775, 3735.915, 3736.91, 3735.32, 3736.7717,
3736.075, 3734.96, 3734.9117, 3734.2833, 3734.495)), class = "data.frame", row.names = c(NA,
-10L))
i want perform GARCH model i try use simple example from help of this library我想执行 GARCH 模型我尝试使用这个库的帮助中的简单示例
library("fGarch")
b=garchFit(formula = ~ garch(1, 1), data = df,
init.rec = c("mci", "uev"),
delta = 2, skew = 1, shape = 4,
cond.dist = c("norm", "snorm", "ged", "sged", "std", "sstd",
"snig", "QMLE"),
include.mean = TRUE, include.delta = NULL, include.skew = NULL,
include.shape = NULL, leverage = NULL, trace = TRUE,
algorithm = c("nlminb", "lbfgsb", "nlminb+nm", "lbfgsb+nm"),
hessian = c("ropt"), control = list(),
title = NULL, description = NULL)
garchKappa(cond.dist = c("norm", "ged", "std", "snorm", "sged", "sstd",
"snig"), gamma = 0, delta = 2, skew = NA, shape = NA)
summary(b)
Then i get the error
Error in garchFit(formula = ~garch(1, 1), data = df, init.rec = c("mci", :
Multivariate data inputs require lhs for the formula.
This time series formed by minites date variable is json_data.time.updatedISO metric variable is price rate_float这个由 minites 日期变量形成的时间序列是 json_data.time.updatedISO 度量变量是 price rate_float
What does mean this error and how to fix it?这个错误是什么意思以及如何修复它?
You specified data = df
, where df
has multiple columns, while the model is just ~ garch(1, 1)
, so there is no way to know which of the variables is supposed to follow this GARCH(1,1).您指定了data = df
,其中df
有多个列,而模型只是~ garch(1, 1)
,因此无法知道哪个变量应该遵循此 GARCH(1,1)。 Hence, the errors says that then you need to specify the left hand side.因此,错误表明您需要指定左侧。 For instance, using例如,使用
formula = rate_float ~ garch(1, 1), data = df
does the job and also做这份工作,也
formula = ~ garch(1, 1), data = df$rate_float
as there is no ambiguity in those cases.因为在这些情况下没有歧义。
Now with your example data summary(b)
will throw some warnings but that's only due to very few observations;现在使用您的示例数据summary(b)
会发出一些警告,但这只是由于很少的观察; not enough to compute the Standardised Residuals Tests
part.不足以计算Standardised Residuals Tests
部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.