Extract pvalue from glm

前端 未结 4 558
说谎
说谎 2021-02-02 07:05

I\'m running many regressions and am only interested in the effect on the coefficient and p-value of one particular variable. So, in my script, I\'d like to be able to just extr

4条回答
  •  借酒劲吻你
    2021-02-02 07:20

    I've used this technique in the past to pull out predictor data from summary or from a fitted model object:

    coef(summary(m))[grepl("var_i_want$",row.names(coef(summary(m)))), 4]
    

    which lets me easily edit which variable I want to get data on.

    Or as pointed out be @Ben, use match or %in%, somewhat cleaner than grepl:

    coef(summary(m))[row.names(coef(summary(m))) %in% "var_i_want" , 4]
    

提交回复
热议问题