I'm running a step regression and I'd like to extract the final formula to use it in another regression.
Using this example:
lm1 <- lm(Fertility ~ ., data = swiss)
slm1 <- step(lm1)
I would expect to be able to assign this to a formula object:
Fertility ~ Agriculture + Education + Catholic +
Infant.Mortality
You can simply extract it from your slm1
object using the formula
method for lm
object
formula(slm1)
Fertility ~ Agriculture + Education + Catholic + Infant.Mortality
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With