当前位置: 动力学知识库 > 问答 > 编程问答 >

statistics - How to calculate R logistic regression standard error values manually?

问题描述:

This question already has an answer here:

  • Extract standard errors from glm

    3 answers

网友答案:

You can calculate this as the square root of the diagonal elements of the unscaled covariance matrix output by summary(model)

sqrt(diag(summary(model)$cov.unscaled)*summary(model)$dispersion)
# (Intercept)           x 
#   2.0600893   0.4000937

For your model, the dispersion parameter is 1 so the last term (summary(model)$dispersion) could be ignored if you want.

To get this unscaled covariance matrix, you do

fittedVals = model$fitted.values
W = diag(fittedVals*(1 - fittedVals))
solve(t(X)%*%W%*%X)
#             (Intercept)          x
# (Intercept)   4.2439753 -0.7506158
# x            -0.7506158  0.1600754
分享给朋友:
您可能感兴趣的文章:
随机阅读: