extract coefficients from glm in R

前端 未结 2 484
独厮守ぢ
独厮守ぢ 2021-02-05 13:23

I have performed a logistic regression with the following result:

ssi.logit.single.age[\"coefficients\"]
# $coefficients
#  (Intercept)          age 
# -3.425062         


        
相关标签:
2条回答
  • 2021-02-05 13:54

    There is an extraction function called coef to get coefficients from models:

    coef(ssi.logit.single.age)["age"]
    
    0 讨论(0)
  • 2021-02-05 13:59

    I've found it, from here

    Look at the data structure produced by summary()

    > names(summary(lm.D9))
      [1] "call"          "terms"         "residuals"     "coefficients"
      [5] "aliased"       "sigma"         "df"            "r.squared"
      [9] "adj.r.squared" "fstatistic"    "cov.unscaled"
    

    Now look at the data structure for the coefficients in the summary:

    > summary(lm.D9)$coefficients
                 Estimate Std. Error   t value     Pr(>|t|)
    (Intercept)    5.032  0.2202177 22.850117 9.547128e-15
    groupTrt      -0.371  0.3114349 -1.191260 2.490232e-01
    
    > class(summary(lm.D9)$coefficients)
    [1] "matrix"
    
    > summary(lm.D9)$coefficients[,3]
    (Intercept)    groupTrt
       22.850117   -1.191260
    
    0 讨论(0)
提交回复
热议问题