[R-sig-ME] Testing significance of deviation of sex ratio (prop of females) from a priori predicted proportion
Tom Wenseleers
Tom.Wenseleers at bio.kuleuven.be
Mon Jan 20 17:21:37 CET 2014
Hi Thierry,
Ha, are you sure - can't I use it to model possible overdispersion in this case?
Cheers,
Tom
-----Original Message-----
From: ONKELINX, Thierry [mailto:Thierry.ONKELINX at inbo.be]
Sent: 20 January 2014 15:41
To: Tom Wenseleers; r-sig-mixed-models at r-project.org
Subject: RE: [R-sig-ME] Testing significance of deviation of sex ratio (prop of females) from a priori predicted proportion
Dear Tom,
I presume you have multiple measurements per colony? If not, it does not makes sense to use colony as a random intercept. And hence to use mixed models...
Best regards,
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
Thierry.Onkelinx at inbo.be
www.inbo.be
To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data.
~ Roger Brinner
The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey
-----Oorspronkelijk bericht-----
Van: Tom Wenseleers [mailto:Tom.Wenseleers at bio.kuleuven.be]
Verzonden: maandag 20 januari 2014 14:31
Aan: ONKELINX, Thierry; r-sig-mixed-models at r-project.org
Onderwerp: RE: [R-sig-ME] Testing significance of deviation of sex ratio (prop of females) from a priori predicted proportion
Hi Thierry,
I now tried
library(devtools)
install_github("lme4",user="lme4") # latest development version
library(lme4)
library(multcomp)
library(gtools)
library(car)
data=read.csv("http://www.kuleuven.be/bio/ento/temp/test_data_sexratio.csv",header=T,stringsAsFactors=T)
data$baseline=logit(0.75)
fit0=glmer(cbind(female,male) ~ offset(baseline)+(1|colony), family = binomial(link=logit), data = data)
summary(fit0)
# test significance of deviation from 3:4 (0.75) using LRT:
Anova(fit0,type=3,test="Chisq") # significance of deviation from 0.75 tested using LRT
# same model but without offset to calculate confidence limits on non-offsetted data
fit1=glmer(cbind(female,male) ~ (1|colony), family = binomial(link=logit), data = data)
# confidence limits calculated using glht
cl=confint(glht(fit1))
inv.logit(cl$confint[1,]) # est prop of females, with 95% confidence limits
# confidence limits calculated using likelihood profiling
cl=confint(fit1) # confidence limits calculated using likelihood profiling
inv.logit(c(attr(fit1,"beta"),as.matrix(cl)[2,])) # mean and 95% confidence limits
Is this correct you reckon? And is the significance calculated using the LRT correct? And what method would be preferred to calculate the confidence limits? Using glht? (Would that use Wald type confidence limits) Or using likelihood profiling (am I correct that this would correspond to the LRT result)?
Cheers & thanks again for your help!
Tom
-----Original Message-----
From: ONKELINX, Thierry [mailto:Thierry.ONKELINX at inbo.be]
Sent: 20 January 2014 12:36
To: Tom Wenseleers
Cc: r-sig-mixed-models at r-project.org
Subject: RE: [R-sig-ME] Testing significance of deviation of sex ratio (prop of females) from a priori predicted proportion
Hi Tom,
Try
data$baseline <- qlogis(0.75)
fit <- glmer(cbind(females, males) ~ offset(baseline) + (1|colony), family = binomial(link=logit), data = data)
or send me a reproducible example.
Please keep the mailing list in cc.
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
Thierry.Onkelinx at inbo.be
www.inbo.be
To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data.
~ Roger Brinner
The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey
-----Oorspronkelijk bericht-----
Van: Tom Wenseleers [mailto:Tom.Wenseleers at bio.kuleuven.be]
Verzonden: maandag 20 januari 2014 10:37
Aan: ONKELINX, Thierry
Onderwerp: RE: [R-sig-ME] Testing significance of deviation of sex ratio (prop of females) from a priori predicted proportion
Hi Thierry,
One problem though I bump into:
library(devtools)
install_github("lme4",user="lme4")
library(lme4)
If I then try
fit=glmer(cbind(femalesmales) ~ offset(qlogis(0.75)) + (1|colony), family = binomial(link=logit), data = data) I get the error Error in model.frame.default(data = data, drop.unused.levels = TRUE, :
variable lengths differ (found for 'offset(qlogis(0.75))')
Any thoughts what I am doing wrong? What version of lme4 should I be using?
Cheers,
Tom
-----Original Message-----
From: ONKELINX, Thierry [mailto:Thierry.ONKELINX at inbo.be]
Sent: 20 January 2014 09:24
To: Tom Wenseleers; r-sig-mixed-models at r-project.org
Subject: RE: [R-sig-ME] Testing significance of deviation of sex ratio (prop of females) from a priori predicted proportion
Dear Tom,
I would add the null hypothesis as an offset. Then the intercept would be the deviation from that null hypothesis.
Fit <- glmer(cbind(females, males) ~ offset(qlogis(0.75)) + (1|colony), family = binomial, data = data)
library(multcomp)
confint(glht(Fit))
Addingspacesmakescodemuchmorereadable.
Best regards,
Thierry
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
Thierry.Onkelinx at inbo.be
www.inbo.be
To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data.
~ Roger Brinner
The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey
-----Oorspronkelijk bericht-----
Van: r-sig-mixed-models-bounces at r-project.org [mailto:r-sig-mixed-models-bounces at r-project.org] Namens Tom Wenseleers
Verzonden: maandag 20 januari 2014 0:54
Aan: r-sig-mixed-models at r-project.org
Onderwerp: [R-sig-ME] Testing significance of deviation of sex ratio (prop of females) from a priori predicted proportion
Dear all,
I have counts of males and females produced by different colonies of a species of social insects.
I fitted the model
Fit=glmer(cbind(females,names)~1+(1|colony),family=binomial,data=data)
However, how can I test within such a framework if the overall average sex ratio deviates from an a priori predicted value (e.g. half females, or ¾ females)?
I presume this would have to be done based on the fitted intercept. But how does one do this? Also, what would be the best way to get 95% conf lims on the estimate? Using likelihood profiling, or parametric bootstrap? Does anybody happen to have any example calculation?
Cheers,
Tom
_______________________________________________________________________________________
Prof. Tom Wenseleers
* Lab. of Socioecology and Social Evolution
Dept. of Biology
Zoological Institute
K.U.Leuven
Naamsestraat 59, box 2466
B-3000 Leuven
Belgium
* +32 (0)16 32 39 64 / +32 (0)472 40 45 96
* tom.wenseleers at bio.kuleuven.be
http://bio.kuleuven.be/ento/wenseleers/twenseleers.htm
[[alternative HTML version deleted]]
* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * * Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document.
* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * * Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document.
* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * * Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document.
More information about the R-sig-mixed-models
mailing list