In my data set, I have several independent variables (here named "predictor1", "predictor2" etc.) and several dependent variables ("outcomeA", "outcomeB" etc). Furthermore, I have several covariates ("covariate1", "covariate2", etc.).
I want to do linear regression analysis, in which I
- FIRST use predictor1 to predict all outcomes, while adjusting for covariate1.
- THEN use predictor2 to predict all outcomes, while adjusting for covariate2.
- THEN use predictor3 to predict all outcomes, while adjusting for covariate3. etc.
I know how to build a loop that will use predictor1 to predict all outcomes, then use predictor2 to predict all outcomes, etc. I also know how to add covariates that would be used for all models regardless of the predictor in question, but that's no use.
What I don't know is this: how to I "couple" covariates with predictors, so that when I predict the outcomes with predictor1, I will also adjust for covariate1? Then, when I predict the outcomes with predictor2, I will adjust for covariate2, etc.
Below here is my syntax for doing this so that all models include the same covariates. How do I change this so that SPSS will not use all these covariates for all models, but will choose them according to the independent variable? Can I build two lists for independent variables that the loop will go through (e.g. "!indepvars1" and "!indepvars2") or something similar, or what could I do?
Obviously, I have no experience in programming, and I just couldn't get it to work on my own. Perhaps the answer is obvious.
PRESERVE.
SET TVARS NAMES.
oms select tables
/destination format = sav
numbered = "Table_Number"
outfile = '\\ATKK\visit1_TEMP1.sav'
/if commands = ['regression']
subtypes = ['Coefficients']
/tag = "reg".
*////////////////////.
DEFINE !regtest100 (indepvars=!charend ('/') /depvars=!CMDEND)
!DO !depvar !IN (!depvars)
!DO !indepvar !IN (!indepvars)
regression
/STATISTICS COEFF OUTS CI(95) R ANOVA
/dependent = !depvar
/method = enter !indepvar covariate1 covariate2 covariate3.
!DOEND
!DOEND
!ENDDEFINE.
*///////////////////
!regtest100
indepvars= predictor1 predictor2 predictor3.
/ depvars= outcomeA outcomeB outcomeC.
EXECUTE.