Say I wanted to investigate the proportion of different types of nuts in bags of mixed nuts. So I weigh the nuts by type. Would I be able to use the information on weights and the Chi-squared test to analyze the nuts?
|
|
Edit: Based on a modified understanding of the problem, and after a discussion with @whuber (thanks, @whuber), I've modified my approach. My original answer treated the counts of nuts as the data, whereas the problem seems to ask how to test whether the different types of nuts are equally represented in terms of weight. My last solution (which can be seem by viewing the previous edit) is valid if there is no variation in the size of the nuts but that is probably not a realistic assumption. So, my modified understanding of the problem is that you've observed weights - $W_1, ..., W_k$ - of the $k$ different types of nuts and want to see whether or not there is evidence that more of some type of nuts are represented in the bag. That is, you test $$ H_0 : E(W_1) = \cdots = E(W_k)$$ To solve this problem we have to make some assumptions. Suppose that that average nut size for each type is known - $\mu_1, ..., \mu_k$ - and that the variance in nut size, $\sigma^2$, is the same across types but is unknown. Then we can envision the $W_{i}$'s arising from $$ W_i = \sum_{j=1}^{n_{i}} X_{ij} $$ where $X_{ij}$ is size of the $j$'th nut of type $i$ in the sample and $n_i$ is the number of nuts of type $i$ in each bag (suppose for simplicity that this is the same, but unknown, for all bags, otherwise this becomes a random sum and things are much more complicated). Let's assume normality of the nut sizes for brevity (although we could assume any other distribution with a mean and a variance, but we choose the normal here since it is closed under addition)so that $X_{ij} \sim N(\mu_i, \sigma^2)$. Then, assuming individuals nuts are independent, each observed weight of nut type $i$ has a $N(n_i \mu_i, n_i \sigma^2)$ distribution. Then we can re-formulate the null hypothesis as testing $$ H_0 : n_1 \mu_1 = \cdots =n_k \mu_k $$ Call this common value $\theta$. Note that, in order to test this hypothesis, we're going to need multiple bags of nuts since we need to estimate the variance and each of the $n_{i}$. Let's say we have $M$ bags and $W_{im}$ is the weight of nut type $i$ in bag $m$. Under the null hypothesis, $n_i = \theta/\mu_i$ and the joint likelihood is $$ \prod_{m=1}^M \prod_{i=1}^{k} \phi(W_{im} | \theta, \theta \sigma^{2}/\mu_i) $$ where $\phi(x|\mu,\tau^2)$ is the normal density with mean $\mu$ and variance $\tau^2$, which can be maximized as a function of $\theta, \sigma^2$. Call this optimum $L_0$. Without the constraint imposed by the null hypothesis, the joint likelihood is $$ \prod_{m=1}^M \prod_{i=1}^{k} \phi(W_{im} | n_i \mu_i, n_i \sigma^2) $$ which can be optimized as a function of $n_1, ..., n_k, \sigma^2$. Call this optimum $L_1$. Now, we can use the usual maximum likelihood machinery, which tells us that $$ \lambda = 2 \Big( \log(L_1) - \log(L_0) \Big) $$ has an asymptotic $\chi^2$ distribution. This is called the likelihood ratio test. The degrees of freedom are $k-1$, since we delete $k-1$ parameters (the $\mu_i$ are replaced by a single parameter $\theta$) to arrive at the submodel. In this example $k=5$. |
|||||||||||||
|