Hi all, This could be naivety/stupidity on my part rather than a problem with model output, but here goes.... I have fitted a fairly simple model m1<-glm(count~siteall+yrs+yrs:district,family=quasipoisson,weights=weight,data=m[x[[i]],]) I want to know if yrs (a continuous variable) has a significant unique effect in the model, so I fit a simplified model with the main effect ommitted... m2<-glm(count~siteall+yrs:district,family=quasipoisson,weights=weight,data=m[x[[i]],]) then compare models using anova() anova(m1,m1b,test="F") Analysis of Deviance Table Model 1: count ~ siteall + yrs + yrs:district Model 2: count ~ siteall + yrs:district Resid. Df Resid. Dev Df Deviance F Pr(>F) 1 1936 75913 2 1936 75913 0 0>The d.f.'s are exactly the same, is this right? Can I only test the significance of a main effect when it is not in an interaction? Thanks in advance, Simon. Dr. Simon Pickett Research Ecologist Land Use Department Terrestrial Unit British Trust for Ornithology The Nunnery Thetford Norfolk IP242PU 01842750050 [[alternative HTML version deleted]]
On 19-Feb-09 10:38:50, Simon Pickett wrote:> Hi all, > > This could be naivety/stupidity on my part rather than a problem > with model output, but here goes.... > > I have fitted a fairly simple model > > m1<-glm(count~siteall+yrs+yrs:district,family=quasipoisson, > weights=weight,data=m[x[[i]],]) > > I want to know if yrs (a continuous variable) has a significant > unique effect in the model, so I fit a simplified model with the > main effect ommitted... > > m2<-glm(count~siteall+yrs:district,family=quasipoisson, > weights=weight,data=m[x[[i]],])So, above, you have fitted two models: m1, m2> then compare models using anova() > anova(m1,m1b,test="F")And here you are comparing two models: m1, m1b Could this be the reason for your result?> Analysis of Deviance Table > > Model 1: count ~ siteall + yrs + yrs:district > Model 2: count ~ siteall + yrs:district > Resid. Df Resid. Dev Df Deviance F Pr(>F) > 1 1936 75913 > 2 1936 75913 0 0 > > The d.f.'s are exactly the same, is this right? Can I only test the > significance of a main effect when it is not in an interaction? > > Thanks in advance, > Simon.-------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 19-Feb-09 Time: 10:56:12 ------------------------------ XFMail ------------------------------
Cheers Mark, I did originally think too, i.e. that not including the main effect was the problem. However, the same thing happens when I include main effects.... test1<-glm(count~siteall+yrs*district,family=quasipoisson,weights=weight,data=m[x[[i]],]) test2<-glm(count~siteall+district+yrs:district,family=quasipoisson,weights=weight,data=m[x[[i]],]) anova(test1,test2,test="F") Model 1: count ~ siteall + yrs * district Model 2: count ~ siteall + district + yrs:district Resid. Df Resid. Dev Df Deviance F Pr(>F) 1 1933 75665 2 1933 75665 0 0 Simon. ----- Original Message ----- From: <markleeds at verizon.net> To: "Simon Pickett" <simon.pickett at bto.org> Sent: Thursday, February 19, 2009 10:50 AM Subject: RE: [R] type III effect from glm()> Hi Simon: John Fox can say a lot more about below but I've been reading > his book over and over recently and one thing he constantly stresses is > marginality which he defines as always including the lower order term if > you include it in a higher order term. So, I think below is problematic > because you are including an interaction that includes the main effect but > not including the main effect. This definitely causes problems when trying > to interpret > the anova table or the Anova table. That's as much as I can say. I highly > recommed his text for this sort of thing and hopefully he will respond. > > Oh, my point is that if you want to check the effect of yrs, then I think > you have to take it out of model 2 totally in order to interpret the anova > ( or the Anova ) table. > > On Thu, Feb 19, 2009 at 5:38 AM, Simon Pickett wrote: > >> Hi all, >> >> This could be naivety/stupidity on my part rather than a problem with >> model output, but here goes.... >> >> I have fitted a fairly simple model >> >> m1<-glm(count~siteall+yrs+yrs:district,family=quasipoisson,weights=weight,data=m[x[[i]],]) >> >> I want to know if yrs (a continuous variable) has a significant unique >> effect in the model, so I fit a simplified model with the main effect >> ommitted... >> >> >> m2<-glm(count~siteall+yrs:district,family=quasipoisson,weights=weight,data=m[x[[i]],]) >> >> then compare models using anova() >> anova(m1,m1b,test="F") >> >> Analysis of Deviance Table >> >> Model 1: count ~ siteall + yrs + yrs:district >> Model 2: count ~ siteall + yrs:district >> Resid. Df Resid. Dev Df Deviance F Pr(>F) >> 1 1936 75913 2 1936 75913 0 >> 0 >>> >> >> The d.f.'s are exactly the same, is this right? Can I only test the >> significance of a main effect when it is not in an interaction? >> Thanks in advance, >> >> Simon. >> >> >> >> >> >> >> Dr. Simon Pickett >> Research Ecologist >> Land Use Department >> Terrestrial Unit >> British Trust for Ornithology >> The Nunnery >> Thetford >> Norfolk >> IP242PU >> 01842750050 >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> 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. >
Hi Simon: In below , test1 spelled out is count ~ siteall + yrs + district + yrs:district so this is fine. but in test2 , you have years interacting with district but not the main effect for years. this is against the rules of marginality so I still think there's a problem. I would wait for John or the other wizaRds to respond ( you know who you are ) because I don't feel particularly confident giving advice on this because I bang my head against it often also. Plus, I gotta go home because it's getting light out soon ( i'm in the US on the east coast ). Good luck. On Thu, Feb 19, 2009 at 6:10 AM, Simon Pickett wrote:> Cheers Mark, > > I did originally think too, i.e. that not including the main effect > was the problem. However, the same thing happens when I include main > effects.... > > > test1<-glm(count~siteall+yrs*district,family=quasipoisson,weights=weight,data=m[x[[i]],]) > > test2<-glm(count~siteall+district+yrs:district,family=quasipoisson,weights=weight,data=m[x[[i]],]) > anova(test1,test2,test="F") > > Model 1: count ~ siteall + yrs * district > Model 2: count ~ siteall + district + yrs:district > Resid. Df Resid. Dev Df Deviance F Pr(>F) > 1 1933 75665 > 2 1933 75665 0 0 > > Simon. > > > > > ----- Original Message ----- From: <markleeds at verizon.net> > To: "Simon Pickett" <simon.pickett at bto.org> > Sent: Thursday, February 19, 2009 10:50 AM > Subject: RE: [R] type III effect from glm() > > >> Hi Simon: John Fox can say a lot more about below but I've been >> reading his book over and over recently and one thing he constantly >> stresses is marginality which he defines as always including the >> lower order term if you include it in a higher order term. So, I >> think below is problematic because you are including an interaction >> that includes the main effect but not including the main effect. This >> definitely causes problems when trying to interpret >> the anova table or the Anova table. That's as much as I can say. I >> highly recommed his text for this sort of thing and hopefully he will >> respond. >> >> Oh, my point is that if you want to check the effect of yrs, then I >> think you have to take it out of model 2 totally in order to >> interpret the anova ( or the Anova ) table. >> >> On Thu, Feb 19, 2009 at 5:38 AM, Simon Pickett wrote: >> >>> Hi all, >>> >>> This could be naivety/stupidity on my part rather than a problem >>> with model output, but here goes.... >>> >>> I have fitted a fairly simple model >>> >>> >>> m1<-glm(count~siteall+yrs+yrs:district,family=quasipoisson,weights=weight,data=m[x[[i]],]) >>> >>> I want to know if yrs (a continuous variable) has a significant >>> unique effect in the model, so I fit a simplified model with the >>> main effect ommitted... >>> >>> >>> >>> m2<-glm(count~siteall+yrs:district,family=quasipoisson,weights=weight,data=m[x[[i]],]) >>> >>> then compare models using anova() >>> anova(m1,m1b,test="F") >>> >>> Analysis of Deviance Table >>> >>> Model 1: count ~ siteall + yrs + yrs:district >>> Model 2: count ~ siteall + yrs:district >>> Resid. Df Resid. Dev Df Deviance F Pr(>F) >>> 1 1936 75913 2 1936 75913 >>> 0 0 >>>> >>> >>> The d.f.'s are exactly the same, is this right? Can I only test the >>> significance of a main effect when it is not in an interaction? >>> Thanks in advance, >>> >>> Simon. >>> >>> >>> >>> >>> >>> >>> Dr. Simon Pickett >>> Research Ecologist >>> Land Use Department >>> Terrestrial Unit >>> British Trust for Ornithology >>> The Nunnery >>> Thetford >>> Norfolk >>> IP242PU >>> 01842750050 >>> >>> [[alternative HTML version deleted]] >>> >>> ______________________________________________ >>> 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. >>
Hi Simon,>> I want to know if yrs (a continuous variable) has a significant unique >> effect in the model, >> so I fit a simplified model with the main effect ommitted...[A different approach...] This is not really a sensible question until you have established that there is no significant interaction between "yrs" and "district." If this interaction is significant then, ipso facto, the effect of "yrs" is not unique but depends on "district." So establish that first. There is a good section on marginality in MASS (Venables & Ripley) and, as Mark has mentioned, in Prof Fox's texts. From what I can remember, some of these tests are reparametrized behind the scenes to enforce the marginality constraint. Regards, Mark. Simon Pickett-4 wrote:> > Hi all, > > This could be naivety/stupidity on my part rather than a problem with > model output, but here goes.... > > I have fitted a fairly simple model > > m1<-glm(count~siteall+yrs+yrs:district,family=quasipoisson,weights=weight,data=m[x[[i]],]) > > I want to know if yrs (a continuous variable) has a significant unique > effect in the model, so I fit a simplified model with the main effect > ommitted... > > m2<-glm(count~siteall+yrs:district,family=quasipoisson,weights=weight,data=m[x[[i]],]) > > then compare models using anova() > anova(m1,m1b,test="F") > > Analysis of Deviance Table > > Model 1: count ~ siteall + yrs + yrs:district > Model 2: count ~ siteall + yrs:district > Resid. Df Resid. Dev Df Deviance F Pr(>F) > 1 1936 75913 > 2 1936 75913 0 0 >> > > The d.f.'s are exactly the same, is this right? Can I only test the > significance of a main effect when it is not in an interaction? > > Thanks in advance, > > Simon. > > > > > > > Dr. Simon Pickett > Research Ecologist > Land Use Department > Terrestrial Unit > British Trust for Ornithology > The Nunnery > Thetford > Norfolk > IP242PU > 01842750050 > > [[alternative HTML version deleted]] > > ______________________________________________ > 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/type-III-effect-from-glm%28%29-tp22097773p22099331.html Sent from the R help mailing list archive at Nabble.com.