lara harrup (IAH-P)
2008-Sep-03 08:46 UTC
[R] ANCOVA/glm missing/ignored interaction combinations
Hi I am using R version 2.7.2. on a windows XP OS and have a question concerning an analysis of covariance with count data I am trying to do, I will give details of a scaled down version of the analysis (as I have more covariates and need to take account of over-dispersion etc etc) but as I am sure it is only a simple problem but I just can't see how to fix it. I have a data set with count data as the response (total) and two continuous covariates and one categorical explanatory variable (semio). When I run the following lines, after loading the data and assigning 'semio' as a factor, taking into account that I want to consider two way interactions:> model.a<-glm(total~(temperature+humidity+semio)^2,family=poisson) > summary(model.a)I get the output below. But not all interactions are listed there are 4 semio categories, 1,2,3 and 4 but only 2,3,and 4 are listed in the summary (semio2,semio3,semio4). And I cant for the life of me work out why category one (semio1) is being ignored, missing etc. Any help or suggestions would be most appreciated. Thanks in advance Lara lara.harrup at bbsrc.ac.uk Call: glm(formula = total ~ (temperature + humidity + semio)^2, family poisson) Deviance Residuals: Min 1Q Median 3Q Max -22.212 -5.132 -2.484 3.200 18.793 Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) 23.848754 2.621291 9.098 < 2e-16 *** temperature -1.038284 0.150465 -6.901 5.18e-12 *** humidity -0.264912 0.033928 -7.808 5.81e-15 *** semio2 22.852664 1.291806 17.690 < 2e-16 *** semio3 3.699901 1.349007 2.743 0.0061 ** semio4 -1.851163 1.585997 -1.167 0.2431 temperature:humidity 0.012983 0.001983 6.545 5.94e-11 *** temperature:semio2 -0.870430 0.037602 -23.149 < 2e-16 *** temperature:semio3 -0.060846 0.038677 -1.573 0.1157 temperature:semio4 0.055288 0.046137 1.198 0.2308 humidity:semio2 -0.114718 0.013369 -8.581 < 2e-16 *** humidity:semio3 -0.031692 0.013794 -2.298 0.0216 * humidity:semio4 0.008425 0.016020 0.526 0.5990 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for poisson family taken to be 1) Null deviance: 10423.5 on 47 degrees of freedom Residual deviance: 2902.2 on 35 degrees of freedom AIC: 3086.4 Number of Fisher Scoring iterations: 7
Mark Difford
2008-Sep-03 10:46 UTC
[R] ANCOVA/glm missing/ignored interaction combinations
Hi Lara,>> And I cant for the life of me work out why category one (semio1) is being >> ignored, missing >> etc.Nothing is being ignored Lara --- but you are ignoring the fact that your factors have been coded using the default contrasts in R, viz so-called treatment or Dunnett contrasts. That is, your intercept is semio1 and the other coefficients are calculated off it, hence the name treatment contrasts. In general this type of coding is recommended for GLM models (but this can raise deep divisions, as some don't consider them to be proper contrasts because they are not orthogonal). Perhaps you should read up on how dummy variables are coded. To really understand this you will have to move away from ?contrasts as a source. It might also help you to do the following on a simpler model: ?dummy.coef dummy.coef(saved.glm/lm.model) This shows how it is worked out. HTH, Mark. lara harrup (IAH-P) wrote:> > Hi > > I am using R version 2.7.2. on a windows XP OS and have a question > concerning an analysis of covariance with count data I am trying to do, > I will give details of a scaled down version of the analysis (as I have > more covariates and need to take account of over-dispersion etc etc) but > as I am sure it is only a simple problem but I just can't see how to fix > it. > > I have a data set with count data as the response (total) and two > continuous covariates and one categorical explanatory variable (semio). > When I run the following lines, after loading the data and assigning > 'semio' as a factor, taking into account that I want to consider two way > interactions: > >> model.a<-glm(total~(temperature+humidity+semio)^2,family=poisson) >> summary(model.a) > > I get the output below. But not all interactions are listed there are 4 > semio categories, 1,2,3 and 4 but only 2,3,and 4 are listed in the > summary (semio2,semio3,semio4). And I cant for the life of me work out > why category one (semio1) is being ignored, missing etc. > > Any help or suggestions would be most appreciated. Thanks in advance > > Lara > lara.harrup at bbsrc.ac.uk > > Call: > glm(formula = total ~ (temperature + humidity + semio)^2, family > poisson) > > Deviance Residuals: > Min 1Q Median 3Q Max > -22.212 -5.132 -2.484 3.200 18.793 > > Coefficients: > Estimate Std. Error z value Pr(>|z|) > (Intercept) 23.848754 2.621291 9.098 < 2e-16 *** > temperature -1.038284 0.150465 -6.901 5.18e-12 *** > humidity -0.264912 0.033928 -7.808 5.81e-15 *** > semio2 22.852664 1.291806 17.690 < 2e-16 *** > semio3 3.699901 1.349007 2.743 0.0061 ** > semio4 -1.851163 1.585997 -1.167 0.2431 > temperature:humidity 0.012983 0.001983 6.545 5.94e-11 *** > temperature:semio2 -0.870430 0.037602 -23.149 < 2e-16 *** > temperature:semio3 -0.060846 0.038677 -1.573 0.1157 > temperature:semio4 0.055288 0.046137 1.198 0.2308 > humidity:semio2 -0.114718 0.013369 -8.581 < 2e-16 *** > humidity:semio3 -0.031692 0.013794 -2.298 0.0216 * > humidity:semio4 0.008425 0.016020 0.526 0.5990 > --- > Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > > (Dispersion parameter for poisson family taken to be 1) > > Null deviance: 10423.5 on 47 degrees of freedom Residual deviance: > 2902.2 on 35 degrees of freedom > AIC: 3086.4 > > Number of Fisher Scoring iterations: 7 > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > >-- View this message in context: http://www.nabble.com/ANCOVA-glm-missing-ignored-interaction-combinations-tp19285259p19286859.html Sent from the R help mailing list archive at Nabble.com.
ONKELINX, Thierry
2008-Sep-03 14:02 UTC
[R] ANCOVA/glm missing/ignored interaction combinations
Lara, The first category is nor missing, nor ignored. It is used as the reference. So the temperature effect for semio1 is only temperature. The temperature effect for semio2 is temperature + temperature:semio2. For semio3 it is temperature + temperature:semio3. Hence the main effect of temperature is NOT the overall effect of temperature but the effect for the reference category (in your case semio1). It looks like you need to do some reading on ?contrasts and ?contr.treatment HTH, Thierry ------------------------------------------------------------------------ ---- ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 Thierry.Onkelinx op 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-help-bounces op r-project.org [mailto:r-help-bounces op r-project.org] Namens lara harrup (IAH-P) Verzonden: woensdag 3 september 2008 10:47 Aan: r-help op r-project.org Onderwerp: [R] ANCOVA/glm missing/ignored interaction combinations Hi I am using R version 2.7.2. on a windows XP OS and have a question concerning an analysis of covariance with count data I am trying to do, I will give details of a scaled down version of the analysis (as I have more covariates and need to take account of over-dispersion etc etc) but as I am sure it is only a simple problem but I just can't see how to fix it. I have a data set with count data as the response (total) and two continuous covariates and one categorical explanatory variable (semio). When I run the following lines, after loading the data and assigning 'semio' as a factor, taking into account that I want to consider two way interactions:> model.a<-glm(total~(temperature+humidity+semio)^2,family=poisson) > summary(model.a)I get the output below. But not all interactions are listed there are 4 semio categories, 1,2,3 and 4 but only 2,3,and 4 are listed in the summary (semio2,semio3,semio4). And I cant for the life of me work out why category one (semio1) is being ignored, missing etc. Any help or suggestions would be most appreciated. Thanks in advance Lara lara.harrup op bbsrc.ac.uk Call: glm(formula = total ~ (temperature + humidity + semio)^2, family poisson) Deviance Residuals: Min 1Q Median 3Q Max -22.212 -5.132 -2.484 3.200 18.793 Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) 23.848754 2.621291 9.098 < 2e-16 *** temperature -1.038284 0.150465 -6.901 5.18e-12 *** humidity -0.264912 0.033928 -7.808 5.81e-15 *** semio2 22.852664 1.291806 17.690 < 2e-16 *** semio3 3.699901 1.349007 2.743 0.0061 ** semio4 -1.851163 1.585997 -1.167 0.2431 temperature:humidity 0.012983 0.001983 6.545 5.94e-11 *** temperature:semio2 -0.870430 0.037602 -23.149 < 2e-16 *** temperature:semio3 -0.060846 0.038677 -1.573 0.1157 temperature:semio4 0.055288 0.046137 1.198 0.2308 humidity:semio2 -0.114718 0.013369 -8.581 < 2e-16 *** humidity:semio3 -0.031692 0.013794 -2.298 0.0216 * humidity:semio4 0.008425 0.016020 0.526 0.5990 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for poisson family taken to be 1) Null deviance: 10423.5 on 47 degrees of freedom Residual deviance: 2902.2 on 35 degrees of freedom AIC: 3086.4 Number of Fisher Scoring iterations: 7 ______________________________________________ R-help op r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. 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.%CRLF%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%CRLF%