Hi there,
I am admittingly a newbie at both R and stepwise regression.
I have been analysing my data using linear regression analysis but have decided stepwise regression would be more appropriate.
After a quick bit of research it looked like the 'olsrr' package is a straightforward way to do stepwise regression. However, I have encountered a bit of an error. In my dataset there are multiple observations per individual, as such it would be optimal to add participant ID as a random intercept. Previously I was doing this by adding '(1 |participantID)' after listing my independent variables when performing regression analysis. However, this command doesn't seem to work with the 'olsrr' package, is there another command I can use or is this not possible?
Many thanks in advance!!
Code example:
model1 <- lm(dependentvariable ~ variable1 + variable2 + variable3 + variable4, data = datafile)
forward <- ols_step_forward_p(model1, pent = 0.5, details = TRUE)
plot(forward)