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
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]