R Stepwise Regression Error

Hi. i am trying to run a stepwise regression in R. My code are as follow:

model1<-lm(y~.,data=table)

library(olsrr)

model3<-ols_step_both_p(model1, pent=0.25, prem=0.05)

However, in the console section, I always get this:

model3<-ols_step_both_p(model1, pent=0.25, prem=0.05)

Error in model.frame.default(formula = paste(response, "~", paste(predictors, :

'data' must be a data.frame, environment, or list

Help please!

I noticed that you have set pent to be greater than prem but shouldn't pent to be less than prem?

pent    p value; variables with p value less than pent will enter into the model.
prem    p value; variables with p more than prem will be removed from the model.

I rechecked the given data. pent is really 0.25 and prem is 0.05 :frowning:

image

I dont know where I am wrong.

Can you post the output of

dput(model1)

If that is very large, due to a large data set, can you run lm() on a subset of your data and post the result of running dput() on the that model1? Put a line with three back ticks just before and just after the dput() output, like this
```
dput() output here
```

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.