0

In the multi linear regression lm(FE_FCE2 ~ Trial + .x, data = DF_FCE3) there is one fixed variable (trial) and many x variables. I am analysing each x variable against FE_FCE2 with trial as fixed effect. I than use the boom package for the many regressions and plot the results in one table. I have obtained the results for the regression results. However cannot add the data from ANOVA Table into the Broom packages with map function.

Is it possible? And Yes How?

I have used the following formula to obtain Data from Results from Regression:

DF_FCE3 %>% 
  select(-FE_FCE2, -Trial) %>%  # exclude outcome, leave only predictors 
  map( ~lm(FE_FCE2 ~ Trial + .x, data = DF_FCE3)) %>% 
  map(summary) %>% 
  map_df(glance) %>% 
  round(3) -> rsme

However I would like to obtain the P-Value (**4.26e-08 *****) from the ANOVA Table of Trial. To see if Trial had a significant influence on the x variable.

**$x1
Analysis of Variance Table

**Response: FE_FCE2
          Df  Sum Sq  Mean Sq F value   Pr(>F)    
Trial      3 0.84601 0.282002 15.0653 **4.26e-08 *****
.x         1 0.00716 0.007161  0.3826   0.5377    
Residuals 95 1.77827 0.018719**                     
---**

Is it possible to use the broom package with map function to obtain a table which contains all the many p values of the anova regressions?

Phil
  • 7,287
  • 3
  • 36
  • 66
Totti
  • 15
  • 1
  • 1
  • 5
  • Please make a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) or [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – Martin Gal Oct 03 '21 at 15:12

1 Answers1

0

Like this (using mpg)? This returns a dataframe with the original columns and one row containing the p-value except for the outcome and target (hwy and cyl in thisexample, FE_FCE2 and Trial in your case).

mpg %>%
  select(-hwy, -cyl) %>%  # exclude outcome, leave only predictors 
  map( ~lm(hwy ~ cyl + .x, data = mpg)) %>% 
  map(anova) %>% 
  map(broom::tidy) %>%
  map_df(~.$p.value[1])
Robin Gertenbach
  • 10,316
  • 3
  • 25
  • 37