confint for glm (general linear model)

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

confint for glm (general linear model)

casperyc
This post was updated on .
Hi all,

I have been looking at your replys.

Then I noticed that actually, 'confint.default' is what I want for the CI
since I have not studied profile confidence interval yet.

As someone pointed out that confint.default uses t-distribution,
I dont know why I still cant get (verify) the confidence interval myself
using the formular:

estimator +/- critical value * standard deviation

for a particular general linear model, I have


=================================

              Estimate Std. Error z value Pr(>|z|)
(Intercept)      2.168      0.114  19.020    0.000
Rtreatplacebo   -0.283      0.121  -2.332    0.020
BlockerYes      -0.378      0.146  -2.584    0.010
SiteInferior     0.550      0.141   3.911    0.000
SiteOther       -0.152      0.155  -0.983    0.326  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 50.921  on 23  degrees of freedom
Residual deviance: 15.855  on 19  degrees of freedom
AIC: 121.86


and

> round(confint.default(hglm.final),3)
               2.5 % 97.5 %
(Intercept)    1.944  2.391
Rtreatplacebo -0.520 -0.045
BlockerYes    -0.666 -0.091
SiteInferior   0.275  0.826
SiteOther     -0.456  0.151

=================================

I have tried to use ( for 'Rtreatplacebo')

-0.283+c(-1,1)*qt(0.975,df=19)* 0.121
[1] -0.53625591 -0.02974409

it does not give me what I want as in confint.default(hglm.final), it's
Rtreatplacebo -0.520 -0.045


Thanks.

casper
######################
PhD candidate in Statistics
Big R Fan
Big LEGO Fan
Big sTaTs Fan
######################
Reply | Threaded
Open this post in threaded view
|

Re: confint for glm (general linear model)

casperyc
does no one know this?
######################
PhD candidate in Statistics
Big R Fan
Big LEGO Fan
Big sTaTs Fan
######################
Reply | Threaded
Open this post in threaded view
|

Re: confint for glm (general linear model)

David Winsemius

On Dec 9, 2009, at 9:21 PM, casperyc wrote:

>
> does no one know this?

Have you read the Posting Guide?

> --
> View this message in context: http://n4.nabble.com/confint-for-glm-general-linear-model-tp954071p956658.html
> Sent from the R help mailing list archive at Nabble.com.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

______________________________________________
[hidden email] mailing list
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: confint for glm (general linear model)

Walmes Zeviani
In reply to this post by casperyc
This functions are different. I advice you study them:

?confint # profile likelihood
?confint.default # t-distribution

Walmes Zeviani - Brazil


casperyc wrote
Hi,

I have a glm gives summary as follows,

               Estimate             Std. Error        z value    Pr(>|z|)
(Intercept) -2.03693352     1.449574526 -1.405194 0.159963578
A            0.01093048       0.006446256  1.695633 0.089955471
N            0.41060119      0.224860819  1.826024 0.067846690
S           -0.20651005      0.067698863 -3.050421 0.002285206

then I use confint(k.glm) to obtain a confidnece interval for the estimates.

> confint(k.glm,level=0.97)
Waiting for profiling to be done...
                   1.5 %      98.5 %
(Intercept) -5.471345995  0.94716503
A           -0.002340863  0.02631582
N           -0.037028592  0.95590178
S           -0.365570347 -0.06573675

while reading the help for 'confint', i found something like confint.glm for general linear model.
I load the MASS package by clicking on the Menu( or otherwise how should I load the package?)

then I still cant use the confint.glm command, what have I dont wrong?


How do I calculate this confidence interval for glm estimate manually??

for A, I use
0.01093048 + c(-1,1) * 0.006446256 * qt(0.985,df=77)
which is a different interval i got from the confint(k.glm,level=0.97) above.

To be short, what's the right command to find the confidence interval for glm estimats?
How do I verify it manully?

Thanks.

casper
==========================================================================
Walmes Marques Zeviani
LEG (Laboratório de Estatística e Geoinformação, 25.450418 S, 49.231759 W)
Departamento de Estatística - Universidade Federal do Paraná
homepage: http://www.leg.ufpr.br/~walmes        twitter: @walmeszeviani
==========================================================================
Reply | Threaded
Open this post in threaded view
|

Re: confint for glm (general linear model)

casperyc
I think the help page are exactly the same...
I just want to verify the confidence interval manually. That's all I want.

Thanks.

casper


brestat wrote
This functions are different. I advice you study them:

?confint # profile likelihood
?confint.default # t-distribution

Walmes Zeviani - Brazil


casperyc wrote
Hi,

I have a glm gives summary as follows,

               Estimate             Std. Error        z value    Pr(>|z|)
(Intercept) -2.03693352     1.449574526 -1.405194 0.159963578
A            0.01093048       0.006446256  1.695633 0.089955471
N            0.41060119      0.224860819  1.826024 0.067846690
S           -0.20651005      0.067698863 -3.050421 0.002285206

then I use confint(k.glm) to obtain a confidnece interval for the estimates.

> confint(k.glm,level=0.97)
Waiting for profiling to be done...
                   1.5 %      98.5 %
(Intercept) -5.471345995  0.94716503
A           -0.002340863  0.02631582
N           -0.037028592  0.95590178
S           -0.365570347 -0.06573675

while reading the help for 'confint', i found something like confint.glm for general linear model.
I load the MASS package by clicking on the Menu( or otherwise how should I load the package?)

then I still cant use the confint.glm command, what have I dont wrong?


How do I calculate this confidence interval for glm estimate manually??

for A, I use
0.01093048 + c(-1,1) * 0.006446256 * qt(0.985,df=77)
which is a different interval i got from the confint(k.glm,level=0.97) above.

To be short, what's the right command to find the confidence interval for glm estimats?
How do I verify it manully?

Thanks.

casper
######################
PhD candidate in Statistics
Big R Fan
Big LEGO Fan
Big sTaTs Fan
######################
Reply | Threaded
Open this post in threaded view
|

Re: confint for glm (general linear model)

David Winsemius

On Dec 9, 2009, at 9:50 PM, casperyc wrote:

>
> I think the help page are exactly the same...

I cannot tell what you maen by this.

> I just want to verify the confidence interval manually. That's all I  
> want.

Then provide some reproducible code and data. ... as the Posting Guide  
explains and provides explicit examples of the manner for most  
effectively presenting data objects.

--
David

>
> Thanks.
>
> casper
>
>
>
> brestat wrote:
>>
>> This functions are different. I advice you study them:
>>
>> ?confint # profile likelihood
>> ?confint.default # t-distribution
>>
>> Walmes Zeviani - Brazil
>>
>>
>>
>> casperyc wrote:
>>>
>>> Hi,
>>>
>>> I have a glm gives summary as follows,
>>>
>>>               Estimate             Std. Error        z value    
>>> Pr(>|z|)
>>> (Intercept) -2.03693352     1.449574526 -1.405194 0.159963578
>>> A            0.01093048       0.006446256  1.695633 0.089955471
>>> N            0.41060119      0.224860819  1.826024 0.067846690
>>> S           -0.20651005      0.067698863 -3.050421 0.002285206
>>>
>>> then I use confint(k.glm) to obtain a confidnece interval for the
>>> estimates.
>>>
>>>> confint(k.glm,level=0.97)
>>> Waiting for profiling to be done...
>>>                   1.5 %      98.5 %
>>> (Intercept) -5.471345995  0.94716503
>>> A           -0.002340863  0.02631582
>>> N           -0.037028592  0.95590178
>>> S           -0.365570347 -0.06573675
>>>
>>> while reading the help for 'confint', i found something like  
>>> confint.glm
>>> for general linear model.
>>> I load the MASS package by clicking on the Menu( or otherwise how  
>>> should
>>> I load the package?)
>>>
>>> then I still cant use the confint.glm command, what have I dont  
>>> wrong?
>>>
>>>
>>> How do I calculate this confidence interval for glm estimate  
>>> manually??
>>>
>>> for A, I use
>>> 0.01093048 + c(-1,1) * 0.006446256 * qt(0.985,df=77)
>>> which is a different interval i got from the  
>>> confint(k.glm,level=0.97)
>>> above.
>>>
>>> To be short, what's the right command to find the confidence  
>>> interval for
>>> glm estimats?
>>> How do I verify it manully?
>>>
>>> Thanks.
>>>
>>> casper
>>>
>>>
>>>
>>
>>
>
> --
> View this message in context: http://n4.nabble.com/confint-for-glm-general-linear-model-tp954071p956671.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> 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.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

______________________________________________
[hidden email] mailing list
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: confint for glm (general linear model)

Peter Ehlers
In reply to this post by casperyc
I suspect that you don't know about 'profile' confidence
intervals. If that's true then I can recommend the
discussion in MASS (the book) in section 8.4.
In a nutshell, I don't think that you want to do
a profile confint calculation manually (unless typing
instructions that use the function profile.glm()
counts as 'manual').

  -Peter Ehlers

casperyc wrote:

> I think the help page are exactly the same...
> I just want to verify the confidence interval manually. That's all I want.
>
> Thanks.
>
> casper
>
>
>
> brestat wrote:
>> This functions are different. I advice you study them:
>>
>> ?confint # profile likelihood
>> ?confint.default # t-distribution
>>
>> Walmes Zeviani - Brazil
>>
>>
>>
>> casperyc wrote:
>>> Hi,
>>>
>>> I have a glm gives summary as follows,
>>>
>>>                Estimate             Std. Error        z value    Pr(>|z|)
>>> (Intercept) -2.03693352     1.449574526 -1.405194 0.159963578
>>> A            0.01093048       0.006446256  1.695633 0.089955471
>>> N            0.41060119      0.224860819  1.826024 0.067846690
>>> S           -0.20651005      0.067698863 -3.050421 0.002285206
>>>
>>> then I use confint(k.glm) to obtain a confidnece interval for the
>>> estimates.
>>>
>>>> confint(k.glm,level=0.97)
>>> Waiting for profiling to be done...
>>>                    1.5 %      98.5 %
>>> (Intercept) -5.471345995  0.94716503
>>> A           -0.002340863  0.02631582
>>> N           -0.037028592  0.95590178
>>> S           -0.365570347 -0.06573675
>>>
>>> while reading the help for 'confint', i found something like confint.glm
>>> for general linear model.
>>> I load the MASS package by clicking on the Menu( or otherwise how should
>>> I load the package?)
>>>
>>> then I still cant use the confint.glm command, what have I dont wrong?
>>>
>>>
>>> How do I calculate this confidence interval for glm estimate manually??
>>>
>>> for A, I use
>>> 0.01093048 + c(-1,1) * 0.006446256 * qt(0.985,df=77)
>>> which is a different interval i got from the confint(k.glm,level=0.97)
>>> above.
>>>
>>> To be short, what's the right command to find the confidence interval for
>>> glm estimats?
>>> How do I verify it manully?
>>>
>>> Thanks.
>>>
>>> casper
>>>
>>>
>>>
>>
>

--
Peter Ehlers
University of Calgary

______________________________________________
[hidden email] mailing list
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: confint for glm (general linear model)

casperyc
for an example,


counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9); treatment <- gl(3,3)
glm.D93 <- glm(counts ~ outcome + treatment, family=poisson())
confint(glm.D93)
confint.default(glm.D93)  # based on asymptotic normality

to verify the confidence interval (confint.default(glm.D93))  for outcome2

-4.542553e-01 + c(-1,1) * 0.2021708 * qt(0.975,df=4)
-1.0155714  0.1070608

does not give me
outcome2    -0.8505027 -0.05800787
as in confint.default(glm.D93)

Thanks
######################
PhD candidate in Statistics
Big R Fan
Big LEGO Fan
Big sTaTs Fan
######################
Reply | Threaded
Open this post in threaded view
|

Re: confint for glm (general linear model)

David Winsemius

On Dec 12, 2009, at 8:19 PM, casperyc wrote:

>
> for an example,
>
>
> counts <- c(18,17,15,20,10,20,25,13,12)
> outcome <- gl(3,1,9); treatment <- gl(3,3)
> glm.D93 <- glm(counts ~ outcome + treatment, family=poisson())
> confint(glm.D93)
> confint.default(glm.D93)  # based on asymptotic normality
>
> to verify the confidence interval (confint.default(glm.D93))  for  
> outcome2
>
> -4.542553e-01 + c(-1,1) * 0.2021708 * qt(0.975,df=4)
> -1.0155714  0.1070608
>
> does not give me
> outcome2    -0.8505027 -0.05800787
> as in confint.default(glm.D93)

But this does (up to rounding anyway):

 > coef(summary(glm.D93))[2,1] + c(-1,1) * coef(summary(glm.D93))
[2,2]*qnorm(0.975)
[1] -0.85050267 -0.05800787

I can understand thinking that the CI's might be t-distributed but the  
usual formulation is that they are normally distributed.

>
--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

______________________________________________
[hidden email] mailing list
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: confint for glm (general linear model)

Peter Dalgaard
David Winsemius wrote:

>
> On Dec 12, 2009, at 8:19 PM, casperyc wrote:
>
>>
>> for an example,
>>
>>
>> counts <- c(18,17,15,20,10,20,25,13,12)
>> outcome <- gl(3,1,9); treatment <- gl(3,3)
>> glm.D93 <- glm(counts ~ outcome + treatment, family=poisson())
>> confint(glm.D93)
>> confint.default(glm.D93)  # based on asymptotic normality
>>
>> to verify the confidence interval (confint.default(glm.D93))  for
>> outcome2
>>
>> -4.542553e-01 + c(-1,1) * 0.2021708 * qt(0.975,df=4)
>> -1.0155714  0.1070608
>>
>> does not give me
>> outcome2    -0.8505027 -0.05800787
>> as in confint.default(glm.D93)
>
> But this does (up to rounding anyway):
>
>  > coef(summary(glm.D93))[2,1] + c(-1,1) *
> coef(summary(glm.D93))[2,2]*qnorm(0.975)
> [1] -0.85050267 -0.05800787
>
> I can understand thinking that the CI's might be t-distributed but the
> usual formulation is that they are normally distributed.
>
>>

Right, and 4 DF is just plain wrong. There is no "estimated variance"
for the Poisson distribution like there is in the Gaussian models. E.g.,
it makes sense to calculate a CI for the true log-mean based on a single
Poisson outcome:

 > x <- 50
 > confint(glm(x~1, family=poisson))
Waiting for profiling to be done...
    2.5 %   97.5 %
3.621423 4.176967


--
    O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
   c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - ([hidden email])              FAX: (+45) 35327907

______________________________________________
[hidden email] mailing list
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: confint for glm (general linear model)

cossincos
In reply to this post by casperyc
it use normal dist. instead of T dist for Z statistic, which usually corresponds to asymptotic normal dist.

> -0.283+c(-1,1)*qnorm(0.975)* 0.121
[1] -0.5201556 -0.0458444