The step function always prints the result of each stepwise regression to the console, even if the executed statement is an assignment, not evaluation. How do I make it just silently select predictors, without printing anything?
In the help file of function step()
you can find that there is argument trace=
. If you set this argument to 0
then only final predictors are printed or if you use step()
in assignment then nothing is printed.
Modified example from help file:
summary(lm1 <- lm(Fertility ~ ., data = swiss))
slm1 <- step(lm1,trace=0)
summary(slm1)
Or
step(lm1, trace=0)
Call:
lm(formula = Fertility ~ Agriculture + Education + Catholic +
Infant.Mortality, data = swiss)
Coefficients:
(Intercept) Agriculture Education Catholic
62.1013 -0.1546 -0.9803 0.1247
Infant.Mortality
1.0784
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