簡體   English   中英

正常copula擬合中的“freeParam”錯誤[R]

[英]Error in `freeParam` in fitting of normal copula [R]

我正在使用R版本3.3.2和軟件包copula版本0.999-15來評估正常copula與我的數據的擬合。 我的數據和代碼是:

數據: https//www.dropbox.com/s/tdg8bfzmy4nd1dd/jumps.dat?dl = 0

library(copula)
data <- read.csv(file="jumps.dat", head=F, sep="")

cop_model <- ellipCopula("normal", dim = 2)
m <- pobs(as.matrix(data))
fitCopula(cop_model, m, method = 'mpl')

運行代碼后,我收到以下錯誤:

Error in `freeParam<-`(`*tmp*`, value = estimate) : the length of 'value' is not equal to the number of free parameters
Calls: fitCopula ... fitCopula.ml -> fitCopStart -> fitCopula.icor ->      freeParam<-
Execution halted

我不知道這里發生了什么。 克萊頓和Gumbel的配件非常好。 在網上搜索類似的錯誤,我一無所獲。 閱讀文檔( https://www.rdocumentation.org/packages/copula/versions/0.999-15/topics/fitCopula ?)以獲得對ellipCopula一些特異性,我找到了posDef的特定選項,但它沒有返回任何解決方案。

老問題,但我找到了這個,所以將分享我的解決方案。

嘗試運行以下命令,這是一個最小的工作示例:

library(copula)
print("-----------")
mycop <- ellipCopula("normal", dim=4)
data <- matrix(runif(400), nrow=4)
fitCopula(mycop, t(data))
print("-----------")

對我來說,如果我打開R並逐個輸入行,這可以正常工作,但如果我作為帶有Rscript的腳本運行則會失敗。 解決方案是你也需要library(methods)

出於某種原因,這與copula v0.999-v14一起使用,但被v0.999-v16打破了。 唉。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM