so I am currently running logistic regression and am attempting to extract summary information for individual predictors without including the intercept as follows:
zscores1<-summary(step1)$coefficients[-1,"z value"]
> zscores1
i3 i2 i1
0.5011802 2.7834229 2.0239975
Step1 is the model of interest here to provide context. I ultimately want to extract just the included predictors:
allpredictorsincld<-rownames(summary(step1)$coefficients[-1,])
> allpredictorsincld
[1] "i3" "i2" "i1"
The issue I am having is if I only use one predictor I only get the information for that predictor, but the item number is dropped as follows:
> zscores1<-summary(step1)$coefficients[-1,"z value"]
> zscores1
[1] 5.644939
Where item 1 (i1) is the only item included as a predictor. How can I make it so R gives me the value in addition to the item number? So as to have something like this:
> zscores1
i1
5.644939
Thank you!
Another solution I discovered is converting the results to a data frame, then extracting the row names as follows:
then:
and finally:
Though Mr. Flick's solution is much quicker.