gamlss() vs glm() standard errors via summary() vs vcov()

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

gamlss() vs glm() standard errors via summary() vs vcov()

kman-4
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)

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: gamlss() vs glm() standard errors via summary() vs vcov()

Peter Dalgaard-2
> # 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 <[hidden email]> 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)
>
> ______________________________________________
> [hidden email] 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: [hidden email]  Priv: [hidden email]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: gamlss() vs glm() standard errors via summary() vs vcov()

kman-4
Thank you, Peter!

Sincerely,
KeithC.

On Wed, Jul 4, 2018 at 4:11 AM, Peter Dalgaard <[hidden email]> wrote:

>> # 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 <[hidden email]> 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)
>>
>> ______________________________________________
>> [hidden email] 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: [hidden email]  Priv: [hidden email]
>
>
>
>
>
>
>
>
>

______________________________________________
[hidden email] 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.