# Binomial test with nested data

I hope to compare the proportion of "IN" & "OUT" outcomes in my data. I would have used a simple binomial test (our hypothesis is that the subjects are more likely to endorse "OUT" than "IN") but the outcomes are nested within each subject so I'm thinking there should be a more appropriate way to analyze this data.

Here's a snippet of my data:

ID  Age Sex Outcome
1   19  M   IN
1   19  M   OUT
1   19  M   IN
1   19  M   IN
8   21  M   OUT
8   21  M   OUT
8   21  M   OUT
8   21  M   OUT
10  28  M   OUT
10  28  F   OUT
10  28  F   OUT
10  28  F   OUT
15  32  F   IN
15  32  F   IN
15  32  F   OUT
15  32  F   OUT
22  21  F   OUT
22  21  F   OUT
22  21  F   OUT
22  21  F   IN


Does anyone have any suggestions?

• You can use logistic regression with the response as a binomial instead of a Bernoulli. Is that your complete dataset? Do you have only 5 subjects? (You won't be able to test if the response is related to age or sex.) – gung - Reinstate Monica Feb 14 '16 at 14:12
• Oh I actually have about 53 subjects! Hmm I did some searching on the internet...will using glm(formula=cbind(Groupness, Trials-Groupness), family = binomial, data = W) be appropriate for my data? And thanks for the helpful response! – RukiaPsych Feb 14 '16 at 16:17

We prototypically think of logistic regression as having a response that is distributed as a Bernoulli (every study unit has a single $0$ or $1$). But logistic regression is more general than that: it can handle binomial response data where the number of trials is $>1$. If your four trials don't differ in any meaningful way, you can think of each person as having a single response consisting of the number of times they selected OUT (from $[0, 4]$ times).
Statistical software can handle this, but typically needs to be informed that that is the setup of your data. For example, in R your response would be:
cbind(number_of_times_OUT_is_chosen, number_of_times_IN_is_chosen)