Search code examples
rcbind

benferroni adjusted p-value - how to bind it without exponentiating just like OR and CI?


I am trying to get my benferroni adjusted p value to my cbinded list of OR and CI and face two issues:

  1. when I extract p-values from my logistic regression I get the intercept as well, however I proceed with transformation regardless of that. I do not want the intercept when I extract the p-value, how do I do this?

I have tried this:

#get logistic regression
d_ch <- glm(diabetes_type_one ~ chills, data = test, family = binomial) 
# extract the p-values for adjusting 
d_ch_pval <- summary(d_ch)$coefficients[,4]
#apply benferroni 
d_ch_padj <- p.adjust(d_ch_pval, method = "bonferroni")

#I am attaching to the list ordinal ratio and confidence intervals 
exp(cbind(OR = coef(d_ch), confint(d_ch), pvalues = d_ch_padj)) 
  1. As you my observe my pvalue is also exponentiated which I do not want this to happen. I want to keep my benferroni adjusted pvalue intact of exponentiation but want to add it alongside the OR and CI.

this is a fake dataset:

structure(list(diabetes_type_one = structure(c(1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L), .Label = c("No", 
"Yes"), class = "factor"), chills = structure(c(1L, 1L, 1L, 2L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 
1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L), .Label = c("No", 
"Yes"), class = "factor")), row.names = c(NA, -50L), class = c("tbl_df", 
"tbl", "data.frame"))

Would you please help?


Solution

  • Part 1:

    If you want to remove the intercept from the model, do:

    glm(diabetes_type_one ~ chills - 1, data = test, family = binomial)
    

    If you want to remove the intercept from d_ch_pval (model includes intercept), do:

    d_ch_pval[-1] # Intercept is always the first row in the summary if the model includes intercept
    

    Part 2:

    You are exponentiating the p-value along with CI. Instead do this:

    df <- exp(cbind(OR = coef(d_ch), confint(d_ch))) # exp(other columns)
    df <- cbind(df, data.frame(pvalues = d_ch_padj)) # cbind p-values after exp of other columns
    df