# NOT RUN {
# Example 1
# Read data
data(dataset)
data <- dataset$data[1:100,1:5]
# Define the variables Y and X. X are the conditioning variables,
# which have to be positioned in the last columns of the data.frame
colnames(data) <- c("Y1","Y2","X3","X4","X5")
# }
# NOT RUN {
# Select and fit a C- vine copula model, requiring that the
RVM <- CDVineCondFit(data,Nx=3,treecrit="BIC",type="CVine",selectioncrit="AIC")
summary(RVM)
RVM$Matrix
# }
# NOT RUN {
# Example 2
# Read data
data(dataset)
data <- dataset$data[1:80,1:5]
# Define the variables Y and X. X are the conditioning variables,
# which have to be positioned in the last columns of the data.frame
colnames(data) <- c("Y1","Y2","X3","X4","X5")
# Define a VineMatrix which can be used for conditional sampling
ListVines <- CDVineCondListMatrices(data,Nx=3)
Matrix=ListVines$DVine[[1]]
Matrix
# }
# NOT RUN {
# Fit copula families for the defined vine:
RVM <- CDVineCondFit(data,Nx=3,Matrix=Matrix)
summary(RVM)
RVM$Matrix
RVM$family
# check
identical(RVM$Matrix,Matrix)
# Fit copula families for the defined vine, given a group of families to select from:
RVM <- CDVineCondFit(data,Nx=3,Matrix=Matrix,familyset=c(1,2,3,14))
summary(RVM)
RVM$Matrix
RVM$family
# Try to fit copula families for a vine which is not among those
# that allow for conditional sampling:
Matrix
Matrix[which(Matrix==4)]=40
Matrix[which(Matrix==2)]=20
Matrix[which(Matrix==40)]=2
Matrix[which(Matrix==20)]=4
Matrix
RVM <- CDVineCondFit(data,Nx=3,Matrix=Matrix)
RVM
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab