[R] glm predict problem with type = "response"

Anne York york at noaa.gov
Wed Feb 21 23:48:44 CET 2001


The standard errors produced by predict.glm with type = "response" seem
wrong. Here is an example using R 1.2 windows version along with the same
problem in Splus. The standard errors for type = "link" are the same in
both systems. 

R1.2> set.seed(10)

R1.2> ytest <- 100*.95^(0:9) + rnorm(10,sd = 5)

R1.2> ytest
 [1] 103.96964  97.60590  88.43220  85.90504  79.18262  76.05762  68.34566
 [8]  74.24119  66.80257  62.95880

R1.2> foo  <-  glm(ytest~I(0:9),family=quasi(link=log))

R1.2> predict(foo,type="link")
       1        2        3        4        5       
4.620614 4.565770 4.510925 4.456081 4.401236  ...

R1.2> predict(foo,type="link", se = TRUE)
$fit
       1        2        3        4        5
4.620614 4.565770 4.510925 4.456081 4.401236 ...

$se.fit
         1          2          3          4          5 
0.01913357 0.01602018 0.01350398 0.01196775 0.01180063 

$residual.scale
[1] 3.005757

R1.2> predict(foo,type="response", se = TRUE)
$fit
 [1] 101.55641  96.13657  91.00598  86.14920  81.55161 


$se.fit
           1            2            3            4            5 
2.438852e+42 9.041729e+39 4.506688e+37 3.105512e+35 3.085449e+33 

$residual.scale
[1] 3.005757

Comparison with Splus. First import ytest into splus

SPlus> ytest
 [1] 103.96964  97.60590  88.43220  85.90504  79.18262  76.05762  68.34566
 [8]  74.24119  66.80257  62.95880

SPlus>  predict(foo,type="link", se = TRUE)
$fit:
        1       2        3        4        5   
 4.620614 4.56577 4.510925 4.456081 4.401236  ...

$se.fit:
          1          2          3          4          5 
 0.01913357 0.01602018 0.01350398 0.01196775 0.01180063  ...

$residual.scale:
[1] 3.005757



SPlus> foo  <-  glm(ytest~I(0:9),family=quasi(link=log))
SPlus>  predict(foo,type="response", se = TRUE)
$fit:
        1        2        3       4        5 
 101.5564 96.13657 91.00598 86.1492 81.55161 ...

$se.fit:
        1        2        3        4       5 
 1.943136 1.540126 1.228943 1.031012 0.96236 ...
 
$residual.scale:
[1] 3.005757

$df:
[1] 8

SPlus>  predict(foo,type="link", se = TRUE)
$fit:
        1       2        3        4        5   
 4.620614 4.56577 4.510925 4.456081 4.401236  ...

$se.fit:
          1          2          3          4          5 
 0.01913357 0.01602018 0.01350398 0.01196775 0.01180063  ...

$residual.scale:
[1] 3.005757







~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Anne E. York
National Marine Mammal Laboratory
Seattle WA 98115-0070  USA
e-mail: anne.york at noaa.gov
Voice: +1 206-526-4039
Fax: +1 206-526-6615
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list