# Converting SPSS syntax for regression to Stata commands

I am running a series of regressions to eliminate the effects of IQ, language ability and age from my variables (task performance). To do this, the variable is entered as the dependent variable (e.g. EFT in syntax below) in a regression with IQ, language ability and age as predictor variables, selecting for control group only (GROUP1 EQ 2 is the control group). This regression equation is then applied to the other groups (GROUP1 = 0 & 1) and the residuals are collected.

The main problem I am having is converting the SPSS syntax below into Stata command (as I am relatively new to Stata). I need to use Stata to run the regression as my data are from related individuals and so I need to use the cluster command which isn't available in SPSS.

REGRESSION
/SELECT=GROUP1 EQ 2
/MISSING LISTWISE
/STATISTICS COEFF OUTS R ANOVA
/CRITERIA=PIN(.05) POUT(.10)
/NOORIGIN
/DEPENDENT EFT
/METHOD=ENTER AGE IQ LANG
/SAVE RESID (rEFT).

-
(+1) Although software-specific questions usually belong elsewhere, we might be the best possible place for stats/data analysis questions about how two (or more) stats programs compare or interact. I suggest refraining from voting to close. –  whuber Oct 3 '12 at 13:46

It's not clear to me why you want to do this, but anyway... This is a tentative based on what I've understood from your post.

regress eft age iq lang if group1 == 2, vce(cluster clustvar)
predict resid1 if inlist(group1, 0, 1), resid


Where clustvar is your cluster variable

(Please note that using vce(cluster clustvar) or not, won't change the residuals calculated with the second line of code, but of course it changes the standard errors of the linear regression).

-
(+1) andrea is right, cluster correction only applies to the standard errors. It seems to me, although zombie14600 did not really state that, that SPSS syntax above asks for a stepwise regression (argh... this is a terrible method), so I edited the suggested code. –  StasK Oct 3 '12 at 14:04
Yes, you're probably right @StasK (but as you say, it's a terrible method). Thanks for pointing that out. On a different note, is it only me who find it awkward to specify \NOORIGIN if you do want the intercept and \ORIGIN if you do not want the intercept? Probably it's just because I'm used to specify nocons (Stata) or noint (SAS), but it feels odd to me. Sorry if I've gone off topic. –  andrea Oct 3 '12 at 14:13
@StasK, the regression syntax for SPSS does not ask for stepwise regression. It is an unfortunate side effect of code produced from menu's, it always includes the CRITERIA statement, even if all variables are included in the equation. The relevant portion of the SPSS code is the /METHOD=ENTER portion, it would say METHOD = BACKWARD or something like that for the model selection techniques. I am going to roll back, andrea's solution was correct previously. –  Andy W Oct 3 '12 at 14:21
Also I agree to intercept statement is a bit strange to view. Again it is a by-product of over-verbose code produced when using the GUI menu's, the defaults for both are logical when the substatements in SPSS are entirely excluded. –  Andy W Oct 3 '12 at 14:26
Damn the interface. Thanks for editing it back. –  StasK Oct 5 '12 at 2:07