Skip to content

Instantly share code, notes, and snippets.

Created August 18, 2016 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/0bb8aba7adee550d40b840a47d8b7e25 to your computer and use it in GitHub Desktop.
Save anonymous/0bb8aba7adee550d40b840a47d8b7e25 to your computer and use it in GitHub Desktop.
library(copula)
# 5 series of data consist of A, B, C, D and E
A <- c(0.849420849, 0.900652985, 0.97144217, 0.817888428, 0.877901578,
1.070040669, 0.889742431, 0.87588968, 0.853541938, 0.848664688,
0.876830319, 0.749582638, 0.818515498, 0.890997174, 0.794766966,
0.784794851, 0.814858959, 1.074396518, 0.83752495, 0.894341116,
0.880375293, 0.900816803)
B <- c(0.479850746, 0.652111668, 1.880607815, 0.579902303, 0.50669344,
0.747560182, 0.701754386, 0.48969697, 0.346751006, 0.379234973,
0.862691466, 0.328280188, 0.317312661, 0.534438115, 0.487002653,
0.335043612, 0.373346897, 0.627520161, 0.792114695, 0.938253012,
0.444553967, 0.625972763)
C <- c(0.693491124, 0.866523143, 4.585714286, 1.512055109, 0.387755102,
0.513435701, 0.76252505, -0.113113113, 0.338521401, 0.333951763,
0.668755595, 0.401273885, 0.419868791, 0.272885789, 0.541541542,
0.32751938, 0.386409736, 0.957446809, 0.861195542, 1.531632653,
0.431610942, 1.226470588)
D <- c(0.807792208, 0.548547718, 0.738232865, 0.542247744, 1.088964927,
0.862385321, 0.60720268, 1.000816993, 0.699289661, 0.41723356,
0.604037267, 0.605003791, 0.698940998, 0.764792899, 0.647897898,
0.825256975, 0.767476085, 0.941391941, 0.889547813, 0.324503311,
0.942435424, 0.740686633)
E <- c(1.077598829, 0.318507891, 1.152616279, 0.930397727, 1.515994437,
0.940689655, 0.880886427, 1.054274084, 1.067282322, 0.677419355,
0.966233766, 0.761029412, 1.05734767, 0.615925059, 1.061988304,
1.07184241, 1.058890147, 1.123873874, 1.304891923, -0.069584736,
1.172757475, 0.501096491)
gumbel.copula <- gumbelCopula(dim = 2)
p <- pobs(as.matrix(cbind(D + E, A + B+ C )))
fit.gumbel <- fitCopula(gumbel.copula, p, method = "ml") #The error is here when trying to fit the gumbel copula
# I got the following error:
Error in optim(start, loglikCopula, lower = lower, upper = upper, method =
method, :
non-finite finite-difference value [1]
In addition: Warning message:
In .local(copula, tau, ...) : tau is out of the range [0, 1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment