[R] Where is the SD in output of glm with Gaussian distribution

Fox, John j|ox @end|ng |rom mcm@@ter@c@
Mon Dec 9 17:52:48 CET 2019


Dear Bert,

It's perhaps a bit pedantic to point it out, but the dispersion is estimated from the Pearson statistic (sum of squared residuals or weighted squared residuals) not from the residual deviance. You can see this in the code for summary.glm().

Best,
 John

  -----------------------------
  John Fox, Professor Emeritus
  McMaster University
  Hamilton, Ontario, Canada
  Web: http::/socserv.mcmaster.ca/jfox

> On Dec 9, 2019, at 10:45 AM, Bert Gunter <bgunter.4567 using gmail.com> wrote:
> 
> In addition, as John's included output shows, only 1 parameter, the
> intercept, is fit. As he also said, the sd is estimated from the residual
> deviance -- it is not a model parameter.
> 
> Suggest you spend some time with a glm tutorial/text.
> 
> Bert
> 
> On Mon, Dec 9, 2019 at 7:17 AM Marc Girondot via R-help <
> r-help using r-project.org> wrote:
> 
>> Let do a simple glm:
>> 
>>> y=rnorm(100)
>>> gnul <- glm(y ~ 1)
>>> gnul$coefficients
>> (Intercept)
>>   0.1399966
>> 
>> The logLik shows the fit of two parameters (DF=2) (intercept) and sd
>> 
>>> logLik(gnul)
>> 'log Lik.' -138.7902 (df=2)
>> 
>> But where is the sd term in the glm object?
>> 
>> If I do the same with optim, I can have its value
>> 
>>> dnormx <- function(x, data) {1E9*-sum(dnorm(data, mean=x["mean"],
>> sd=x["sd"], log = TRUE))}
>>> parg <- c(mean=0, sd=1)
>>> o0 <- optim(par = parg, fn=dnormx, data=y, method="BFGS")
>>> o0$value/1E9
>> [1] 138.7902
>>> o0$par
>>      mean        sd
>> 
>> 0.1399966 0.9694405
>> 
>> But I would like have the value in the glm.
>> 
>> (and in the meantime, I don't understand why gnul$df.residual returned
>> 99... for me it should be 98=100 - number of observations) -1 (for mean)
>> - 1 (for sd); but it is statistical question... I have asked it in
>> crossvalidated [no answer still] !)
>> 
>> Thanks
>> 
>> Marc
>> 
>> ______________________________________________
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.



More information about the R-help mailing list