I am trying to get my benferroni adjusted p value to my cbinded list of OR and CI and face two issues:
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))
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?
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