简体   繁体   English

as.vector(data) 中的错误:无法将此 S4 class 强制转换为 R 中的向量

[英]Error in as.vector(data) : no method for coercing this S4 class to a vector in R

I am trying to run volatility from GARCH model:我正在尝试从 GARCH model 运行波动性:

Used libraries:使用的库:

source("TimeSeriesFunctions.R")
library(PerformanceAnalytics)
library(fGarch)
library(MonteCarlo)
library(Bootstrap)
library(xts)
library(quantmod)
library(dynlm)

GARCH1 = garchFit(~ garch(1,1), data=SP500returns, cond.dist = "norm", include.mean = TRUE)

sigmas = volatility(GARCH1, type = "sigma")

But, I got this error "Error in as.vector(data): no method for coercing this S4 class to a vector" whenever I try, with different scripts as well, and the same code works for other people.但是,每当我尝试使用不同的脚本时,我都会收到此错误“as.vector(data) 中的错误:没有方法将这个 S4 class 强制转换为向量”,并且相同的代码适用于其他人。 I got this error as well even when I try sigma().即使我尝试 sigma(),我也遇到了这个错误。

SP500 are the calculated returns, data taken from yahoo. SP500 是计算所得,数据取自雅虎。

The quantmod library breaks the fGarch library. quantmod 库打破了 fGarch 库。 Try reseting your RStudio and running everything but quantmod I have no idea why it does this, but that has been the only solution I found尝试重置您的 RStudio 并运行除 quantmod 之外的所有内容我不知道它为什么会这样做,但这是我找到的唯一解决方案

Had a similar issue.有类似的问题。 As mentioned, the quantmod library breaks the fgarch library.如前所述,quantmod 库破坏了 fgarch 库。

I loaded fgarch.我加载了 fgarch。 I did not load quantmod.我没有加载quantmod。 Whenever I wanted a function from quandmod I did quantmod::function() .每当我想要来自 quandmod 的 function 时,我都会做quantmod::function()

Example:例子:

library(fGarch)
quantmod::getSymbols(...)

Hopefully, this helps希望这会有所帮助

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 as.vector(data) 中的错误:没有将此 S4 class 强制为向量的方法 - Error in as.vector(data) : no method for coercing this S4 class to a vector as.vector(x) 中的错误:没有将此 S4 class 强制为向量的方法 - Error in as.vector(x) : no method for coercing this S4 class to a vector 软件包CVXR:as.vector(data)中的错误:没有用于将此S4类强制转换为向量的方法 - Package CVXR: Error in as.vector(data): no method for coercing this S4 class to a vector as.vector中的APCluster错误(数据):没有用于将此S4类强制转换为向量的方法 - APCluster Error in as.vector(data): no method for coercing this S4 class to a vector CVXR:as.vector(数据)中的错误:没有方法将此 S4 class 强制转换为向量 - CVXR: Error in as.vector(data): no method for coercing this S4 class to a vector CVXR:solve() 的问题 - as.vector(data) 中的错误:无法将此 s4 class 强制转换为向量 - CVXR: Problem with solve() - Error in as.vector(data): no method for coercing this s4 class to a vector 没有将这个 S4 类强制为向量以使用 mclust 的方法 - no method for coercing this S4 class to a vector for utilization of mclust 在 SparkR 中运行相关性:没有将此 S4 类强制转换为向量的方法 - Running correlations in SparkR: no method for coercing this S4 class to a vector getMethod导致“ as.vector(…中的错误” - getMethod resulting in “Error in as.vector(…” r:将matrix.csr转换为matrix。 as.vector(数据)中的错误 - r: converting matrix.csr to matrix. Error in as.vector(data)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM