I am attempting to run a simulation in R that requires me to take a survey where the probability of selection for each individual is not equal.

I have a factor covariate $x$ which has levels $x_1, x_2, ..., x_5$ that is known for every member of the population before sampling, and I wish to give individuals a probability of selection based off their $x$, so that individuals with $x=x_1$ have the lowest chance of selection, and individuals with $x=x_5$ have the highest. So let's suppose $x_1 =1, x_2=2,..., x_5=5$

Suppose I therefore let $\pi_i = \frac{x_i}{\sum_{i=1}^N x_i}$ where $\pi_i$ is the chance of selection for person $i$.

With this in mind, I need to derive the probability of being included in a sample of size $n$ from the population of size $N$. In simple random sampling, this is just $\frac{n}{N}$, but I'm unsure how to derive it in this instance.

Likewise, for the purpose of variance estimation, I need to derive the joint inclusion probability for two individuals $i$ and $j$, the probability both are included in the sample. Again, in simple random sampling this is just $\frac{n(n-1)}{N(N-1)}$, but I'm not sure what it is here.

The reason I need the inclusion probabilities is so that I can find the sample weights, which are needed for estimation of my total $Y$ and its variance.

  • $\begingroup$ Do you select your sample with or without replacement? $\endgroup$ Jun 1, 2017 at 21:43
  • $\begingroup$ You don't have enough information. You need to know the distribution of $x$ in the population. $\endgroup$
    – AdamO
    Jul 9, 2018 at 14:58

2 Answers 2


Converting my comment to an answer.

You don't have enough information to answer the question specifically. Rather, it depends on the distribution of $x$ in the sampling frame (which we may assume to be the whole population).

Trivially, if you have a target sample of $n=$(say)$300$. That means that that sample will be apportioned 5:4:3:2:1 (15 parts) to members with $x=5$, $x=4$, $\ldots$, and $x=1$ respectively. (so 100, 80, 60, 40, 20 respectively). Once you know the distribution of $x$ in the population, you just calculate the SRS sampling probability 5 times. For instance, if $X=1$ has 1,000 people in the population, then the sampling probability is $20/1000 = 0.005$ and so on and so forth.

That is the answer to the problem along with a description of the missing information.


Suppose we take a sample of size $n$, and let's define $I^{(i)}_j$ as the indicator of whether or not individual $i$ is chosen on the $j^\text{th}$ selection (it equals one if the person is selected and otherwise it equals zero). Then

\begin{align} P( \text{individual $i$ is included in the sample}) &= P \left ( \sum_{j=1}^{n} I_j^{(i)} = 1 \right ) \\ &= \text{E} \left ( \sum_{j=1}^{n} I_j^{(i)} \right ) \\ &= \sum_{j=1}^{n} \text{E} \left ( I_j^{(i)} \right ) \\ &= n \pi_i . \end{align}

We can check that when we're sampling uniformly and $\pi_i = 1 / N$ we do in fact recover the original formula $n / N$. A similar technique can be used to find the probability that individuals $i$ and $j$ are both included in the sample

\begin{align} P(\text{individuals $i$ and $j$ are in the sample}) &= P \left [ \left ( \sum_{k=1}^{n} I_k^{(i)} \right ) \left ( \sum_{l=1}^{n} I_l^{(j)} \right ) = 1 \right ] \\ &= \text{E} \left [ \left ( \sum_{k=1}^{n} I_k^{(i)} \right ) \left ( \sum_{l=1}^{n} I_l^{(j)} \right ) \right ] \\ &= \text{E} \left ( \sum_{k=1}^{n} \sum_{l=1}^{n} I_k^{(i)} I_l^{(j)} \right ) \\ &= \sum_{k=1}^{n} \sum_{l=1}^{n} \text{E} ( I_k^{(i)} I_l^{(j)} ) . \end{align}

Now $I_k^{(i)} I_l^{(j)} = 0$ whenever $k = l$ (we can't select both individuals at the same time) so we're left with the remaining $2 \binom{n}{2} = n (n - 1)$ terms which by symmetry are all equal. The sum above therefore becomes

\begin{align} n (n - 1) \text{E}( I_1^{(i)} I_2^{(j)} ) &= n (n - 1) P(I_1^{(i)} = 1 \cap I_2^{(j)} = 1) \\ &= n (n - 1) P(I_1^{(i)} = 1) P(I_2^{(j)} = 1 \mid I_1^{(i)} = 1) \\ &= n (n - 1) \pi_i \frac{x_j}{\sum_{k \neq i} x_k} . \end{align}

Again we can compare this with the original formula where we have uniform sampling by setting $x_i = 1$ for $1 \leq i \leq N$ and our new formula does reduce to $\frac{n (n - 1)}{N (N - 1)}$.

  • $\begingroup$ The first formula is clearly incorrect if $\pi_i > 1/n$. For example, if $x_1 = 1, ..., x_5 = 5$ as in the question, then $\pi_5 = 1/3$, and if we take $n > 3$. $\endgroup$ Jun 22, 2022 at 23:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.