了解glm $ residuals和resid(glm) [英] Understanding glm$residuals and resid(glm)

查看:126
本文介绍了了解glm $ residuals和resid(glm)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您能告诉我 glm $ residuals resid(glm)返回什么,其中glm是拟泊松对象.例如我将如何使用glm $ y和glm $ linear.predictors创建它们.

Can you tell me what is returned by glm$residuals and resid(glm) where glm is a quasipoisson object. e.g. How would I create them using glm$y and glm$linear.predictors.

glm $残余

     n missing  unique    Mean     .05     .10   .25  .50     .75     .90     .95

 37715   10042    2174 -0.2574 -2.7538 -2.2661 -1.4480 -0.4381  0.7542  1.9845  2.7749



lowest : -4.243 -3.552 -3.509 -3.481 -3.464
highest:  8.195  8.319  8.592  9.089  9.416

残基(glm)

        n    missing     unique       Mean        .05        .10        .25
    37715          0       2048 -2.727e-10    -1.0000    -1.0000    -0.6276
      .50        .75        .90        .95
  -0.2080     0.4106     1.1766     1.7333

lowest : -1.0000 -0.8415 -0.8350 -0.8333 -0.8288
highest:  7.2491  7.6110  7.6486  7.9574 10.1932

推荐答案

调用resid(model)将默认为偏差残差,而model $ resid将为您提供工作残差.由于具有链接功能,因此对模型残差没有唯一的定义.存在偏差,工作残差,部分皮尔逊残差和响应残差.因为这些仅依赖于均值结构(而不​​是方差),所以拟泊松和泊松的残差具有相同的形式.您可以查看residuals.glm函数以了解详细信息,但这是一个示例:

Calling resid(model) will default to the deviance residuals, whereas model$resid will give you the working residuals. Because of the link function, there is no single definition of what a model residual is. There are the deviance, working, partial, Pearson, and response residuals. Because these only rely on the mean structure (not the variance), the residuals for the quasipoisson and poisson have the same form. You can take a look at the residuals.glm function for details, but here is 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=quasipoisson())
glm.D93$resid


#working
resid(glm.D93,type="working")
(counts - glm.D93$fitted.values)/exp(glm.D93$linear)

#deviance
resid(glm.D93,type="dev")
fit <- exp(glm.D93$linear)
poisson.dev <- function (y, mu) 
    sqrt(2 * (y * log(ifelse(y == 0, 1, y/mu)) - (y - mu)))
poisson.dev(counts,fit) * ifelse(counts > fit,1,-1)

#response
resid(glm.D93,type="resp")
counts - fit

#pearson
resid(glm.D93,type="pear")
(counts - fit)/sqrt(fit)

这篇关于了解glm $ residuals和resid(glm)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆