I have constructed a linear regression model, reg_model1, and the model has factors within it. However, within the different sets of factors in the model, very few are significant along with other continuous variables. Is there any code that one can supply to the reg_model1 to produce a summary that outputs only predictors that best fits the model?
Regression Model (Outputs with only meaninful predictors)
93 Views Asked by Cheruiyot Koech At
3
There are 3 best solutions below
0
On
I'd suggest Stepwise Regression / Stepwise Selection. With this you can choose a best fit based on RSME and the goodness of fit. Here's a good source performed on mtcars dataset. There are several other packages which offer pretty much the same thing. I personally prefer to use step function for this purpose.
step.model <- step(lm(mpg ~ ., mtcars), direction="both", trace=FALSE);
summary(step.model)
From a statistical point of view I think you are making confusion between independent variables influencing the dependent variable and goodness of fit of the model, so my advice is to be sure about what you are trying to obtain. That said, if you want a representation of your model that only includes some of the variables, you may transform it into a dataframe with
broom::tidy:Created on 2021-11-20 by the reprex package (v2.0.1)