Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

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?

share|improve this question
When you say you want to Say I wanted to investigate the proportion of different types of nuts in bags of mixed nuts - what do you mean? Do you want to see whether the different types of nuts are equally represented in the bag? Or, are you trying to see whether a particular type of nut is overrepresented? Or, ..? – Macro Jul 19 '12 at 20:31
I want to see whether the different types of nuts are equally represented – BOB Jul 19 '12 at 20:37
How many different types are there? How many nuts are in the bag total? – Macro Jul 19 '12 at 20:39
There are five different types of nuts in the bag – BOB Jul 19 '12 at 20:41
3  
Wait. Or rather Weight! Is the question about the number of each types of nuts in the bag (in which case the chi-square will do the job as Macro explains) or about the weights (as the original question seems to imply)? – Harvey Motulsky Jul 19 '12 at 21:54
show 7 more comments

1 Answer

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$.

share|improve this answer
The data are weights, not counts. – whuber Jul 20 '12 at 12:30
@whuber, when I posted this, it was under the impression the data were counts. I'm awaiting confirmation from the OP at which time I'll modify/delete. – Macro Jul 20 '12 at 12:34
Isn't the problem statement quite clear? Where is the ambiguity? It might help to know that there is a standard method to count large numbers of small things having a known mean individual weight: just weigh the whole collection and divide by the known weight. Imagine doing this with five collections of nuts and wanting to know whether the resulting five weights are consistent with the hypothesis of equal nut counts: that's what's going on in this question. The reference to chi-squared is a red herring, because it's (obviously) inapplicable. – whuber Jul 20 '12 at 12:39
@whuber, I guess the ambiguity arose for me in the title and first sentence. Also, I wasn't thinking of "weigh" in terms of weight on a scale, as it usually doesn't mean that in statistics. It seems to me that if you know the weight-per-nut then you can convert the weights to counts and you're back to the answer I gave except you're no longer testing whether the counts are equal - you're testing some other point hypothesis - but you're still using the $\chi^2$ test. – Macro Jul 20 '12 at 13:00
1  
I disagree with you, Macro, mainly because I'm confident that nuts vary in weight enough for this variation to matter. If, say, your nuts average 1 gm with an SD of 0.1 gm and the weight is 100 gm, then you likely have between 97 and 103 nuts. This is a small range, to be sure, but it's going to affect the chi-squared test. Better solutions are readily available. (Use MLE.) – whuber Jul 20 '12 at 13:20
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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