Skip to main content
4 of 6
edited body
Deb
  • 319
  • 1
  • 5

How to get coefficient tables from multiple regression model result!

I've done multiple regression modeling in R using the below script. Now I'm wondering how can I make a table for the coefficients of each model of all models from lm, glm, and rf separately.


all_variables <- names(PaC09c_w20_dat3)
response_variables <- all_variables[c(1:3)]
predictors <- all_variables[-c(1:3)]

lm_model <- lapply(
  response_variables,
  function(x) lm(reformulate(termlabels = predictors, response = x), data = PaC09c_w20_dat3)
) |>
  setNames(response_variables)

glm_model <- lapply(
  response_variables,
  function(x) glm(reformulate(termlabels = predictors, response = x), data = PaC09c_w20_dat3)
) |>
  setNames(response_variables)

rf_ranger <- lapply(
  response_variables,
  function(x) ranger(reformulate(termlabels = predictors, response = x), data = PaC09c_w20_dat3, importance="impurity")
) |>
  setNames(response_variables)

save.image(file="PaC09c_w20_Reg.RData")

Input data looks like,

  head(PaC09c_w20_dat3)
        EE87865ln1   EE87866ln1   EE87895ln1  blood_vessel_w20 adrenal_gland_w20 bone_element_w20 bronchus_w20 
               <dbl>       <dbl>      <dbl>     <dbl>             <dbl>            <dbl>        <dbl>         
        1    0.00391     0.00326    0.00332       0                 0                1            0             
        2    0.00139     0.00116    0.00132       0                 0                0            0             
        3    0.00360     0.00270    0.00469       1                 1                0            1             
        4    0.00323     0.00348    0.00339       0                 0                1            0             
        5    0.00323     0.00330    0.00382       0                 1                0            0             
        6    0.00278     0.00208    0.00214       0                 0                1            0             
Deb
  • 319
  • 1
  • 5