[R] gamlss() vs glm() standard errors via summary() vs vcov()

Peter Dalgaard pd@|gd @end|ng |rom gm@||@com
Wed Jul 4 12:11:50 CEST 2018


> # Extract SEs via vcov()
> SEvcov1<-exp(coef(fit1)) *sqrt(diag(vcov(fit1)))
> SEvcov2<-exp(coef(fit2))*sqrt(diag(vcov(fit2)))

What makes you think that you need to multiply with exp(coef(....)) here???

-pd

> On 4 Jul 2018, at 11:08 , 1/k^c <kchamberln using gmail.com> wrote:
> 
> Hi R-helpers,
> 
> I was working with some count data using gamlss() and glm(), and
> noticed that the standard errors from the two functions correspond
> when extracting from either the model summary for both functions, or
> using vcov for both functions, but the standard errors between those
> methods do not correspond. I have been lead to believe that in SAS and
> Stata, the SEs do correspond between the different methods. Can anyone
> assist me in understanding what's different between the two types of
> SEs I seem to be encountering when using R with either glm or gamlss?
> I feel like I'm missing something obvious. I have included a small
> reproducible example below.
> 
> library(COUNT) # for myTable()
> library(gamlss)
> len<-50
> seeder<-250
> set.seed(seeder)  # reproducible example
> dat<-rpois(c(1:len), lambda=2)
> myTable(dat)
> fac<-gl(n=2, k=1, length=len, labels = c("control","treat"))
> 
> # Fit gamlss() and glm() models
> fit1<-gamlss(dat~fac, family="PO")
> fit2<-glm(dat~fac, family="poisson")
> 
> # Extract SEs from model summaries
> SESum1<-summary(fit1)[,"Std. Error"]
> SESum2<-coef(summary(fit2))[,"Std. Error"]
> cbind(SESum1, SESum2) # Corresponds
> 
> # Extract SEs via vcov()
> SEvcov1<-exp(coef(fit1)) *sqrt(diag(vcov(fit1)))
> SEvcov2<-exp(coef(fit2))*sqrt(diag(vcov(fit2)))
> cbind(SEvcov1, SEvcov2) # Corresponds
> 
> # Compare between summary() and vcov() extraction. Missmatch.
> cbind(SESum1, SEvcov1)
> 
> ______________________________________________
> 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.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd.mes using cbs.dk  Priv: PDalgd using gmail.com




More information about the R-help mailing list