[R] Error : 'start' contains NA values when fitting frank copula
Martin Maechler
m@ech|er @end|ng |rom @t@t@m@th@ethz@ch
Sat Apr 21 19:46:06 CEST 2018
>>>>> Soumen Banerjee <soumen08 using gmail.com>
>>>>> on Sat, 21 Apr 2018 17:22:56 +0800 writes:
> Hello! I am trying to fit a copula to some data in R and
> I get the error mentioned above. This is the code for a
> reproducible example -
(not really reproducible: You did not set the random seed, so
the data is different every time;
OTOH, yes, the following always gives an error)
> library(copula)
Slightly clearer showing what you are doing:
x <- runif(200)
data <- cbind(x, 2*x, 3*x)
> fr_cop = frankCopula(dim=3)
> fit_fr_cop = fitCopula(fr_cop, pobs(data), method = "mpl") #Error Here
> The error says : Error in fitCopula.ml(copula, u = data, method = method,
> start = start, : 'start' contains NA values
> What could be going wrong?
Is this a homework question? [probably not, but ..]
The homework question & answer would be
Q: What is the best fitting 3D copula if you have perfectly
correlated ("rank 1") data?
A: The complete-dependence copula ... which is indeed a boundary case,
hard to imagine you'd encounter for non-artifical data.
Another hint:
> fitCopula(normalCopula(,3), pobs(data))
Call: fitCopula(copula, data = data)
Fit based on "maximum pseudo-likelihood" and 200 3-dimensional observations.
Copula: normalCopula
rho.1
1
The maximized loglikelihood is 3686
Optimization converged
>
-----------
Yes, one could adapt the fitCopula() code to work better for
this extreme boundary case,
and for the Frank copula, it would return
> fitCopula(frankCopula(,3), pobs(data))
Call: fitCopula(copula, data = data)
Fit based on "maximum pseudo-likelihood" and 200 3-dimensional observations.
Copula: frankCopula
alpha
7.21e+16
The maximized loglikelihood is 1.798e+308
Optimization converged
but it would need even more tweaking to also give such
"alpha ~= +Inf"
results for other cases such as Gumbel or Joe.
I may add the possibility for frank*() as shown above for the
next release of the copula package...
but am a bit hesitant to complicate (and slowdown) the current
code by adding an extra check for this situation.
Martin Maechler
ETH Zurich
More information about the R-help
mailing list