Home > Back-end >  mixture copula in R
mixture copula in R

Time:08-09

I want to use mixture copula for reliability analysis, now ,with the help of a friend ,I've already finished it ‘RVMs_fitted’ 。now i want to perform the probability integral transformation (PIT),but the function of RVINEPIT can’t use,because RVINEPIT(data,RVM),this RVM not RVINEMATRIX Here is my code:

library(vineclust)
data1 <- read.csv("D:/ASTUDY/Rlanguage/Mix copula/data.csv", header = FALSE)
fit <- vcmm(data = data1, total_comp=3,is_cvine = 0)
print(fit)
summary(fit) 
RVMs_fitted <- list()
RVMs_fitted[[1]] <- VineCopula::RVineMatrix(Matrix=fit$output$vine_structure[,,1],
                                            family=fit$output$bicop_familyset[,,1],
                                            par=fit$output$bicop_param[,,1],
                                            par2=fit$output$bicop_param2[,,1])
RVMs_fitted[[2]] <- VineCopula::RVineMatrix(Matrix=fit$output$vine_structure[,,2],
                                            family=fit$output$bicop_familyset[,,2],
                                            par=fit$output$bicop_param[,,2],
                                            par2=fit$output$bicop_param2[,,2])
RVMs_fitted[[3]] <- VineCopula::RVineMatrix(Matrix=fit$output$vine_structure[,,3],
                                            family=fit$output$bicop_familyset[,,3],
                                            par=fit$output$bicop_param[,,3],
                                            par2=fit$output$bicop_param2[,,3])
RVM<-RVMs_fitted

meanx <- c(0.47,0.508,0.45,0.52,0.48)
sigmax <- c(0.318,0.322,0.296,0.29,0.279)
ux1<-pnorm(x[1],meanx[1],sigmax[1])
ux2<-pnorm(x[2],meanx[2],sigmax[2])
ux3<-pnorm(x[3],meanx[3],sigmax[3])
ux4<-pnorm(x[4],meanx[4],sigmax[4])
ux5<-pnorm(x[5],meanx[5],sigmax[5])
data <- c(ux1,ux2,ux3,ux4,ux5)
du=RVinePIT(data, RVM)
y=t(qnorm(t(du)))


Error: 
 In RVinePIT: RVM has to be an RVineMatrix object.

CodePudding user response:

You have multiple problems here:

  1. RVM is a list. However, you tried to fit RVinePIT to a list, while it works for one data at a time.
  2. The same holds for the y.

I do not have your data, but try it with other data.

Here is the code (it should work):

  library(vineclust)
  library(VineCopula)
data1 <- read.csv("D:/ASTUDY/Rlanguage/Mix copula/data.csv", header = FALSE)
fit <- vcmm(data = data, total_comp=3,is_cvine = 0)
print(fit)
summary(fit) 
RVMs_fitted <- list()
RVMs_fitted[[1]] <- RVineMatrix(Matrix=fit$output$vine_structure[,,1],
                                            family=fit$output$bicop_familyset[,,1],
                                            par=fit$output$bicop_param[,,1],
                                            par2=fit$output$bicop_param2[,,1])
RVMs_fitted[[2]] <- RVineMatrix(Matrix=fit$output$vine_structure[,,2],
                                            family=fit$output$bicop_familyset[,,2],
                                            par=fit$output$bicop_param[,,2],
                                            par2=fit$output$bicop_param2[,,2])
RVMs_fitted[[3]] <- RVineMatrix(Matrix=fit$output$vine_structure[,,3],
                                            family=fit$output$bicop_familyset[,,3],
                                            par=fit$output$bicop_param[,,3],
                                            par2=fit$output$bicop_param2[,,3])
RVM<-RVMs_fitted

meanx <- c(0.47,0.508,0.45,0.52,0.48)
sigmax <- c(0.318,0.322,0.296,0.29,0.279)
ux1<-pnorm(x[1],meanx[1],sigmax[1])
ux2<-pnorm(x[2],meanx[2],sigmax[2])
ux3<-pnorm(x[3],meanx[3],sigmax[3])
ux4<-pnorm(x[4],meanx[4],sigmax[4])
ux5<-pnorm(x[5],meanx[5],sigmax[5])
data <- c(ux1,ux2,ux3,ux4,ux5)### This must be a matrix to work with RVinePIT
du=lapply(1:3, function(i) RVinePIT(data, RVM[[i]]))
y <-lapply(1:3, function(i) t(qnorm(t(du[[i]]))))

CodePudding user response:

I want to Transform related variables into independent variables.

 xiangguan<-function(y){
  r1=pnorm(y[1])
  ux1=r1
  x[1]=qnorm(ux1,meanx[1],sigmax[1])

  r2=pnorm(y[2])
  ux2=***hinverse(copula1,r2,ux1)***
  x[2]=qnorm(ux2,meanx[2],sigmax[2])

  r3=pnorm(y[3])
  hdie=h(copula1,ux1,ux2)
  ux3=hinverse(copula2,hinverse(copula5,r3,hdie),ux1)
  x[3]=qnorm(ux3,meanx[3],sigmax[3])

  r4=pnorm(y[4])
  h1=hinverse(copula8,r4,r3)
  h2=hinverse(copula6,h1,hdie)
  ux4=hinverse(copula3,h2,ux1)
  x[4]=qnorm(ux4,meanx[4],sigmax[4])

  r5=pnorm(y[5])
  h3=hinverse(copula10,r5,r4)
  h4=hinverse(copula9,h3,r3)
  h5=hinverse(copula7,h4,hdie)
  ux5=hinverse(copula4,h5,ux1)
  x[5]=qnorm(ux5,meanx[5],sigmax[5])
  return(x)
}

in the code,I want input mixture copula (3 components copula)in hinverse(copula,u,v)or h(copula,u,v) but in this function copula only input an object components ,could you help me? you are my god ! thank you! salute!

  • Related