I'm currently a biology student and we use R occasionally for statistics. I'm currently looking at two groups chances of mating based on their size. I am using my own generated data for this and only the large group mates and the small group does not. My lecturer suggests using a Binomial GLM but using their code doesn't work and, to be honest, I am not sure what it is testing for. I need a test that compares chances of mating and if the difference is statistically different I think. This is the code that I am using. It works fine until the last line.
#this is 35 males who were chosed, with a mean claw size of 15
not.chosen.size<-rnorm(n=65,mean=5,sd=1.5)
#this is 65 males who were not chosen, with a mean claw size of 5
population.size<-c(chosen.size,not.chosen.size)
population.size
#add a column indicating whether they were chosen or not
yes<-rep(1,35)
no<-rep(0,65)
#combine them
chosen<-c(yes,no)
dat<-data.frame(population.size,chosen)
dat
mod<-glm(chosen~population.size,family=binomial,data=dat)
I would appreciate any help you can offer.
EDIT:
I've gotten these results by implementing the changes suggested by @EdM.
Min 1Q Median 3Q Max
-1.4430 -0.8965 -0.4957 0.9204 2.4367
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -4.4769 0.9991 -4.481 7.44e-06 ***
population.size 0.7105 0.1675 4.243 2.21e-05 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 133.75 on 99 degrees of freedom
Residual deviance: 107.94 on 98 degrees of freedom
AIC: 111.94
Number of Fisher Scoring iterations: 4
EDIT: New Code:
chosen.size<-rnorm(n=35,mean=7,sd=1.5)
#this is 35 males who were chosed, with a mean claw size of 7
not.chosen.size<-rnorm(n=65,mean=5,sd=1.5)
#this is 65 males who were not chosen, with a mean claw size of 5
population.size<-c(chosen.size,not.chosen.size)
population.size
#add a column indicating whether they were chosen or not
yes<-rep(1,39)
no<-rep(0,61)
#combine them
chosen<-c(yes,no)
dat<-data.frame(population.size,chosen)
dat
mod<-glm(chosen~population.size,family=binomial,data=dat)