首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在garchFit R包中运行fGarch函数时“模型公式中的无效项”错误

在garchFit R包中运行fGarch函数时“模型公式中的无效项”错误
EN

Stack Overflow用户
提问于 2022-04-23 13:06:17
回答 1查看 61关注 0票数 0

我希望在garchFit()函数的帮助文档中运行fGarch R库中的示例,并针对以下错误:“terms.formula中的错误(公式,数据=数据):模型公式中的无效项”

下面是帮助文档中的第一个示例:

代码语言:javascript
复制
   # In the univariate case the lhs formula has not to be specified ... 
   
   # A numeric Vector from default GARCH(1,1) - fix the seed:
   N = 200
   x.vec = as.vector(garchSim(garchSpec(rseed = 1985), n = N)[,1])
   garchFit(~ garch(1,1), data = x.vec, trace = FALSE)

我使用的是R版本4.1.3。以及fGarch的3042.83.2版本。

如有任何建议等,将不胜感激。

EN

回答 1

Stack Overflow用户

发布于 2022-04-23 13:18:38

当我运行您的代码时,没有错误,只有一个警告:

代码语言:javascript
复制
> library(fGarch)
> # A numeric Vector from default GARCH(1,1) - fix the seed:
> N = 200
> x.vec = as.vector(garchSim(garchSpec(rseed = 1985), n = N)[,1])
> garchFit(~ garch(1,1), data = x.vec, trace = FALSE)

Title:
 GARCH Modelling 

Call:
 garchFit(formula = ~garch(1, 1), data = x.vec, trace = FALSE) 

Mean and Variance Equation:
 data ~ garch(1, 1)
<environment: 0x7fd065608dc8>
 [data = x.vec]

Conditional Distribution:
 norm 

Coefficient(s):
        mu       omega      alpha1       beta1  
3.5418e-05  1.0819e-06  8.8855e-02  8.1200e-01  

Std. Errors:
 based on Hessian 

Error Analysis:
        Estimate  Std. Error  t value Pr(>|t|)    
mu     3.542e-05   2.183e-04    0.162    0.871    
omega  1.082e-06   1.051e-06    1.030    0.303    
alpha1 8.885e-02   5.450e-02    1.630    0.103    
beta1  8.120e-01   1.242e-01    6.538 6.25e-11 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Log Likelihood:
 861.9494    normalized:  4.309747 

Description:
 Sat Apr 23 15:14:55 2022 by user:  

Warning message:
Using formula(x) is deprecated when x is a character vector of length > 1.
  Consider formula(paste(x, collapse = " ")) instead. 
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71979900

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档