Last active
October 20, 2016 01:54
-
-
Save njtierney/5b3204ebc449091191e6bcc533d2854f to your computer and use it in GitHub Desktop.
R copula code exampl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install.packages("VineCopula") | |
# install.packages("copula") | |
# install.packages("tigerstats") | |
library(VineCopula) | |
library(copula) | |
library(tigerstats) | |
set.seed(123) | |
N=200 | |
dim=dim | |
U=runif(N, min=0,max=1) | |
# x <- rep(0,N) | |
x <- vector("list",N) | |
for (i in 1:N){ | |
if(U[i] < 0.3){ | |
x[[i]]= rCopula(N,claytonCopula(0.5,dim=2)) | |
}else if(U[i]<0.7){ | |
x[[i]]=rCopula(N,frankCopula(-4,dim=2)) | |
} | |
} | |
x[[1]] | |
# densityplot(x[[1]]) | |
plot(density(x[[1]])) | |
## make rCopula(N...) into rCopular(i,...)----------------------------------- | |
library(VineCopula) | |
library(copula) | |
library(tigerstats) | |
set.seed(123) | |
N=200 | |
dim=dim | |
U=runif(N, min=0,max=1) | |
# x <- rep(0,N) | |
x <- vector("list",N) | |
for (i in 1:N){ | |
if(U[i] < 0.3){ | |
x[[i]]= rCopula(i,claytonCopula(0.5,dim=2)) | |
}else if(U[i]<0.7){ | |
x[[i]]=rCopula(i,frankCopula(-4,dim=2)) | |
} | |
} | |
x[[1]] | |
densityplot(as.numeric(x[[1]])) | |
plot(density(x[[1]])) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment