0

I run a linear regression for which I adjust the p-values. When I want to display it using modelsummary() the model displayed does not show me the adjusted p-values. Here is a reproducible example:

library(modelsummary)
library(estimatr)

d<- data.frame(x=c(1,2,31,1,3),y=c(35,6,32,2,2),w=c(15,42,361,1,33),z=c(35,6,32,24,24))

g1<- lm_robust(x~y,d)
g2<- lm_robust(w~z,d)

p <- p.adjust(c(g1$p.value,g2$p.value), method = "fdr")

g1$p.value <- p[1:2]
g2$p.value <- p[3:4]
modelsummary(models=list(g1,g2), statistic = "p.value")

For instance, regression g1 looks like:

print(g1)

             Estimate Std. Error   t value  Pr(>|t|)  CI Lower CI Upper DF
(Intercept) 1.1768425  1.9767101 0.5953541 0.7913711 -5.113931 7.467616  3
y           0.4170882  0.5123141 0.8141258 0.7913711 -1.213324 2.047500  3

But modelsummary() only displays the non-adjusted p-values.

I have been stuck on that problem for quite a while now. First, I thought that this answer would be helpful: How to add a q value (adjusted p-value) to a modelsummary table after pooling the results of a multinomial model over multiple imputed datasets. But they only seem to correct p-values within regressions... I guess the difficulty comes from the fact that I am adjusting p-values across multiple regressions.

Thanks for your help!

ju_pi_car
  • 1
  • 1
  • 1
    I think, after the `tidy` you are no longer dealing with models, but summary tibbles – SmokeyShakers Sep 15 '22 at 18:02
  • Thanks @SmokeyShakers, I think my question was not phrased well. I have reformulated it. The main problem I am facing is about making `modelsummary()` display adjusted p-values. – ju_pi_car Sep 16 '22 at 08:05
  • I don't have time to write a full answer but here's what I would do: (1) export each model to a `modelsummary_list` object by calling `modelsummary(models, output = "modelsummary_list")`, (2) correct the p values as necessary in the resulting objects, (3) feed the objects back to `modelsummary` to produce the final result. You can read more details about `modelsummary_list` objects here: https://vincentarelbundock.github.io/modelsummary/articles/modelsummary.html#adding-new-models-part-i – Vincent Sep 16 '22 at 11:30

0 Answers0