[R] get deviance from glm() for given parameter values
Thomas Lumley
tlumley at u.washington.edu
Thu Feb 28 17:51:09 CET 2002
On Thu, 28 Feb 2002, Emmanuel Paradis wrote:
> Dear all,
>
> I would like to get glm() return its results (at least the deviance) for
> some given parameter values (ie without actually fitting the model). I
> tried to set `maxit = 0' but this does not work, eg:
>
> > glm(y ~ x, start = c(1, 1), maxit = 0)
> Error in glm.control(...) : maximum number of iterations must be > 0
>
>
> Any idea?
>
You can set up the linear predictor as an offset and fit the model that
way. This allows any number of coefficients to be fixed and also makes it
easy to use anova() to compare the model to models with those coefficients
estimated
Eg
data(trees)
m1<-glm(log(Volume)~offset(log(Height))+offset(2*log(Girth)),data=trees)
to fit a model with volume proportional to Height*Girth^2 (ie, fixing two
of the coefficients or
cone<-log(pi/(3*24*24))
m2<-glm(log(Volume)~offset(cone+log(Height))+offset(2*log(Girth))+0,data=trees)
fixing all three of the coefficients at the values for a right circular
cone, and then
m3<-glm(log(Volume)~log(Girth)+log(Height),data=trees)
anova(m2,m1,m3)
-thomas
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list