I have the results of a dual choice test to evaluate oviposition preference. In the experimental arena, the same insect was offered simultaneously two plants (A and B) and the number of eggs laid on each plant was counted. So the assumption of independence would not be fulfilled and it seems to me more correct to use a binomial distribution than a Poisson distribution.The problem appears when I want to use a binomial distribution because it would have no explanatory variable. The variable would be the proportion of eggs laid on one of the plants (number of eggs laid in A/ total eggs laid in A +B) against.. nothing! Because the explanatory variable (type of plant:A and B) is contained within the response variable. These are two sides of the same coin.

Would it be correct to write the binomial model like this? or is it better to use a chi-square distribution? I have ten replicates.

m<-glm(eggsproportion ~ 1 , family=binomial, weights = total, data=eggs)


  • 1
    $\begingroup$ What is your research aim? What do you need the distribution for? "So the assumption of independence would not be fulfilled" - independence between what? Where would this be assumed? $\endgroup$ Commented Mar 22, 2023 at 17:05
  • 1
    $\begingroup$ The binomial distribution as a standard is a distribution of a variable of the type "number of successes in n trials" (or whatever you want to count as "success"). It does not imply any explanatory variable, and for sure you don't need the glm command to fit it. (Have a look at the binom.test command.) $\endgroup$ Commented Mar 22, 2023 at 17:07
  • $\begingroup$ What exactly do you want to test? $\endgroup$
    – Dave
    Commented Mar 22, 2023 at 17:10
  • $\begingroup$ Thanks for your reply. I want to know if the insect has a preference for laying eggs on any of the plants I offered it. As I offer it two plants at the same time, the choice of one may be conditioned by the presence of another. The insect moves freely and lays eggs on both plants. That is what I meant by lack of independence in the bioassay. $\endgroup$ Commented Mar 22, 2023 at 17:37
  • $\begingroup$ Then it seems like you just want to test if the proportion of eggs on plant A is different from $0.5$ (or some other value of interest), right? (Better yet might be to calculate a confidence interval for the proportion!) // I have some concerns about independence of the eggs being laid, and independence is an assumption of the usual tests, but that can be for a later discussion. $\endgroup$
    – Dave
    Commented Mar 22, 2023 at 17:44

1 Answer 1


In general, you can use the GLM as a way of doing the one-sample hypothesis test for a proportion.

y <- rbinom(100, 1, 0.4) ## the illusive biased coin realization
f <- glm(y ~ 1, family=binomial)


            Estimate Std. Error z value Pr(>|z|)
(Intercept)  -0.2819     0.2020  -1.395    0.163

Where the (Intercept) is the log-odds of response. In other words, if $p=0.5$, then $\log\left(p/(1-p)\right) = 0$. So, at the 0.05 level I would not reject the null hypothesis that my coin is fair.

Note to test any proportion other than 0.5, you would need to calculate and add an offset to the model. For instance, if the null were that p=0.3, then the log odds of p is -0.84, and setting the offset to this value for each result gives a hypothesis test for p!=0.3 in the intercept term.

Anyway, you could compare this result to:

prop.test(sum(y), 100, correct = F)

Which gives nearly the same result:

    1-sample proportions test without continuity correction

data:  sum(y) out of 100, null probability 0.5
X-squared = 1.96, df = 1, p-value = 0.1615
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
 0.3373330 0.5278461
sample estimates:

Of course, the important bits are a) that you have pivoted from your planned analysis due to a suspicion of non-independent data and b) a binomial analysis won't actually handle dependence in data. The interesting bit is that the analysis is essentially the same as the Poisson! The "log-linear modeling" approach has known connections to logistic regression. Consider our biased coin experiment:

t <- as.data.frame(table(y))

gives a tabular result:

  y Freq
1 0   57
2 1   43

and fitting the Poisson model gives you the exact same result.

> summary(glm( Freq ~ y, family=poisson, data=t))

glm(formula = Freq ~ y, family = poisson, data = t)

Deviance Residuals: 
[1]  0  0

            Estimate Std. Error z value Pr(>|z|)    
(Intercept)   4.0431     0.1325  30.524   <2e-16 ***
y1           -0.2819     0.2020  -1.395    0.163    
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for poisson family taken to be 1)

    Null deviance:  1.9665e+00  on 1  degrees of freedom
Residual deviance: -6.4393e-15  on 0  degrees of freedom
AIC: 15.487

Number of Fisher Scoring iterations: 2

In other words, I still have $p=0.163$ for whether I get "more heads" or "more tails" in the count model. Conditioning on the overall count of data is already handled by adjusting for the intercept in the Poisson model.

In the experimental arena, the same insect was offered simultaneously two plants (A and B) and the number of eggs laid on each plant was counted. So the assumption of independence would not be fulfilled

Unfortunately, this is not any description at all of dependent data! By "insect" I assume you mean several specimens of a particular species of insect, and you are thinking that if subject A lays on plant A then subject B is more likely to lay on plant B, then there is really no way to handle this in the analysis, it's a feature of the design. The preference for plant A may really be a result of there is only one other plant to lay on, and if there are more on A, you can still declare there's a preference for "A", it's just subject to the conditions of the study.

  • $\begingroup$ Thank you so much for your response! When I speak of insect, I mean a single individual enclosed together with two different plants A and B. That is the replica: one individual with two plants. This single individual lays eggs on both plants and I want to know if it lays more eggs on one relative to the other. Also, there is a biological limit on the total number of eggs it can lay. I think that laying eggs on one plant could condition the laying of eggs on the other plant. That's what I assume a dependent event is. $\endgroup$ Commented Mar 24, 2023 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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