On Sun, 24 Nov 2002, Andrew Criswell wrote:
> Hello:
>
> I am trying to understand why glm() does not replicate the results in
> Dobson, "Introduction to Generalized Linear Models," pp. 17-20.
>
> I set up the following model. The variable CONDT is assumed as Poisson and
> the objective is to estimate the expected value.
>
> The data (chronic medical conditions among women in Australia) is as
> follows:
>
> CONDT <- c(0, 1, 1, 0, 2, 3, 0, 1, 1, 1, 1, 2, 0, 1, 3, 0, 1,
> 2, 1, 3, 3, 4, 1, 3, 2, 0, 2, 0, 3, 0, 0, 1, 1,
1,
> 1, 0, 0, 2, 2, 0, 1, 2, 0, 0, 1, 1, 1, 0, 2)
>
> The Poisson model estimating the mean:
>
> summary(fm1 <- glm(CONDT ~ 1, family = poisson(link =
'identity')))
>
> The estimated coefficient obtained matches the results in Dobson exactly.
> But I am unable to replicate the value for the log-likelihood using the
> results on deviance or null deviance (the same here) from R. If you plug
> into the log-likelihood function the coefficient value and the values for
> CONDT, you get log(L) = - 68.3868 This is what is reported in Dobson. That
> number I cannot seem to gleam from R.
If you want loglikelihoods you use the logLik() function.
R> logLik(fm1)
`log Lik.' -68.38682 (df=1)
> Another question: For a Poisson model like this, what is the difference
> between the fm1$residuals and residuals(fm1)? I expected, when taking the
> ratio of one to the other, to get a vector of constants. Not so. The
values
> for fm1$residuals are the difference between the actual and fitted values,
> but what about residuals(fm1)? They are not standardized residuals for a
> Poisson model such as this.
You shouldn't use fm1$residuals --- the S language doesn't prevent you
from accessing internal fields of objects directly, but it's still a bad
idea, especially if you don't know what they mean.
The residuals() function for a glm provides five different sorts of
residuals according to the "type" argument (as described in
help(residuals.glm)). The values for fm1$residuals are in fact *not* the
difference between the actual and fitted data (in this model they are
equal purely by coincidence).
-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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._