fitCopula产生checkPar错误

时间:2017-04-28 23:35:55

标签: r packages

我是R和copula的新手。我正在尝试将Tawn Type 1 copula与数据相匹配,但仍然收到以下错误消息:

Error in .local(u, copula, log, ...) : unused argument (checkPar = FALSE)

我使用的数据是瑞典汽车保险数据,位于:http://instruction.bus.wisc.edu/jfrees/jfreesbooks/Regression%20Modeling/BookWebDec2010/data.html

x是索赔,y是付款。

任何人都可以帮我辨别出什么是错的吗?

提前致谢!

# Estimate x (Claims) gamma distribution parameters and visually       compare simulated vs observed data
x_mean <- mean(x)
x_var <- var(x)
x_rate <- x_mean / x_var
x_shape <- ( (x_mean)^2 ) / x_var
hist(x, breaks = 20, col = "green", density = 20)
hist(rgamma( nrow(mat), rate = x_rate, shape = x_shape), breaks = 20,col = "blue", add = T, density = 20, angle = -45)

# Estimate y (Payment) gamma distribution parameters and visually     compare simulated vs observed data
y_mean <- mean(y)
y_var <- var(y)
y_rate <- y_mean / y_var
y_shape <- ( (y_mean)^2 ) / y_var
hist(y, breaks = 20, col = "green", density = 20)
hist(rgamma(nrow(mat), rate = y_rate, shape = y_shape), breaks = 20, col = "blue", add = T, density = 20, angle = -45)

# Looks good, so...

# Measure association using Kendall's Tau
cor(mat, method = "kendall")

##[,1]      [,2]
##[1,] 1.0000000 0.8673572
##[2,] 0.8673572 1.0000000

# Now try Spearman's Rho
cor(mat, method = "spearman")
##[,1]      [,2]
##[1,] 1.0000000 0.9624433
##[2,] 0.9624433 1.0000000

# Use Vine Copula pachage to select a copula
var_a <- pobs(mydata)[,1]
var_b <- pobs(mydata)[,2]
selectedCopula <- BiCopSelect(var_a, var_b, familyset = NA)
selectedCopula
## Bivariate copula: Tawn  type 1 (par = 12.9, par2 = 0.96, tau = 0.89) 

# Family 
selectedCopula$family
##[1] 104

# Par 
# par -> parameter of the copula
selectedCopula$par
##[1] 12.89932

# Estimate copula parameters
cop_model <-  tawnT1Copula(param = c(2,0.5))
m <- pobs(as.matrix(mat))
fit <- fitCopula(cop_model, m, method = 'ml')
coef(fit)

1 个答案:

答案 0 :(得分:0)

没有最低限度的工作示例,我们无法确定。但是,错误信息很明确:一个copula函数被输入&#34; checkPar&#34;论证,不存在。

您提供的代码没有单词&#34; checkPar&#34;,因此它可能属于依赖项。你的R是最新的吗?你的包裹是最新的吗?