Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extract only coefficients whose p values are significant from a logistic model

I have run a logistic regression, the summary of which I name. "score" Accordingly, summary(score) gives me the following

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.3616  -0.9806  -0.7876   1.2563   1.9246  

                       Estimate Std. Error    z value    Pr(>|z|)
(Intercept)        -4.188286233 1.94605597 -2.1521921 0.031382230 *
Overall            -0.013407201 0.06158168 -0.2177141 0.827651866
RTN                -0.052959314 0.05015013 -1.0560154 0.290961160
Recorded            0.162863294 0.07290053  2.2340482 0.025479900 *
PV                 -0.086743611 0.02950620 -2.9398438 0.003283778 **
Expire             -0.035046322 0.04577103 -0.7656878 0.443862068
Trial               0.007220173 0.03294419  0.2191637 0.826522498
Fitness             0.056135418 0.03114687  1.8022810 0.071501212 .

---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 757.25  on 572  degrees of freedom
Residual deviance: 725.66  on 565  degrees of freedom
AIC: 741.66

Number of Fisher Scoring iterations: 4

What I am hoping to achieve is to get variables names and coefficients of those variables which have a *, **, or *** next to their Pr(>|z|) value. In other words, I want the aforementioned variables and coefficients with a Pr(>|z|) < .05.

Ideally, I'd like to get them in a data frame. Unfortunately, the following code I've tried does not work.

variable_try <-
  summary(score)$coefficients[if(summary(score)$coefficients[, 4] <= .05, 
                                 summary(score)$coefficients[, 1]),]

Error: unexpected ',' in "variable_try <-
summary(score)$coefficients[if(summary(score)$coefficients[,4] < .05,"
like image 826
Jonathan Charlton Avatar asked Apr 17 '13 21:04

Jonathan Charlton


People also ask

Is the p-value for the dummy variables significant in a logistic regression?

I am doing a logistic regression for a friend. The model that she wants to work on is with a binary outcome and a predictor with more than 2 categories. When I ran the regression, the p-value for the whole model is significant, but the individual dummy variables p-values are not significant.

How do coefficients and p-values work together in regression analysis?

P-values and coefficients in regression analysis work together to tell you which relationships in your model are statistically significant and the nature of those relationships. The coefficients describe the mathematical relationship between each independent variable and the dependent variable.

What does the coefficient value signify in a model?

The coefficient value signifies how much the mean of the dependent variable changes given a one-unit shift in the independent variable while holding other variables in the model constant. This property of holding the other variables constant is crucial because it allows you to assess the effect of each variable in isolation from the others.

What does the t-test for the coefficient p-value tell you?

In this case, you’re seeing whether the 2nd model accounts for significantly more variance than the first model. The t-test for the coefficient p-value assesses whether the coefficient is significantly different than zero (no effect).


1 Answers

What about this:

data.frame(summary(score)$coef[summary(score)$coef[,4] <= .05, 4])
like image 119
tcash21 Avatar answered Oct 15 '22 03:10

tcash21