Stratified Sampling Allocation You believe that the mean electricity usage is about twice as much for houses as
for apartments or condominiums, and that the standard deviation is proportional
to the mean so that S1 = 2S2 = 2S3. How would you allocate a stratified sample
of 900 observations if you wanted to estimate the mean electricity consumption
for all households in the city?
I'm confused as to whether this is a proportional allocation problem or a optimum allocation one. Proportional allocation formula doesn't include standard deviation anywhere
 A: Because you have no evident need to make the proportions in the sample similar to those in the population, this is an optimal allocation problem: that is, it focuses on sampling to produce the smallest possible expected standard error of estimate.
Analysis
When the strata populations are $N_h,$ $h=1,2,3$ with $N_1+N_2+N_3=N$  being the total numbers of houses, apartments, and condos; and the sample sizes (to be determined) are $n_h,$ for $h=1,2,3$ with $n_1+n_2+n_3=900 = n$ the budgeted sample size, then let the mean values in the strata be $\bar{x}_h$ and the sample variances in the strata be $s_h^2.$ In these terms the estimated mean is
$$\bar x = \sum_h \frac{N_h}{N}\bar{x}_h$$
(a weighted mean with weights proportional to the actual sizes of the strata in the population) and its sampling variance (the square of the standard error of estimate) is
$$s^2_{\bar x}=\sum_h \left(\frac{N_h}{N}\right)^2\,\left(1 - \frac{n_h}{N_h}\right)\, \frac{s_h^2}{n_h}.$$
You are supposing that $s_3^2 = s_2^2$ (let's simply call this common value $s^2$) but $s_1^2 = (2s)^2 = 4s^2.$  In general let's write
$$s_h^2 = \omega^2 s^2$$
so that the relative standard deviations are $\omega = (2,1,1).$
So, although we don't know $s^2$ during this planning stage, we can still express the eventual margin of error as a multiple of $s^2$ by plugging in these values for the $s_h^2$ in the previous formula and dividing both sides by $s^2,$ giving
$$f(n_1,n_2,n_3) = \frac{s^2_{\bar x}}{s^2}=\sum_h \left(\frac{N_h}{N}\right)^2\,\left(1 - \frac{n_h}{N_h}\right)\, \frac{\omega_h^2}{n_h} = \sum_h \left(\frac{N_h\omega_h}{N}\right)^2\,\left(\frac{1}{n_h} - \frac{1}{N_h}\right).$$
In these terms your objective can be framed as a constrained optimization problem:

Minimize $f(n_1,n_2,n_3)$ subject to the constraints $0 \le n_h \le N_h$ for each $h$ and $n_1+n_2+n_3 \le 900.$

Results
Let's draw some useful conclusions from this:

*

*You need to know (at least to a good approximation) the relative sizes of each stratum in the population, $N_h/N.$  The larger ones will dominate the calculation of $f$ because they appear as squares in its formula.  (After all, you can't even estimate the overall mean $\bar x$ without knowing the $N_h.$)


*Writing $y_h = 1/n_h - 1/N_h$ re-expresses the objective function in the form $$g(y) = \sum_{h} \alpha_h^2\, y_h$$ for given numbers $$\alpha_h = N_h \omega_h / N.$$  We can recover the optimal $n_h$ from a solution for the $y_h$ because $$n_h = \frac{1}{y_h + 1/N_h}.$$  The constraints on the $n_h$ become $$y_h \ge 0;\quad c(y_1,y_2,y_3) = \sum_h \frac{1}{y_h + 1/N_h} \le 900.$$


*$(2)$ exhibits the problem as an optimization problem with (very simple) linear constraints, but with a twist: the values of $n_h$ are supposed to be whole numbers.  Except when the sample size is very small, a good approximate solution is usually obtained by finding the optimal $n_h$ as real numbers and rounding them.  It's a good idea to round the smallest values up.  You can even modify the constraints to guarantee there's a minimum sample size in each stratum, because you may have a secondary objective of producing some reasonable estimates of the individual stratum means.


*A general solution to the optimization uses Lagrange Multipliers and the KKT conditions.  However, the only constraint that will apply to the solution is the nonlinear one $c(y_1,y_2,y_3) \le 900,$ because the others apply only if you were to sample an entire stratum, which is never going to happen because that would zero out its contribution to the standard error.  The method of Lagrange multipliers immediately shows the optimum is attained when the $n_h$ are proportional to the $\alpha_h \propto N_h\omega_h,$ giving the solution $$n_h^{*} = 900\,\frac{N_h \omega_h}{\sum_h N_h \omega_h}$$ (which you then round).


*Inspecting $(4)$ gives this memorable rule:

Allocate the samples in proportion to the stratum sizes and the expected population standard deviations.


Robustness
Because the standard error as a function of the $n_h$ is quadratic near the optimum values, it changes very little even if you don't find the exact optimum.  I'll demonstrate this with a worked example.  Suppose your city has 500 houses, 2500 apartments, and 3000 condominiums, so that $(N_h) = (500, 2500, 3000)$ and $N=6000$ dwelling.  Then the raw weights vector is
$$\alpha = (500\times 2, 2500\times 1, 3000 \times 1)/6000 = \left(\frac{1}{6}, \frac{5}{12}, \frac{1}{2}\right),$$
yielding the optimum allocation
$$(n_h)^{*} = 900\left(\frac{1}{6}, \frac{5}{12}, \frac{1}{2}\right)\,/\, (1/6+5/12+1/2) = (138, 346, 415).$$
(Rounding caused this allocation to sum only to $899.$  Assign the leftover subject to, say, the smallest sample if you like.)
What happens if we don't specify an optimal design?  The figure plots what happens to the square of the standard error when we take $dn$ observations out of one stratum's sample and allocate them to another stratum.  There are three possible ways to do this, distinguished by colors in the graphs:

Even when mis-allocating $70$ observations (which is half the size of the sample of houses), the sampling variance barely changes in this example.
In general, this phenomenon of robustness to sample design occurs in relatively large surveys.  That's why we needn't fuss about the rounding issue, nor even worry too much about whether our guesses about the strata standard deviations (or even the stratum sizes in the population) are absolutely correct: we just have to get reasonably close.
A: Kevin, for example for the optimun allocation:
$$S_{1}=2 \cdot S_{2} =2 \cdot S_{3}$$
$$n_{1}/n= \frac{N_{1} \cdot S_{1} } {N_{1} \cdot S_{1} + N_{2} \cdot S_{2}+ N_{3} \cdot S_{3}}=$$
$$ \frac{W_{1} \cdot S_{1} } {W_{1} \cdot S_{1} + W_{2} \cdot S_{1}/2+ W_{3} \cdot S_{1}/2}=$$
$$ \frac{W_{1} \cdot S_{1} } {S_{1} \cdot (W_{1} + W_{2}/2+ W_{3}/2)}=$$
$$ \frac{W_{1}  } { (W_{1} + W_{2}/2+ W_{3}/2)}=$$
(if $S_{i}$ is the S.D.)
