# Confidence Interval of proportions

I'm working on a project with this sort of setup, but I changed the description to make it more understandable.

In a city there are males and females each with corresponding weights (lbs). We wish to determine the proportion of the total amount of weight in the city that comes from males. We do this by sampling 500 people at random, and calculating $$\hat{p} = \dfrac{\sum(\text{weight of sampled men})}{\sum(\text{weight of all sampled people})}$$.

How would I calculate a confidence interval for this proportion? I tried bootstrapping, but can I use a normal approximation or more 'exact' method here? The reason I ask is because it seems a bit different than a typical binomial CI setup where there are a certain number of successes in a set of trials.

Per a sampling theory reference, I would regress an individual male's weight (y variable) vs. the sum of the male and a female's weight (x variable), based on a random pairing of a male and female (which would be a conservative estimate of the variance of the sampling theory regression estimator) that results in the statistic of interest:

$$Beta = \dfrac{\sum(\text{weight of sampled men})}{\sum(\text{weight of all sampled people})}$$

Then, per this sampling theory source Equation (47):

$$Var(Beta) = ((N-n)/N) /(n*{XBar(all)}^2)*{S_e}^2$$

where the $${S_e}^2$$ of the regression is the usual sample regression variance estimate based on the sum of squares of actual vs fitted adjusted for degrees of freedom. XBar(all) is the average of the total pair weights consisting of a single male plus a female as employed in the regression model. If the number of males N in the parent population is not known, replace the first term (sampling correction factor) with 1.

Compute the standard deviation to produce a Student's t-test based confidence interval for the proportion of interest.

[EDIT] Note, my suggested analysis does lose data unless the number of males equals the number of females. Also, for a parent population, where the number of males is smaller than the number of females, and the % is known, then apply an adjustment factor to the female's weight in constructing the x-variable to derive an appropriate statistic of interest for the parent population.

• +1 I thought about adding my thoughts on this questions as an answer but then I saw you have already written it down. – LuckyPal Apr 23 at 22:08

You can't use the normal approximation here. The normal approximation you are likely referring to comes from the Central Limit Theorem which concerns the asymptotic distribution of sums of iid random variables. Though you are summing iid random variables in the numerator, things are complicated because of the denominator.

If you are able to make some assumptions about the distribution of weight for males and females, I suppose you could use something like the delta method. Let $$w_m$$ and $$w_f$$ be random variables for a man and woman's weights respectively. Then

$$\sum_i^n w_{m,i} = n_m \bar{w}_m \sim \mathcal{N}(n_m\mu_m, n_m\sigma_m^2)$$

Where $$\mu_m$$ and $$\sigma_m$$ are population level mean and standard deviations for men's weights. A similar expression can be derived for women. Your statistic is then

$$\hat{p} = \dfrac{n_m \bar{w}_m}{n_m \bar{w}_m + n_f \bar{w}_f}$$

To use the delta method, you need to know the covariance between $$w_m$$ and $$w_f$$. It might be safe to assume these are independent. If so, then the you can use the delta method to get an estimate of the variance of $$\hat{p}$$. I can come back later after my meeting and try to work through this some more. I also may be off in the right direction, so someone let me know if I've said something wrong.

Just for some notational clarity, let $$X = n_m \bar{w}_m$$ and $$Y = n_f \bar{w}_f$$. We need the gradient of $$g(X,Y) = X/(X+Y)$$ which is

$$\nabla g = \left< \dfrac{Y}{(X+Y)^2}, \dfrac{-X}{(X+Y)^2} \right>$$

The variance of $$g(X,Y)$$ is

$$\nabla g^T \Sigma \nabla g$$

where $$\Sigma$$ is the covariance between $$X$$ and $$Y$$. Assuming they are independent, then $$\Sigma$$ is diagonal and the variance collapses to

$$\operatorname{Var}(g(X,Y)) = \dfrac{n_m\sigma^2_mY^2}{(X+Y)^4} + \dfrac{n_f\sigma^2_fX^2}{(X+Y)^4}$$

We can get an estimate of the variance by plugging in estimates of $$X$$ and $$Y$$ thanks to Slutsky's theorem. I think that should be correct, but let's simulate just to make sure.


nm = 20
nf = 20

weight_of_men = rnorm(nm, 80, 5)
sm = var(weight_of_men)
X = sum(weight_of_men)

weight_of_women = rnorm(nf, 70, 4)
sf = var(weight_of_women)
Y = sum(weight_of_women)

v = nm*sm*Y^2/((X+Y)^4) + nf*sf*X^2/((X+Y)^4)

ps = replicate(100000, {
nm = 20
nf = 20

weight_of_men = rnorm(nm, 80, 5)
sm = var(weight_of_men)
X = sum(weight_of_men)

weight_of_women = rnorm(nf, 70, 4)
sf = var(weight_of_women)
Y = sum(weight_of_women)

X/(X+Y)

})

#Computed variance
v
#Variance from simulation
var(ps)



Depending on your random seed, you might see different numbers but I get 2.70e-5 for my formula and 2.21e-05 from the simulation. They are at least on the same order of magnitude.

Your confidence interval is then $$\hat{p} \pm 2\sigma$$. Let's examine the coverage of this estimator.

library(tidyverse)

coverage = replicate(100000, {
nm = 20
nf = 20

weight_of_men = rnorm(nm, 80, 5)
sm = var(weight_of_men)
X = sum(weight_of_men)

weight_of_women = rnorm(nf, 70, 4)
sf = var(weight_of_women)
Y = sum(weight_of_women)

v = sqrt(nm*sm*Y^2/((X+Y)^4) + nf*sf*X^2/((X+Y)^4))

between(80/150, X/(X+Y) - 2*v, X/(X+Y) + 2*v)

})

mean(coverage)
>>>0.947



Bingo! 95% coverage using the derived variance. This solution heavily depends on the assumption of the random variables being independent, so have a think about that before implementing it.

• Thanks for the response! Yes the normal approx I was referring to was $$\hat{p} \pm 1.96 * \sqrt(\hat{p}*(1-\hat{p})/n)$$. Would bootstrapping be a suitable method if we don't wish to assume anything about the distribution of weights? – m55667 Apr 23 at 20:03
• @m55667 Yes, I think you should just bootstrap. – Demetri Pananos Apr 23 at 20:07