-1

I want to mimic the following SPSS syntax in R:

USE first thru 3122.
EXECUTE.

REGRESSION
  /STATISTICS COEFF OUTS R ANOVA COLLIN TOL ZPP
  /CRITERIA=PIN(.05) POUT(.10)
  /NOORIGIN 
  /DEPENDENT HCTBB
  /METHOD=BACKWARD

So far, I have done this:

step(lm(dependentVAR[1:3122]~.,data=independentVAR[1:3122,]),direction="backward")

But the output (on the exact same dataset) is not the same. Can anyone help?

Rorschach
  • 31,301
  • 5
  • 78
  • 129
Joost
  • 9
  • 1
  • 2
    First, it is traditional to admonish someone asking about this topic and point them to why it is bad(e.g., [link](http://www.google.com/#q=why+is+stepwise+regression+bad)). Second, you may find this to be helpful: [link](http://stats.stackexchange.com/questions/97257/stepwise-regression-in-r-critical-p-value) Third, please provide a reproducible example. And if you want to match the outputs, please provide the SPSS output somehow. – user1231088 Dec 18 '15 at 14:45
  • Please read the info about [how to ask a good question](http://stackoverflow.com/help/how-to-ask) and how to give a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610). This will make it much easier for others to help you. – Jaap Dec 21 '15 at 07:23
  • Thank you for your feedback, I am new at this so I will keep it in mind in the future. I am working with a lot of data I cannot share, but I have followed up on your suggestion and tested some 'random' regression data from the internet. Using this data set, R and SPSS yielded the same outcome! So now I am wondering if R is treating my variables in the same way SPSS does... – Joost Dec 21 '15 at 12:43

1 Answers1

0

I guess you are performing multiple linear regression?

You may find regsubsets function (package: leaps) and stepAIC (library: mass) helpful. The former allowing the usual criteria such as AIC, BIC and adjusted R2, whereas the latter is only based on AIC. In terms of the search process, they are all able to do backward, forward, and best subset.

StayLearning
  • 601
  • 2
  • 7
  • 18
  • Thank you for your suggestion! I have posted a comment above which describes my progress. I will certainly look at regsubsets and stepAIC as well. Thank you so much for your help. – Joost Dec 21 '15 at 12:44