[R] olsrr and substitute lm -> lmRob
Ashim Kapoor
@@h|mk@poor @end|ng |rom gm@||@com
Tue Oct 10 09:00:01 CEST 2023
Dear all,
I wish to use backward selection from the package olsrr.
?ols_step_backward_p
This gives me a model of class lm.
I wish to then run lmRob from the robust package on the SAME variables
ie I want to substitute lm -> lmRob in the function call which created
the lm model.
Here is a reprex:
----------------------------------------------------------------
library(olsrr)
library(robust)
myformula <- lm(mpg~.,data = mtcars)
# This is how I do backward selection.
chosen.model = ols_step_backward_p(myformula,details=F)
# Chosen model
chosen.model$model
# Not sure if this is the correct thing to do
lmRob(chosen.model$model)
--------------------------------------------------------------------------
My query is : is the above correct ? Do I need to do some meta
programming and substitute lm with lmRob ?
I am not sure how I would do that in this context using the
?substitute function perhaps ?
Many thanks,
Ashim
More information about the R-help
mailing list