# Sampling from conditional distribution using copula [duplicate]

This question already has an answer here:

I'm using Clayton copula model to generate bivariate observations. x= poisson and y=gamma with, of course, certain dependence among them.

I have generated observations (X,Y) ~ f(x,y) using copula package in r but now I need to generate observation Y|X=x ~ f(Y|X=x) ¿Is there any way/algorithm to generate samples from conditional distribution that involves the copula? For example, like this, found in Nelsen:

1. Generate two independent uniform (0,1) variates u and t;
2. Set v = cu(-1)(t), where cu(-1) denotes a quasi-inverse of cu .
3. The desired pair is (u,v).

I have the next code in r where I model the observations according to Nelsen,using the quasi-inverse of cu from cCopula function:

t<-runif(1700)
u_t<-cbind(t,runif(1700))
V<-cCopula(u_t,claytonCopula(param=0.14,dim=2),inverse=TRUE)
x<-qpois(u_t[,1],lambda=d.poisson$estimate[1]) y<-qgamma(V[,2],shape=claim_size.gamma$estimate[1],rate=claim_size.gamma$estimate[2]) plot(data_sinout$d,data_sinout$claim_size,main='Test dataset x and y',col='blue') points(x,y,col='red') legend('topright', c('Observed', 'Simulated'), col = c('blue', 'red'), pch=21) The result is: which is quite reasonable being one of my first tries. Now I want to generate observations of Y when X=15, it means f(Y|X=15), then according to the data I expect to have low values of y, in the range of [0,50k].So, I have this code: t_x<-15 t<-ppois(t_x,lambda=d.poisson$estimate[1])
u_t<-cbind(t,runif(1700))
V<-cCopula(u_t,claytonCopula(param=0.14,dim=2),inverse=TRUE)
x<-qpois(u_t[,1],lambda=d.poisson$estimate[1]) y<-qgamma(V[,2],shape=claim_size.gamma$estimate[1],rate=claim_size.gamma$estimate[2]) plot(data_sinout$d,data_sinout\$claim_size,main='Test dataset x and y',col='blue')
points(x,y,col='red')
legend('topright', c('Observed', 'Simulated'), col = c('blue', 'red'), pch=21)

but instead I have:

which is not what I was expecting. Any help would be really appreciate it.