0

Statistics and R noob wondering if there is there a way to add p-values from a glm onto the end of the output resulting from the following command:

exp(cbind(OR = coef(mod1), confint(mod1)))

Perhaps something like:

summary(mod1)$coefficients[,4]

I realise that this is somewhat of a 'cosmetic' issue but it would be handy nonetheless.

Thanks

L Tyrone
  • 1,268
  • 3
  • 15
  • 24

1 Answers1

2

You can save the results of summary(mod1), and then access the coefficients table using coefficients.

You can write a function that will do the whole process for you...

OR.summary <- function(x){
 # get the summary
  xs <- summary(x)
 # and the confidence intervals for the coefficients 
  ci = confint(x)
 # the table from the summary object
  coefTable <- coefficients(xs)
 # replace the Standard error / test statistic columns with the CI
  coefTable[,2:3] <- ci
 # rename appropriatly
  colnames(coefTable)[2:3] <- colnames(ci)
# exponentiate the appropriate columns
  coefTable[,1:3] <- exp(coefTable[,1:3])
# return the whole table....
  coefTable

}

A more robust approach would be to use a package like rms....

mnel
  • 113,303
  • 27
  • 265
  • 254