Hello useRs, Pls help with removing a single interaction term from a formula: summary( glm.turn.2 <- glm(cbind(turn.cnt,tot.cnt-turn.cnt)~sn+poly(relAge,2,raw=T)+termfac+rate:termfac,data=fix, family="quasibinomial") ) Gives Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -7.028467 0.106002 -66.305 < 2e-16 *** snFeb 0.156963 0.023660 6.634 3.27e-11 *** snMar 0.317540 0.022883 13.876 < 2e-16 *** snApr 0.526084 0.022004 23.908 < 2e-16 *** snMay 1.026710 0.020347 50.460 < 2e-16 *** snJun 0.841044 0.021318 39.452 < 2e-16 *** snJul 0.668790 0.022530 29.685 < 2e-16 *** snAug 0.544267 0.022580 24.104 < 2e-16 *** snSep 0.389667 0.023363 16.679 < 2e-16 *** snOct 0.351294 0.023586 14.894 < 2e-16 *** snNov 0.391464 0.024057 16.272 < 2e-16 *** snDec -0.373369 0.028755 -12.985 < 2e-16 *** poly(relAge, 2, raw = T)1 2.952887 0.067455 43.776 < 2e-16 *** poly(relAge, 2, raw = T)2 -1.783907 0.064074 -27.841 < 2e-16 *** termfac2 -0.681719 0.128571 -5.302 1.14e-07 *** termfac3 -1.032416 0.146396 -7.052 1.77e-12 *** termfac4 -1.267011 0.108940 -11.630 < 2e-16 *** termfac5 -1.009922 0.213129 -4.739 2.15e-06 *** termfac6 3.300301 0.203465 16.221 < 2e-16 *** termfac1:rate 0.012274 0.019895 0.617 0.537 termfac2:rate 0.121724 0.013472 9.036 < 2e-16 *** termfac3:rate 0.175232 0.018987 9.229 < 2e-16 *** termfac4:rate 0.197726 0.005787 34.164 < 2e-16 *** termfac5:rate 0.145622 0.027295 5.335 9.56e-08 *** termfac6:rate -0.362379 0.025261 -14.345 < 2e-16 *** and I would like to remove the termfac1:rate interaction. Is there a way to do that? Thank you Stephen Bond [[alternative HTML version deleted]]
On 11.08.2011 17:27, Bond, Stephen wrote:> Hello useRs, > > Pls help with removing a single interaction term from a formula: > > summary( > glm.turn.2<- glm(cbind(turn.cnt,tot.cnt-turn.cnt)~sn+poly(relAge,2,raw=T)+termfac+rate:termfac,data=fix, > family="quasibinomial") > ) > > Gives > > Coefficients: > Estimate Std. Error t value Pr(>|t|) > (Intercept) -7.028467 0.106002 -66.305< 2e-16 *** > snFeb 0.156963 0.023660 6.634 3.27e-11 *** > snMar 0.317540 0.022883 13.876< 2e-16 *** > snApr 0.526084 0.022004 23.908< 2e-16 *** > snMay 1.026710 0.020347 50.460< 2e-16 *** > snJun 0.841044 0.021318 39.452< 2e-16 *** > snJul 0.668790 0.022530 29.685< 2e-16 *** > snAug 0.544267 0.022580 24.104< 2e-16 *** > snSep 0.389667 0.023363 16.679< 2e-16 *** > snOct 0.351294 0.023586 14.894< 2e-16 *** > snNov 0.391464 0.024057 16.272< 2e-16 *** > snDec -0.373369 0.028755 -12.985< 2e-16 *** > poly(relAge, 2, raw = T)1 2.952887 0.067455 43.776< 2e-16 *** > poly(relAge, 2, raw = T)2 -1.783907 0.064074 -27.841< 2e-16 *** > termfac2 -0.681719 0.128571 -5.302 1.14e-07 *** > termfac3 -1.032416 0.146396 -7.052 1.77e-12 *** > termfac4 -1.267011 0.108940 -11.630< 2e-16 *** > termfac5 -1.009922 0.213129 -4.739 2.15e-06 *** > termfac6 3.300301 0.203465 16.221< 2e-16 *** > termfac1:rate 0.012274 0.019895 0.617 0.537 > termfac2:rate 0.121724 0.013472 9.036< 2e-16 *** > termfac3:rate 0.175232 0.018987 9.229< 2e-16 *** > termfac4:rate 0.197726 0.005787 34.164< 2e-16 *** > termfac5:rate 0.145622 0.027295 5.335 9.56e-08 *** > termfac6:rate -0.362379 0.025261 -14.345< 2e-16 *** > > and I would like to remove the termfac1:rate interaction. Is there a way to do that? > Thank youAnd what do you want to do with the observations with termfac=1 then? Ignore? Also move to the Intercept? Uwe Ligges> > Stephen Bond > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Using glm.fit I can remove the unwanted column from model.matrix(glm.turn.2) manually and then call glm.fit directly. Q: how can I stuff the output from glm.fit into a regular glm object, so I can use prediction functions, etc.?? the help does not describe how to use output from glm.fit in the way a glm model can be used. Thanks everybody. Stephen -----Original Message----- From: Uwe Ligges [mailto:ligges at statistik.tu-dortmund.de] Sent: Thursday, August 11, 2011 11:40 AM To: Bond, Stephen Cc: r-help at r-project.org Subject: Re: [R] model formula On 11.08.2011 17:27, Bond, Stephen wrote:> Hello useRs, > > Pls help with removing a single interaction term from a formula: > > summary( > glm.turn.2<- glm(cbind(turn.cnt,tot.cnt-turn.cnt)~sn+poly(relAge,2,raw=T)+termfac+rate:termfac,data=fix, > family="quasibinomial") > ) > > Gives > > Coefficients: > Estimate Std. Error t value Pr(>|t|) > (Intercept) -7.028467 0.106002 -66.305< 2e-16 *** > snFeb 0.156963 0.023660 6.634 3.27e-11 *** > snMar 0.317540 0.022883 13.876< 2e-16 *** > snApr 0.526084 0.022004 23.908< 2e-16 *** > snMay 1.026710 0.020347 50.460< 2e-16 *** > snJun 0.841044 0.021318 39.452< 2e-16 *** > snJul 0.668790 0.022530 29.685< 2e-16 *** > snAug 0.544267 0.022580 24.104< 2e-16 *** > snSep 0.389667 0.023363 16.679< 2e-16 *** > snOct 0.351294 0.023586 14.894< 2e-16 *** > snNov 0.391464 0.024057 16.272< 2e-16 *** > snDec -0.373369 0.028755 -12.985< 2e-16 *** > poly(relAge, 2, raw = T)1 2.952887 0.067455 43.776< 2e-16 *** > poly(relAge, 2, raw = T)2 -1.783907 0.064074 -27.841< 2e-16 *** > termfac2 -0.681719 0.128571 -5.302 1.14e-07 *** > termfac3 -1.032416 0.146396 -7.052 1.77e-12 *** > termfac4 -1.267011 0.108940 -11.630< 2e-16 *** > termfac5 -1.009922 0.213129 -4.739 2.15e-06 *** > termfac6 3.300301 0.203465 16.221< 2e-16 *** > termfac1:rate 0.012274 0.019895 0.617 0.537 > termfac2:rate 0.121724 0.013472 9.036< 2e-16 *** > termfac3:rate 0.175232 0.018987 9.229< 2e-16 *** > termfac4:rate 0.197726 0.005787 34.164< 2e-16 *** > termfac5:rate 0.145622 0.027295 5.335 9.56e-08 *** > termfac6:rate -0.362379 0.025261 -14.345< 2e-16 *** > > and I would like to remove the termfac1:rate interaction. Is there a way to do that? > Thank youAnd what do you want to do with the observations with termfac=1 then? Ignore? Also move to the Intercept? Uwe Ligges> > Stephen Bond > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Hi Stephen, have a look at ?update.formula glm.turn.3<-update(glm.turn.2,.~.-termfac1:rate) should do the trick. hth. Am 11.08.2011 17:27, schrieb Bond, Stephen:> Hello useRs, > > Pls help with removing a single interaction term from a formula: > > summary( > glm.turn.2 <- glm(cbind(turn.cnt,tot.cnt-turn.cnt)~sn+poly(relAge,2,raw=T)+termfac+rate:termfac,data=fix, > family="quasibinomial") > ) > > Gives > > Coefficients: > Estimate Std. Error t value Pr(>|t|) > (Intercept) -7.028467 0.106002 -66.305 < 2e-16 *** > snFeb 0.156963 0.023660 6.634 3.27e-11 *** > snMar 0.317540 0.022883 13.876 < 2e-16 *** > snApr 0.526084 0.022004 23.908 < 2e-16 *** > snMay 1.026710 0.020347 50.460 < 2e-16 *** > snJun 0.841044 0.021318 39.452 < 2e-16 *** > snJul 0.668790 0.022530 29.685 < 2e-16 *** > snAug 0.544267 0.022580 24.104 < 2e-16 *** > snSep 0.389667 0.023363 16.679 < 2e-16 *** > snOct 0.351294 0.023586 14.894 < 2e-16 *** > snNov 0.391464 0.024057 16.272 < 2e-16 *** > snDec -0.373369 0.028755 -12.985 < 2e-16 *** > poly(relAge, 2, raw = T)1 2.952887 0.067455 43.776 < 2e-16 *** > poly(relAge, 2, raw = T)2 -1.783907 0.064074 -27.841 < 2e-16 *** > termfac2 -0.681719 0.128571 -5.302 1.14e-07 *** > termfac3 -1.032416 0.146396 -7.052 1.77e-12 *** > termfac4 -1.267011 0.108940 -11.630 < 2e-16 *** > termfac5 -1.009922 0.213129 -4.739 2.15e-06 *** > termfac6 3.300301 0.203465 16.221 < 2e-16 *** > termfac1:rate 0.012274 0.019895 0.617 0.537 > termfac2:rate 0.121724 0.013472 9.036 < 2e-16 *** > termfac3:rate 0.175232 0.018987 9.229 < 2e-16 *** > termfac4:rate 0.197726 0.005787 34.164 < 2e-16 *** > termfac5:rate 0.145622 0.027295 5.335 9.56e-08 *** > termfac6:rate -0.362379 0.025261 -14.345 < 2e-16 *** > > and I would like to remove the termfac1:rate interaction. Is there a way to do that? > Thank you > > Stephen Bond > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Eik Vettorazzi Department of Medical Biometry and Epidemiology University Medical Center Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790
On 11.08.2011 18:32, Eik Vettorazzi wrote:> Hi Stephen, > have a look at ?update.formula > > glm.turn.3<-update(glm.turn.2,.~.-termfac1:rate)No, "1" is a level of the variable "termfac" here. Uwe Ligges> > should do the trick. > hth. > > Am 11.08.2011 17:27, schrieb Bond, Stephen: >> Hello useRs, >> >> Pls help with removing a single interaction term from a formula: >> >> summary( >> glm.turn.2<- glm(cbind(turn.cnt,tot.cnt-turn.cnt)~sn+poly(relAge,2,raw=T)+termfac+rate:termfac,data=fix, >> family="quasibinomial") >> ) >> >> Gives >> >> Coefficients: >> Estimate Std. Error t value Pr(>|t|) >> (Intercept) -7.028467 0.106002 -66.305< 2e-16 *** >> snFeb 0.156963 0.023660 6.634 3.27e-11 *** >> snMar 0.317540 0.022883 13.876< 2e-16 *** >> snApr 0.526084 0.022004 23.908< 2e-16 *** >> snMay 1.026710 0.020347 50.460< 2e-16 *** >> snJun 0.841044 0.021318 39.452< 2e-16 *** >> snJul 0.668790 0.022530 29.685< 2e-16 *** >> snAug 0.544267 0.022580 24.104< 2e-16 *** >> snSep 0.389667 0.023363 16.679< 2e-16 *** >> snOct 0.351294 0.023586 14.894< 2e-16 *** >> snNov 0.391464 0.024057 16.272< 2e-16 *** >> snDec -0.373369 0.028755 -12.985< 2e-16 *** >> poly(relAge, 2, raw = T)1 2.952887 0.067455 43.776< 2e-16 *** >> poly(relAge, 2, raw = T)2 -1.783907 0.064074 -27.841< 2e-16 *** >> termfac2 -0.681719 0.128571 -5.302 1.14e-07 *** >> termfac3 -1.032416 0.146396 -7.052 1.77e-12 *** >> termfac4 -1.267011 0.108940 -11.630< 2e-16 *** >> termfac5 -1.009922 0.213129 -4.739 2.15e-06 *** >> termfac6 3.300301 0.203465 16.221< 2e-16 *** >> termfac1:rate 0.012274 0.019895 0.617 0.537 >> termfac2:rate 0.121724 0.013472 9.036< 2e-16 *** >> termfac3:rate 0.175232 0.018987 9.229< 2e-16 *** >> termfac4:rate 0.197726 0.005787 34.164< 2e-16 *** >> termfac5:rate 0.145622 0.027295 5.335 9.56e-08 *** >> termfac6:rate -0.362379 0.025261 -14.345< 2e-16 *** >> >> and I would like to remove the termfac1:rate interaction. Is there a way to do that? >> Thank you >> >> Stephen Bond >> >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at r-project.org mailing list >> stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >
Am 11.08.2011 17:39, schrieb Uwe Ligges:> > > On 11.08.2011 17:27, Bond, Stephen wrote: >> Hello useRs, >> >> Pls help with removing a single interaction term from a formula: >> >> summary( >> glm.turn.2<- >> glm(cbind(turn.cnt,tot.cnt-turn.cnt)~sn+poly(relAge,2,raw=T)+termfac+rate:termfac,data=fix, >> >> family="quasibinomial") >> ) >> >> Gives >> >> Coefficients: >> Estimate Std. Error t value Pr(>|t|) >> (Intercept) -7.028467 0.106002 -66.305< 2e-16 *** >> snFeb 0.156963 0.023660 6.634 3.27e-11 *** >> snMar 0.317540 0.022883 13.876< 2e-16 *** >> snApr 0.526084 0.022004 23.908< 2e-16 *** >> snMay 1.026710 0.020347 50.460< 2e-16 *** >> snJun 0.841044 0.021318 39.452< 2e-16 *** >> snJul 0.668790 0.022530 29.685< 2e-16 *** >> snAug 0.544267 0.022580 24.104< 2e-16 *** >> snSep 0.389667 0.023363 16.679< 2e-16 *** >> snOct 0.351294 0.023586 14.894< 2e-16 *** >> snNov 0.391464 0.024057 16.272< 2e-16 *** >> snDec -0.373369 0.028755 -12.985< 2e-16 *** >> poly(relAge, 2, raw = T)1 2.952887 0.067455 43.776< 2e-16 *** >> poly(relAge, 2, raw = T)2 -1.783907 0.064074 -27.841< 2e-16 *** >> termfac2 -0.681719 0.128571 -5.302 1.14e-07 *** >> termfac3 -1.032416 0.146396 -7.052 1.77e-12 *** >> termfac4 -1.267011 0.108940 -11.630< 2e-16 *** >> termfac5 -1.009922 0.213129 -4.739 2.15e-06 *** >> termfac6 3.300301 0.203465 16.221< 2e-16 *** >> termfac1:rate 0.012274 0.019895 0.617 0.537 >> termfac2:rate 0.121724 0.013472 9.036< 2e-16 *** >> termfac3:rate 0.175232 0.018987 9.229< 2e-16 *** >> termfac4:rate 0.197726 0.005787 34.164< 2e-16 *** >> termfac5:rate 0.145622 0.027295 5.335 9.56e-08 *** >> termfac6:rate -0.362379 0.025261 -14.345< 2e-16 *** >> >> and I would like to remove the termfac1:rate interaction. Is there a >> way to do that? >> Thank you > > And what do you want to do with the observations with termfac=1 then? > Ignore? Also move to the Intercept?Actually they are already in the Intercept because of the treatment contrasts. The crucial part in the glm formula above is termfac+rate:termfac which specifies intercepts deviating from termfac1 level and slopes for every level of termfac. A dummy coding for different slopes should work, since the slopes are independently modelled and tested against 0.> > Uwe Ligges > > > >> >> Stephen Bond >> >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at r-project.org mailing list >> stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > > ______________________________________________ > R-help at r-project.org mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Eik Vettorazzi Institut f?r Medizinische Biometrie und Epidemiologie Universit?tsklinikum Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790