Skip to content

Instantly share code, notes, and snippets.

@mick001
Last active March 13, 2016 22:20
Show Gist options
  • Save mick001/981c3a5c2e5758f93046 to your computer and use it in GitHub Desktop.
Save mick001/981c3a5c2e5758f93046 to your computer and use it in GitHub Desktop.
How to fit a copula model in R [heavily revised]. Part 1: basic tools. Full article at http://firsttimeprogrammer.blogspot.com/2016/03/how-to-fit-copula-model-in-r-heavily.html
# Generate the normal copula and sample some observations
coef_ <- 0.8
mycopula <- normalCopula(coef_, dim = 2)
u <- rCopula(2000, mycopula)
# Compute the density
pdf_ <- dCopula(u, mycopula)
# Compute the CDF
cdf <- pCopula(u, mycopula)
# Generate random sample observations from the multivariate distribution
v <- rMvdc(2000, multivariate_dist)
# Compute the density
pdf_mvd <- dMvdc(v, multivariate_dist)
# Compute the CDF
cdf_mvd <- pMvdc(v, multivariate_dist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment