rglmadjustment

Adjusted odds ratios using the or_glm() function?


I'm using or_glm() to calculate odds ratios, using this reproducible example:

    library(oddsratio)
    or_glm(data = data_glm, 
           model = glm(admit ~ gre + gpa + rank, 
                       data = data_glm, 
                       family = "binomial"), 
           incr = list(gre = 1, gpa = 1, rank = 1))

I have two questions:

  1. How can I also extract a p-value for each odds ratio?
  2. How can I get an odds ratio for "gre" adjusted for for "gpa" and "rank"?

Solution

  • I would try as follows:

    library(oddsratio)
    library(mfx)
    
    model = glm(admit ~ gre + gpa + rank, 
                       data = data_glm, 
                       family = "binomial")
    logitor(admit ~ gre + gpa + rank,data=data_glm)
    Call:
    logitor(formula = admit ~ gre + gpa + rank, data = data_glm)
    
    Odds Ratio:
          OddsRatio Std. Err.       z     P>|z|    
    gre   1.0022670 0.0010965  2.0699 0.0384651 *  
    gpa   2.2345448 0.7414651  2.4231 0.0153879 *  
    rank2 0.5089310 0.1610714 -2.1342 0.0328288 *  
    rank3 0.2617923 0.0903986 -3.8812 0.0001039 ***
    rank4 0.2119375 0.0885542 -3.7131 0.0002047 ***
    ---
    Signif. codes:  
    0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
    
    exp(coef(model))
    (Intercept)         gre         gpa       rank2 
      0.0185001   1.0022670   2.2345448   0.5089310 
          rank3       rank4 
      0.2617923   0.2119375 
    
    exp(cbind(OR=coef(model), confint(model)))
    Waiting for profiling to be done...
                       OR       2.5 %    97.5 %
    (Intercept) 0.0185001 0.001889165 0.1665354
    gre         1.0022670 1.000137602 1.0044457
    gpa         2.2345448 1.173858216 4.3238349
    rank2       0.5089310 0.272289674 0.9448343
    rank3       0.2617923 0.131641717 0.5115181
    rank4       0.2119375 0.090715546 0.4706961