This code does simulation 10^6 times to calculate the CDF for Poisson bivariate gamma distribution by generating random variables from previous distributions. Now I want to apply this code to real data in an excel file. How I can do that?
Explanation of the code: at the beginning of the loop will generate one value from Poisson if this value is zero so go to the next, if not zero then in (xx) generate the values from gamma equal to the value of Poisson ( if Poisson equal 2 then generate 2 value from gamma if Poisson is 4 then generate 4 value from gamma and so on), also in (yy) generate the values from gamma equal to the value of Poisson as explained earlier. But in real data, I want to take the value from the vector that follows Poisson and take the value from other vectors following gamma based on the taken Poisson value as explained above.
s <- c(2.3, 1.9)
l <- 4
a <- c(1, 1)
a1=a[1]
a2=a[2]
b <- c(2, 4)
b1=b[1]
b2=b[2]
count=0
ll=0
for (j in 1:10000000)
{
f = rpois(1,l)
if(f == 0)
{
count = count + 1
next
}
xx = rgamma(f,a1,rate=1/b1)
yy = rgamma(f,a2,rate=1/b2)
if(sum(xx)== s[1] && sum(yy)<= s[2])
{
ll = ll + 1
}
if(sum(xx)< s[1] && sum(yy)== s[2])
{
ll = ll + 1
}
if(sum(xx)< s[1] && sum(yy)< s[2])
{
count=count+1
}
}
pp1=((count)/10000000)
pp2=((count+ll)/10000000)
pp =((count+0.5*ll)/10000000)