Understanding glm$residuals and resid(glm)

后端 未结 2 1490
终归单人心
终归单人心 2020-12-23 08:26

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 gl

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-23 09:09

    I don't know enough about poisson and quasi-poisson distributions to answer your question in the depth asked for (i.e. an exact equation that will transform the variables into the residuals using the model), but if any of the confusion is due to what residual types are being used and why the two commands give a different answer, this could help:

    resid() defaults to a "deviance" type in R. However, glm() assigns different residuals to the $residuals vector.

    If you're using the quasi-poisson family, glm() will assign residuals of the working type, whereas, resid() gives the deviance type as default.

    To try this out, you can use:

    resid(glm,type="working")

    and

    glm$residuals

    and that should give you the same answer (at least, it did on a sample dataset I used).

    According to R, working residuals are: "the residuals in the final iteration of the IWLS fit"

    If you look up the book: "Generalized Linear models and extensions" (by Hardin and Hilbe) on googlebooks, you can access section 4.5 which explains the various types of residuals.

提交回复
热议问题