Looping macro for GENLIN call

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Looping macro for GENLIN call

Dave Allsop
Hi,

I am trying to set up an automated loop to run a GEE analysis on my data. I
have 32 dependent variables (columns), and a bunch of independent predictor
variables,  and about 800 rows (data or cases) - and I need to do a separate
GEE analysis for each of the 32 dependent variables..

Here is my attempt at the code so far (I know I am probably a long way off
still - but I am new to SPSS syntax... thanks in advance if abnybody can put
me on the right track..


define !myloop ()

!do !index = 1 !to 32
!let !var = !index


DATASET ACTIVATE DataSet1.
VECTOR dependents = Ifeltworried to Ifounditeasytoconcentrate.
*LOOP #index = 1:32

* Generalized Estimating Equations.
GENLIN dependents(!var) (ORDER=ASCENDING) BY BL_vs_Day_markers gender
Relapsers (ORDER=DESCENDING) WITH SDSScore age age_first_can_use
mean_weekly_can_use
Av_alc_units_per_week Av_ciggs_per_week
/MODEL BL_vs_Day_markers SDSScore gender Relapsers age age_first_can_use
Av_alc_units_per_week
DISTRIBUTION=MULTINOMIAL LINK=CUMPROBIT
/CRITERIA METHOD=FISHER(1) SCALE=1 MAXITERATIONS=100 MAXSTEPHALVING=5
PCONVERGE=1E-006(ABSOLUTE)
SINGULAR=1E-012 ANALYSISTYPE=3(WALD) CILEVEL=95 LIKELIHOOD=FULL
 /REPEATED SUBJECT=person_code WITHINSUBJECT=DayMarker SORT=YES
CORRTYPE=AR(1) ADJUSTCORR=YES
    COVB=ROBUST MAXITERATIONS=100 PCONVERGE=1e-006(ABSOLUTE) UPDATECORR=1
  /MISSING CLASSMISSING=EXCLUDE
  /PRINT CPS DESCRIPTIVES MODELINFO SUMMARY SOLUTION.

*END LOOP

!doend
!enddefine

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Looping macro for GENLIN call

Kylie
Hi Dave,

Untested, but I think this should do it:

* Create the macro definition.
DEFINE myloop (!POS !CHAREND('/'))
!DO !var !IN (!1)
GENLIN dependents(!var) (ORDER=ASCENDING) BY BL_vs_Day_markers gender
Relapsers (ORDER=DESCENDING)
 WITH SDSScore age age_first_can_use mean_weekly_can_use
Av_alc_units_per_week Av_ciggs_per_week
 /MODEL BL_vs_Day_markers SDSScore gender Relapsers age age_first_can_use
Av_alc_units_per_week
   DISTRIBUTION=MULTINOMIAL LINK=CUMPROBIT
 /CRITERIA METHOD=FISHER(1) SCALE=1 MAXITERATIONS=100 MAXSTEPHALVING=5
PCONVERGE=1E-006(ABSOLUTE)
   SINGULAR=1E-012 ANALYSISTYPE=3(WALD) CILEVEL=95 LIKELIHOOD=FULL
 /REPEATED SUBJECT=person_code WITHINSUBJECT=DayMarker SORT=YES
CORRTYPE=AR(1) ADJUSTCORR=YES
   COVB=ROBUST MAXITERATIONS=100 PCONVERGE=1e-006(ABSOLUTE) UPDATECORR=1
 /MISSING CLASSMISSING=EXCLUDE
 /PRINT CPS DESCRIPTIVES MODELINFO SUMMARY SOLUTION.
!DOEND
!ENDDEFINE.

* Call the macro, passing it the variables you want it to run on.
myloop Ifeltworried <list all variables here> Ifounditeasytoconcentrate.

Cheers,
Kylie.


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Dave Allsop
Sent: Tuesday, 21 September 2010 2:40 PM
To: [hidden email]
Subject: Looping macro for GENLIN call

Hi,

I am trying to set up an automated loop to run a GEE analysis on my data. I
have 32 dependent variables (columns), and a bunch of independent predictor
variables,  and about 800 rows (data or cases) - and I need to do a separate
GEE analysis for each of the 32 dependent variables..

Here is my attempt at the code so far (I know I am probably a long way off
still - but I am new to SPSS syntax... thanks in advance if abnybody can put
me on the right track..


define !myloop ()

!do !index = 1 !to 32
!let !var = !index


DATASET ACTIVATE DataSet1.
VECTOR dependents = Ifeltworried to Ifounditeasytoconcentrate.
*LOOP #index = 1:32

* Generalized Estimating Equations.
GENLIN dependents(!var) (ORDER=ASCENDING) BY BL_vs_Day_markers gender
Relapsers (ORDER=DESCENDING) WITH SDSScore age age_first_can_use
mean_weekly_can_use
Av_alc_units_per_week Av_ciggs_per_week
/MODEL BL_vs_Day_markers SDSScore gender Relapsers age age_first_can_use
Av_alc_units_per_week
DISTRIBUTION=MULTINOMIAL LINK=CUMPROBIT
/CRITERIA METHOD=FISHER(1) SCALE=1 MAXITERATIONS=100 MAXSTEPHALVING=5
PCONVERGE=1E-006(ABSOLUTE)
SINGULAR=1E-012 ANALYSISTYPE=3(WALD) CILEVEL=95 LIKELIHOOD=FULL
 /REPEATED SUBJECT=person_code WITHINSUBJECT=DayMarker SORT=YES
CORRTYPE=AR(1) ADJUSTCORR=YES
    COVB=ROBUST MAXITERATIONS=100 PCONVERGE=1e-006(ABSOLUTE) UPDATECORR=1
  /MISSING CLASSMISSING=EXCLUDE
  /PRINT CPS DESCRIPTIVES MODELINFO SUMMARY SOLUTION.

*END LOOP

!doend
!enddefine

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD