1

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?

GaB
  • 1,076
  • 2
  • 16
  • 29

1 Answers1

2

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
Naveen Mathew
  • 362
  • 2
  • 14
  • I am trying to get the p-value right at the beggining -without adding your line of code, indeed it is a good solution - is just that I am running 17 models * 9 and that will be a lot of typing. I am trying to save a lot of time. – GaB Sep 15 '20 at 09:18
  • Modularizing the code by defining functions may help. Let's assume you defined a function `get_exp_coefs(formula, test)` which executes `glm(formula = formula, data = test, family = binomial)` and returns `df` as shown above. Let's assume you have the 17 test data sets and 17 formulae in a vector/list. You can use lapply like this: `lapply(1:17, function(i) return(get_exp_coefs(formula_list[[i]], test_data[[i]])))` – Naveen Mathew Sep 16 '20 at 13:20