Home > OS >  Output variables with significant p-values from several multiple regressions in R
Output variables with significant p-values from several multiple regressions in R

Time:07-22

I have a dataframe that looks like the following.

consistent  admire  trust  judge 
3           3       2      4
5           1       3      6
2           4       5      1

I am running the following regressions.

summary(lm(consistent ~ judge   admire, df))
summary(lm(consistent ~ judge   trust, df))

In the actual dataset, I have more than 2 variables, so I am using the following code to run several regressions simultaneously.

variables <- c("admire", "trust")
form <- paste("consistent ~ judge   ",variables,"")
model <- form %>% 
  set_names(variables) %>%
  map(~lm(as.formula(.x), data = df))
map(model, summary)

I would like a list of the variables with significant p-values at p < 0.05. For example, if "admire" was significant and "trust" was not significant, this would be the result:

admire 

I asked a similar question which showed how to do this for simple linear regressions where there is only one variable.

The reason I am asking this question now is that I would also like to be able to do this in instances where there is more than one variable being used in the regression; in the example I've given, the control variable is "judge".

Data:

structure(list(consistent = c(1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 
    1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 
    1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 
    0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 
    1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 
    1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 
    1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 
    1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 
    0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 
    1, 1, 0, 0, 0, 0, 1, 0, 1,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 4, 6, 1, 2, 4, 3, 
    3, 4, 7, 1, 3, 1, 2, 2, 3, 2, 3, 5, 3, 4, 2, 6, 3, 1, 1, 1, 1, 
    4, 2, 2, 4, 4, 5, 4, 2, 1, 6, 7, 5, 2, 2, 4, 5, 6, 1, 5, 2, 4, 
    5, 5, 2, 2, 3, 4, 5, 2, 2, 4, 1, 3, 4, 4, 4, 2, 3, 1, 4, 4, 3, 
    2, 3, 1, 4, 2, 4, 4, 1, 5, 4, 4, 4, 4, 6, 1, 3, 5, 7, 2, 6, 1, 
    5, 7, 5, 4, 2, 3, 6, 3, 1, 1, 2, 2, 5, 5, 2, 5, 4, 4, 5, 4, 4, 
    3, 7, 4, 4, 4, 2, 5, 3, 6, 5, 4, 4, 4, 6, 4, 5, 5, 1, 5, 2, 6, 
    4, 4, 1, 1, 4, 6, 1, 7, 1, 5, 2, 5, 4, 2, 3, 2, 6, 3, 2, 2, 1, 
    1, 5, 4, 1, 1, 4, 1, 5, 1, 4, 3, 2, 3, 4, 1, 6, 1, 2, 1, 3, 5, 
    5, 2, 1, 3, 4, 2, 4, 5, 4, 6, 3, 4, 6, 7, 6, 2, 4, 6, 2, 4, 5, 
    1, 4, 1, 3, 2, 4, 1, 6, 4, 3, 1, 3, 4, 5, 1, 6, 1, 5, 1, 3, 3, 
    1, 3, 4, 2, 4, 1, 1, 2, 2, 2, 3, 1, 6, 5, 4, 1, 7, 5, 6, 5, 2, 
    3, 5, 4, 3, 4, 5, 7, 1, 5, 2, 5, 1, 3, 4, 3, 5, 1, 4, 2, 3, 4, 
    1, 7, 5, 5, 2, 1, 2, 5, 6, 5, 5, 3, 1, 3, 1, 4, 1, 5, 2, 3, 5, 
    6, 4, 4, 3, 2, 4, 1, 3, 4, 3, 4, 4, 1, 5)), row.names = c(NA, 
    -450L), class = c("tbl_df", "tbl", "data.frame")) 

CodePudding user response:

I'm not saying this approach is correct/valid (see the comment by @Maurits Evers), but you could do it like this:

library(tidyverse)
library(broom)
library(purrr)

df <- structure(list(consistent = c(1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 
                                    1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 
                                    1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 
                                    0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 
                                    1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 
                                    1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 
                                    1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 
                                    1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 
                                    0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 
                                    1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 
                                    0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 
                                    1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 
                                    1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 
                                    0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 
                                    1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 
                                    0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 
                                    0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 
                                    1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 
                                    1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 
                                    1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 
                                    0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 
                                    1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0), admire = c(7, 
                                                                                                         3, 1, 1, 3, 5, 5, 6, 7, 1, 4, 2, 5, 3, 3, 1, 3, 1, 2, 1, 5, 5, 
                                                                                                         3, 1, 5, 3, 5, 4, 5, 1, 6, 1, 6, 2, 1, 4, 1, 1, 3, 2, 1, 5, 1, 
                                                                                                         7, 1, 4, 1, 4, 2, 2, 4, 2, 4, 1, 5, 5, 1, 2, 6, 6, 1, 1, 3, 5, 
                                                                                                         5, 1, 5, 7, 2, 4, 5, 1, 4, 4, 3, 5, 6, 1, 5, 2, 1, 5, 6, 2, 3, 
                                                                                                         3, 5, 6, 1, 4, 4, 6, 4, 4, 4, 6, 5, 4, 1, 2, 5, 4, 2, 4, 6, 1, 
                                                                                                         3, 7, 4, 4, 3, 2, 7, 5, 3, 2, 1, 2, 2, 5, 7, 3, 5, 4, 6, 2, 2, 
                                                                                                         4, 4, 5, 5, 1, 5, 6, 1, 2, 4, 7, 1, 4, 5, 4, 2, 4, 1, 4, 3, 4, 
                                                                                                         7, 5, 6, 3, 1, 1, 7, 1, 6, 4, 1, 1, 2, 1, 1, 6, 3, 1, 4, 4, 7, 
                                                                                                         2, 1, 5, 3, 3, 7, 4, 5, 1, 3, 7, 5, 4, 1, 1, 1, 5, 2, 1, 1, 4, 
                                                                                                         1, 5, 4, 5, 1, 4, 4, 4, 7, 1, 1, 2, 5, 2, 4, 2, 4, 6, 4, 2, 6, 
                                                                                                         5, 6, 7, 4, 4, 5, 1, 5, 7, 1, 7, 2, 7, 3, 6, 2, 5, 7, 3, 5, 4, 
                                                                                                         1, 4, 1, 5, 1, 1, 6, 6, 7, 3, 4, 1, 6, 4, 1, 6, 7, 5, 4, 2, 6, 
                                                                                                         5, 5, 4, 1, 2, 6, 1, 5, 3, 1, 1, 1, 7, 7, 3, 5, 1, 5, 1, 7, 2, 
                                                                                                         5, 4, 2, 1, 4, 1, 1, 5, 5, 4, 5, 2, 4, 5, 5, 1, 4, 4, 1, 3, 4, 
                                                                                                         2, 7, 6, 6, 4, 3, 6, 1, 6, 1, 1, 4, 7, 7, 1, 3, 1, 4, 2, 2, 6, 
                                                                                                         1, 2, 1, 1, 1, 4, 2, 5, 4, 1, 4, 2, 5, 5, 2, 1, 6, 1, 2, 3, 4, 
                                                                                                         1, 7, 2, 2, 4, 5, 1, 6, 2, 5, 1, 5, 6, 2, 5, 1, 1, 7, 4, 5, 6, 
                                                                                                         1, 4, 5, 2, 4, 4, 6, 4, 4, 2, 6, 1, 1, 2, 6, 1, 3, 5, 5, 3, 7, 
                                                                                                         5, 6, 4, 3, 4, 7, 5, 4, 2, 1, 5, 7, 2, 6, 3, 1, 2, 4, 3, 5, 4, 
                                                                                                         1, 6, 1, 3, 1, 1, 1, 4, 3, 3, 1, 1, 1, 6, 4, 1, 1, 1, 1, 4, 1, 
                                                                                                         6, 4, 4, 4, 4, 1, 5, 2, 4, 5, 4, 4, 3, 3, 6, 7, 3, 2, 4, 2, 5, 
                                                                                                         1, 4, 5, 4, 1, 2, 4, 1), trust = c(7, 4, 2, 2, 3, 4, 6, 6, 7, 
                                                                                                                                            1, 4, 5, 5, 4, 1, 1, 2, 2, 1, 1, 6, 6, 4, 1, 3, 6, 5, 4, 6, 1, 
                                                                                                                                            5, 1, 6, 1, 2, 5, 1, 1, 4, 1, 1, 5, 1, 7, 1, 4, 4, 5, 3, 4, 5, 
                                                                                                                                            3, 5, 2, 6, 5, 3, 2, 6, 6, 1, 1, 3, 5, 5, 1, 5, 7, 2, 4, 6, 1, 
                                                                                                                                            4, 4, 4, 6, 6, 3, 5, 6, 1, 6, 5, 2, 2, 2, 5, 7, 1, 5, 3, 7, 3, 
                                                                                                                                            5, 4, 6, 6, 5, 2, 1, 6, 5, 2, 6, 5, 1, 2, 7, 6, 5, 3, 3, 4, 7, 
                                                                                                                                            4, 2, 1, 3, 4, 7, 6, 2, 6, 5, 7, 3, 2, 4, 5, 5, 5, 1, 2, 7, 1, 
                                                                                                                                            1, 5, 4, 1, 4, 6, 6, 2, 4, 2, 4, 1, 5, 7, 6, 7, 3, 2, 1, 7, 1, 
                                                                                                                                            4, 4, 1, 2, 4, 1, 1, 6, 3, 1, 4, 3, 7, 2, 2, 6, 4, 5, 7, 5, 7, 
                                                                                                                                            2, 4, 7, 4, 3, 1, 1, 1, 5, 2, 4, 1, 4, 1, 5, 4, 5, 1, 6, 5, 4, 
                                                                                                                                            6, 1, 1, 2, 6, 2, 4, 4, 4, 5, 6, 1, 5, 5, 5, 6, 4, 4, 5, 5, 6, 
                                                                                                                                            7, 1, 7, 3, 7, 5, 6, 3, 5, 7, 4, 5, 4, 2, 3, 1, 4, 5, 1, 5, 4, 
                                                                                                                                            7, 3, 5, 1, 6, 6, 1, 4, 6, 5, 4, 3, 7, 6, 5, 4, 1, 1, 6, 1, 5, 
                                                                                                                                            3, 1, 1, 1, 7, 7, 3, 4, 1, 4, 1, 7, 2, 4, 2, 2, 2, 4, 1, 1, 5, 
                                                                                                                                            4, 6, 5, 2, 4, 5, 4, 1, 6, 4, 1, 4, 4, 3, 7, 5, 6, 4, 4, 6, 2, 
                                                                                                                                            6, 1, 2, 4, 7, 7, 1, 1, 1, 4, 2, 2, 6, 2, 4, 1, 2, 1, 6, 2, 6, 
                                                                                                                                            4, 1, 6, 3, 5, 4, 3, 1, 6, 1, 2, 3, 5, 1, 6, 1, 3, 4, 5, 2, 6, 
                                                                                                                                            2, 5, 1, 3, 7, 1, 4, 1, 1, 7, 5, 6, 5, 1, 5, 5, 1, 4, 3, 7, 4, 
                                                                                                                                            4, 1, 7, 1, 1, 4, 6, 1, 4, 5, 5, 4, 7, 6, 7, 4, 4, 4, 4, 4, 4, 
                                                                                                                                            1, 1, 5, 6, 2, 7, 4, 2, 4, 5, 4, 5, 4, 1, 5, 1, 2, 1, 1, 4, 4, 
                                                                                                                                            3, 4, 3, 1, 2, 6, 5, 1, 1, 1, 2, 4, 1, 7, 4, 4, 5, 6, 2, 5, 3, 
                                                                                                                                            4, 5, 4, 4, 3, 3, 6, 7, 4, 4, 3, 2, 5, 1, 5, 5, 5, 2, 2, 3, 1
                                                                                                         ), judge = c(1, 5, 6, 3, 6, 3, 4, 5, 4, 1, 3, 2, 3, 2, 4, 3, 
                                                                                                                      4, 2, 5, 4, 3, 3, 4, 4, 7, 5, 4, 4, 1, 3, 6, 2, 3, 2, 5, 2, 3, 
                                                                                                                      4, 2, 4, 4, 3, 4, 4, 1, 4, 1, 2, 3, 1, 2, 2, 3, 5, 3, 5, 5, 3, 
                                                                                                                      1, 4, 4, 2, 5, 4, 3, 1, 5, 4, 4, 5, 2, 2, 2, 7, 3, 3, 1, 1, 5, 
                                                                                                                      3, 3, 1, 2, 5, 2, 3, 5, 4, 3, 4, 3, 2, 1, 3, 4, 4, 5, 5, 3, 2, 
                                                                                                                      2, 3, 2, 4, 1, 1, 4, 2, 2, 3, 3, 2, 4, 4, 6, 1, 7, 4, 2, 3, 4, 
                                                                                                                      1, 2, 4, 4, 5, 2, 1, 3, 2, 2, 1, 1, 7, 2, 3, 5, 5, 1, 2, 2, 5, 
                                                                                                                      6, 5, 1, 1, 1, 4, 1, 5, 4, 3, 6, 1, 4, 1, 3, 4, 6, 1, 2, 4, 3, 
                                                                                                                      3, 4, 7, 1, 3, 1, 2, 2, 3, 2, 3, 5, 3, 4, 2, 6, 3, 1, 1, 1, 1, 
                                                                                                                      4, 2, 2, 4, 4, 5, 4, 2, 1, 6, 7, 5, 2, 2, 4, 5, 6, 1, 5, 2, 4, 
                                                                                                                      5, 5, 2, 2, 3, 4, 5, 2, 2, 4, 1, 3, 4, 4, 4, 2, 3, 1, 4, 4, 3, 
                                                                                                                      2, 3, 1, 4, 2, 4, 4, 1, 5, 4, 4, 4, 4, 6, 1, 3, 5, 7, 2, 6, 1, 
                                                                                                                      5, 7, 5, 4, 2, 3, 6, 3, 1, 1, 2, 2, 5, 5, 2, 5, 4, 4, 5, 4, 4, 
                                                                                                                      3, 7, 4, 4, 4, 2, 5, 3, 6, 5, 4, 4, 4, 6, 4, 5, 5, 1, 5, 2, 6, 
                                                                                                                      4, 4, 1, 1, 4, 6, 1, 7, 1, 5, 2, 5, 4, 2, 3, 2, 6, 3, 2, 2, 1, 
                                                                                                                      1, 5, 4, 1, 1, 4, 1, 5, 1, 4, 3, 2, 3, 4, 1, 6, 1, 2, 1, 3, 5, 
                                                                                                                      5, 2, 1, 3, 4, 2, 4, 5, 4, 6, 3, 4, 6, 7, 6, 2, 4, 6, 2, 4, 5, 
                                                                                                                      1, 4, 1, 3, 2, 4, 1, 6, 4, 3, 1, 3, 4, 5, 1, 6, 1, 5, 1, 3, 3, 
                                                                                                                      1, 3, 4, 2, 4, 1, 1, 2, 2, 2, 3, 1, 6, 5, 4, 1, 7, 5, 6, 5, 2, 
                                                                                                                      3, 5, 4, 3, 4, 5, 7, 1, 5, 2, 5, 1, 3, 4, 3, 5, 1, 4, 2, 3, 4, 
                                                                                                                      1, 7, 5, 5, 2, 1, 2, 5, 6, 5, 5, 3, 1, 3, 1, 4, 1, 5, 2, 3, 5, 
                                                                                                                      6, 4, 4, 3, 2, 4, 1, 3, 4, 3, 4, 4, 1, 5)), row.names = c(NA, 
                                                                                                                                                                                -450L), class = c("tbl_df", "tbl", "data.frame")) 
variables <- c("admire", "trust")
form <- paste("consistent ~ judge   ",variables,"")
model <- form %>% 
  set_names(variables) %>%
  map(~lm(as.formula(.x), data = df))

map_dfr(model, ~tidy(summary(.x))) %>% 
  filter(p.value < 0.05 & term != "(Intercept)")
#> # A tibble: 4 × 5
#>   term   estimate std.error statistic  p.value
#>   <chr>     <dbl>     <dbl>     <dbl>    <dbl>
#> 1 judge    0.0413   0.00966      4.28 2.31e- 5
#> 2 admire   0.186    0.00817     22.8  5.76e-77
#> 3 judge    0.0397   0.00903      4.40 1.36e- 5
#> 4 trust    0.194    0.00757     25.7  5.45e-90

sig_terms <- map_dfr(model, ~tidy(summary(.x))) %>% 
  filter(p.value < 0.05 & term != "(Intercept)") %>%
  distinct(term)
sig_terms
#> # A tibble: 3 × 1
#>   term  
#>   <chr> 
#> 1 judge 
#> 2 admire
#> 3 trust

# More strict p.value cutoff as all terms are significant at 0.05
sig_terms <- map_dfr(model, ~tidy(summary(.x))) %>%
  filter(p.value < 1.36e-6 & term != "(Intercept)") %>%
  distinct(term)
sig_terms
#> # A tibble: 2 × 1
#>   term  
#>   <chr> 
#> 1 admire
#> 2 trust

Created on 2022-07-22 by the reprex package (v2.0.1)

  • Related