Generating from a binomial distribution whose quantile is given

by Jimmy Dur   Last Updated April 11, 2018 18:19 PM

I am trying to reproduce a simulation study in a paper.To do it, I need to generate counts for control and treatment groups as described below,

generate $θ_{i1}$ from $Uni(0.1, 0.2)$ for $i = 1, . . . ,k_{0}$ and set $θ_{i2} =θ_{i1}$ for $i=1, . . . ,k_{0}$. Set $θ_{i1}= 0.2$ and $θ_{i2}= 0.5$ for $i =k_{0}+1,...,k$. Set $n=40$, and for each $j ∈ {1, 2}$ and $i$, generate a count $C_{ji}$ from the binomial distribution $Bin(θ_{ji}, n)$ whose quantile is $u_{i}$.

for a given $u$, I am trying to generate counts $C_{ji}$ but I am not sure if I am doing it correctly. Based on my understanding, I wrote down the following R code. And it always gives $C_{1j}=C_{2j}$ for all $j=1,...,k_{0}$. I don't think this is the data generated for the simulations in the paper I am following. I may be misunderstanding something. I would appreciate if one can help me out.


#obtain p0 and p1

for (i in 1:k){

for (i in 1:k){

Related Questions

Quantile crossing with Quantile Regression Forests

Updated November 14, 2017 10:19 AM

Linear Properties of the Quantile Function

Updated May 11, 2017 08:19 AM

How can I analyze this variable

Updated January 18, 2018 15:19 PM

Quantile regression with spline smoothing

Updated November 22, 2017 13:19 PM