Hi! I'm trying to complete stepwise regression using forward, backward, and both. My data includes multiple dummy variables. This isn't a problem for my forward and backward however, when I run "both" it references my original dataset rather than the dummy variables I've created. To avoid this, I've tried using scope however, somewhere I am going wrong. Below is my code as well as the error I receive:
step(lm(lifesat~., data=na.omit(final4)),direction="both", scope=(lifesat~age+male+notmarried+income+physical+child+ses+nosmoke+spirit+college+advanced+job+psych))
step(lm(lifesat~., data=na.omit(final4)),direction="both", scope=(lifesat~age+male+notmarried+income+physical+child+ses+nosmoke+spirit+college+advanced+job+psych))
Start: AIC=181.63
lifesat ~ subject + age + gender + married + psych + ses + child +
physical + smoke + spirit + edu + job + income + male + notmarried +
nosmoke + college + advanced
Error in factor.scope(ffac, list(add = fadd, drop = fdrop)) :
upper scope has terms ‘subject’, ‘gender’, ‘married’, ‘smoke’, ‘edu’ not included in model
Thank you in advance for your help!