Optimizing the sample size: number of individuals versus trials per individual Given that I have $C$ to spend on my experiment, what is the optimal number of individuals $n$ of my experiment?
Say that I want to estimate the mean $\mu$ of distribution of individuals
$$X_i \sim N(\mu, \sigma)$$
and I can sample several values from each individual which is distributed as
$$Y_{ij} \sim N(X_{i}, \tau)$$
Say that

*

*the costs of recruiting an individual are $a$

*and the cost of obtaining a sample are $b$
For example, when we sample Alice, Bob and Carol twice each and Eve once, then we sampled 4 persons 7 times and the cost will be $4a+7b$. (So sampling the same person another time only costs $b$ whereas sampling a new person will cost $a+b$)
then what is the ideal number of individuals $n$ and samples $k$, within the costs $C$ to get the highest precision of estimate (in terms of lowest variance).
Let's assume that we know $\sigma$ and $\tau$. But $\mu$, which we want to estimate, is unknown.
Let's assume that we use a weighted least squares to estimate $\mu$. And I consider optimal to be the lowest standard error of the estimate (which needs to be unbiased).

The mean per individual will be distributed as
$$\bar{Y}_i = \frac{1}{n_i} \sum_{j = 1}^{n_i} Y_{ij} \sim N\left(\mu, \sigma^2 + \tau^2/n_i\right)$$
where $n_i \geq 1$ are the number of observations for individual $i$ (we need at least 1 measurement for a participant).
The estimate will be
$$\hat{\mu} = \sum_{i=1}^n w_i \bar{Y}_i$$
with $$w_i =  \frac{(\sigma^2 + \tau^2/n_i)^{-1}}{ \sum_{l=1}^n (\sigma^2 + \tau^2/n_l)^{-1}} $$
and the variance will be
$$\text{VAR}(\hat{\mu}) = \frac{1}{\sum_{l=i}^n (\sigma^2 + \tau^2/n_i)^{-1}} \approx \frac{\sigma^2}{n }+ \frac{\tau^2}{ \sum n_i} =  \frac{\sigma^2}{n }+ \frac{\tau^2}{ m} $$
The approximate is exactly true when the $n_i$ are all the same. And we defined $m =  \sum n_i$.
The variance decreases when we increase $n$ or when we increase $m$. With the changes being
$$\frac{\partial}{\partial n}  \text{VAR}(\hat{\mu}) =  - \frac{\sigma^2}{n^2} \\
\frac{\partial}{\partial m}  \text{VAR}(\hat{\mu}) =  - \frac{\tau^2}{m^2} \\$$
and the optimum will occur when the amount of observations per individual follows the ratio
$$\frac{m}{n} = \frac{\tau\sqrt{a}}{\sigma\sqrt{b}}$$
and there is also the limit $\frac{m}{n} > 1$ because we need at minimum one observation per individual.
