Discussion:
Repeated Measures with Within Subjects factor Logistic Regression in SPSS?
(too old to reply)
d***@gmail.com
2009-05-29 20:46:18 UTC
Permalink
Hi,

I'm trying to analyze some data from an experimental design where I
have two between subjects factors and a repeated measure with a
categorical response (Yes or No) in 3 different treatments for the
same subject. Factors Dis and Wo, are the between subjects (BS)
factors (also categorical, both Hi/Low manipulations), PreF (Hi/Low)
is the within subjects factor and PSCH is the repeated measure. If
PSCH were a continuous variable, I could do a repeated measures under
the GLM option, alas it's not.

I'm trying to test whether the Dis, Wo, PreF, Dis*PreF or Dis*Wo*PreF
have any significant effects on the PSCH measure response. Is there
a way to do this with SPSS code? If so is there a way to do it with
the 3 repeated measures in one row of data for the subject instead of
having 3 rows of data for each subject with dummy variables?

I think the codes should look something like the below with 3 rows for
each subject and dummy variables for each level of treatment
(t1,t2,t3), but I can't seem to get it quite right. Can some point me
in the right direction? Please let me know if you can or if I'm
unclear or if there's an easier way to attack this problem.

GENLIN PSCH (REFERENCE=FIRST) BY Dis Wo WITH t1 t2 t3
/MODEL Dis Wo Dis*Wo t1 t2 t3 INTERCEPT=YES
DISTRIBUTION=BINOMIAL LINK=LOGIT
/REPEATED SUBJECT=fileNum WITHINSUBJECT=t2*t3
/MISSING CLASSMISSING=EXCLUDE
/PRINT CPS DESCRIPTIVES MODELINFO FIT SUMMARY.
Thanks,
D
Bruce Weaver
2009-05-30 02:37:00 UTC
Permalink
Post by d***@gmail.com
Hi,
I'm trying to analyze some data from an experimental design where I
have two between subjects factors and a repeated measure with a
categorical response (Yes or No) in 3 different treatments for the
same subject. Factors Dis and Wo, are the between subjects (BS)
factors (also categorical, both Hi/Low manipulations), PreF (Hi/Low)
is the within subjects factor and PSCH is the repeated measure. If
PSCH were a continuous variable, I could do a repeated measures under
the GLM option, alas it's not.
I'm trying to test whether the Dis, Wo, PreF, Dis*PreF or Dis*Wo*PreF
have any significant effects on the PSCH measure response. Is there
a way to do this with SPSS code? If so is there a way to do it with
the 3 repeated measures in one row of data for the subject instead of
having 3 rows of data for each subject with dummy variables?
I think the codes should look something like the below with 3 rows for
each subject and dummy variables for each level of treatment
(t1,t2,t3), but I can't seem to get it quite right. Can some point me
in the right direction? Please let me know if you can or if I'm
unclear or if there's an easier way to attack this problem.
GENLIN PSCH (REFERENCE=FIRST) BY Dis Wo WITH t1 t2 t3
/MODEL Dis Wo Dis*Wo t1 t2 t3 INTERCEPT=YES
DISTRIBUTION=BINOMIAL LINK=LOGIT
/REPEATED SUBJECT=fileNum WITHINSUBJECT=t2*t3
/MISSING CLASSMISSING=EXCLUDE
/PRINT CPS DESCRIPTIVES MODELINFO FIT SUMMARY.
Thanks,
D
I'm not sure I follow everything, but if there are 3 repeated
measures, then you should have only two of the 3 dummy variables
(t1, t2, t3) in your model. The one you omit will be the
reference category.
--
Bruce Weaver
***@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/
"When all else fails, RTFM."
DH
2009-06-01 15:31:53 UTC
Permalink
Thanks Bruce.

I took your advice, and now I'm down to the following code (where the
t2 and t3 have been replaced by PreF2 and PreF3, the Dis replaced by
Discount and Wo dropped from the model, as it had no impact):

GENLIN PSCH (REFERENCE=FIRST) BY discount WITH PreF2 PreF3
/MODEL discount discount*PreF2 discount*PreF3 PreF2 PreF3
INTERCEPT=YES
DISTRIBUTION=BINOMIAL LINK=LOGIT
/REPEATED SUBJECT=file WITHINSUBJECT=PreF2*PreF3
/MISSING CLASSMISSING=EXCLUDE
/PRINT CPS DESCRIPTIVES MODELINFO FIT SUMMARY.

That seems to be getting close to working, but is there a way to
specify that the PreF2 and PreF3 are categorical instead of continuous
variables? The output I'm getting seems to hint that it is incorrectly
treating them as continuous.

Thanks,
D
Ryan
2009-06-01 17:21:31 UTC
Permalink
Post by DH
Thanks Bruce.
I took your advice, and now I'm down to the following code (where the
t2 and t3 have been replaced by PreF2 and PreF3, the Dis replaced by
GENLIN PSCH (REFERENCE=FIRST) BY discount WITH PreF2 PreF3
  /MODEL discount discount*PreF2 discount*PreF3 PreF2 PreF3
INTERCEPT=YES
   DISTRIBUTION=BINOMIAL LINK=LOGIT
  /REPEATED SUBJECT=file WITHINSUBJECT=PreF2*PreF3
  /MISSING CLASSMISSING=EXCLUDE
  /PRINT CPS DESCRIPTIVES MODELINFO FIT SUMMARY.
That seems to be getting close to working, but is there a way to
specify that the PreF2 and PreF3 are categorical instead of continuous
variables? The output I'm getting seems to hint that it is incorrectly
treating them as continuous.
Thanks,
D
A couple of quick thoughts.

(1) You do not need to dummy code. Simply place the categorical
variable in the "Factor" Window. Of course you need to make sure that
it's using the reference category that you want. If for some reason
you feel strongly about dummy coding, then it shouldn't matter if you
treat the dichotomous variables as a covariate or Factor.
(2) Similar to an ANOVA, if you want to examine the main effects, you
should not include any interactions in the model. After you review the
main effects, then run another model with any two-way interactions
that interest you. The same applies to examining two-way interactions
in the presence of three way interactions.

HTH
DH
2009-06-01 18:10:06 UTC
Permalink
Hi Ryan,

Thanks for the feedback. I'm confident I can follow what you are
saying in (2), but I want to make sure that I'm fully understanding
what you are saying with comment (1). I was trying to do this with
code because I didn't think I could accomplish what I needed with the
drop down menus. So, I think what you are saying is that I should be
using Analyze -> Regression -> Binary Logistic and putting the
categorical variable in the "Covariates" box. Is that right? I
understand how to do that and specify a categorical vs. continuous
variable. My issue is how to indicate that the binary DV is a
repeated measure so that I account for the influence of the same
participant at different trt levels, in addition to the 2 between
subjects factors, and as near as I can tell, there is no way to
specify this in the binary logistic regression option. Does that make
sense?

D
Ryan
2009-06-01 21:39:54 UTC
Permalink
Post by DH
Hi Ryan,
Thanks for the feedback.   I'm confident I can follow what you are
saying in (2), but I want to make sure that I'm fully understanding
what you are saying with comment (1).  I was trying to do this with
code because I didn't think I could accomplish what I needed with the
drop down menus.   So, I think what you are saying is that I should be
using Analyze ->   Regression -> Binary Logistic and putting the
categorical variable in the "Covariates" box.   Is that right?   I
understand how to do that and specify a categorical vs. continuous
variable.  My issue is how to indicate that the binary DV is a
repeated measure so that I account for the influence of the same
participant at different trt levels, in addition to the 2 between
subjects factors, and as near as I can tell, there is no way to
specify this in the binary logistic regression option.  Does that make
sense?
D
I can't say I understand your model fully, but it seems to me that
"Treatment" is the within subjects (aka repeated measures) independent
variable. You have treatment-invariant covariates and treatment-
variant covariates. How one treats variant and invariant covariates
depends largerly on your research question.I would not use the
standard binary logistic regression procedure because each person is
exposed to each treatment, right? If yes, then I would stick with
generalized estimating equations (GEE).

As far as I'm aware, you have the option of treating a variable as
categorical (Factor) or continuous (covariate) in the GEE procedure.

HTH

Ryan

Ryan
Ryan
2009-06-01 22:30:23 UTC
Permalink
Post by Ryan
Post by DH
Hi Ryan,
Thanks for the feedback.   I'm confident I can follow what you are
saying in (2), but I want to make sure that I'm fully understanding
what you are saying with comment (1).  I was trying to do this with
code because I didn't think I could accomplish what I needed with the
drop down menus.   So, I think what you are saying is that I should be
using Analyze ->   Regression -> Binary Logistic and putting the
categorical variable in the "Covariates" box.   Is that right?   I
understand how to do that and specify a categorical vs. continuous
variable.  My issue is how to indicate that the binary DV is a
repeated measure so that I account for the influence of the same
participant at different trt levels, in addition to the 2 between
subjects factors, and as near as I can tell, there is no way to
specify this in the binary logistic regression option.  Does that make
sense?
D
I can't say I understand your model fully, but it seems to me that
"Treatment" is the within subjects (aka repeated measures) independent
variable. You have treatment-invariant covariates and treatment-
variant covariates. How one treats variant and invariant covariates
depends largerly on your research question.I would not use the
standard binary logistic regression procedure because each person is
exposed to each treatment, right? If yes, then I would stick with
generalized estimating equations (GEE).
As far as I'm aware, you have the option of treating a variable as
categorical (Factor) or continuous (covariate) in the GEE procedure.
HTH
Ryan
Ryan- Hide quoted text -
- Show quoted text -
One small clarification--I said you have treatment invariant and
variant "covariates," regarding dichotomous variables as covariates.
You can certainly replace the term "Covariate" with "Factor" if that
makes it easier to digest.
DH
2009-06-01 22:44:26 UTC
Permalink
Hi Ryan,

I'm sorry if I haven't done a great job explaining the model, but you
seem to have it grasped spot on. Treatment (trt) is the Within Ss IV,
and it is categorical. As are the other two between subjects IV
factors which do not vary between treatment levels (so a person is
always at one level of Dis and one level of Wo as they are exposed to
3 levels of trt). The DV is the PSCH, which is binary and taken at
each trt level.

You are correct in that each person is exposed to each treatment, thus
making the regular binary logistic regression procedure unusable to me
because I cannot specify that repeated measure within the framework.
I tried to use your guidance to use the GEE correctly to get at the
information I need, but I'm still falling short.

So I open the GEE box, and I did the following. I went to the
"Repeated Tab" and enter subj into the "subject variables" box and trt
into the "within-subject variables" box. Next I selected the type of
model tab, here I can specify "Binary Logistic" as the type. Then I
moved to the response tab here I entered PSCH and selected Binary for
the Type of Dependent Variable. Next I went to the Predictors tab and
inserted Dis, Wo and logitcount into the "Factors" Box. Then I went
to the Model tab, and I put Dis, Wo, and trt in the "Model" box (can
also specify any of the appropriate interactions here either now or at
a later time). I left the default on the estimation, statistics, EM
Means tabs. Then I hit OK. When I did this, I got the message "There
are at least two records with the same values for the subject and
within-subject variables. No output will be displayed. This command is
not executed."

Presumably, this means that the information on the "Repeated Tab" for
"Subject Variables" and "within Subject variables" are redundant. I
tried removing the trt from the "within-subjects" box, and I get a
message that "The Hessian matrix is singular. Some convergence
criteria are not satisfied.
The GENLIN procedure continues despite the above warning(s).
Subsequent results shown are based on the last iteration. Validity of
the model fit is uncertain." Thus I'm assuming that something is awry
still. Can you offer any further insight? My current syntax text is
as follows:

GENLIN PSCH (REFERENCE=LAST) BY dis wo trt (ORDER=ASCENDING)
/MODEL dis wo trt dis*trt INTERCEPT=YES
DISTRIBUTION=BINOMIAL LINK=LOGIT
/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=subj SORT=YES CORRTYPE=INDEPENDENT ADJUSTCORR=YES
COVB=ROBUST MAXITERATIONS=100
PCONVERGE=1e-006(ABSOLUTE) UPDATECORR=1
/MISSING CLASSMISSING=EXCLUDE
/PRINT CPS DESCRIPTIVES MODELINFO FIT SUMMARY SOLUTION.

Thanks,
D
Ryan
2009-06-02 01:31:36 UTC
Permalink
Post by DH
Hi Ryan,
I'm sorry if I haven't done a great job explaining the model, but you
seem to have it grasped spot on.  Treatment (trt) is the Within Ss IV,
and it is categorical.  As are the other two between subjects IV
factors which do not vary between treatment levels (so a person is
always at one level of Dis and one level of Wo as they are exposed to
3 levels of trt).  The DV is the PSCH, which is binary and taken at
each trt level.
You are correct in that each person is exposed to each treatment, thus
making the regular binary logistic regression procedure unusable to me
because I cannot specify that repeated measure within the framework.
I tried to use your guidance to use the GEE correctly to get at the
information I need, but I'm still falling short.
So I open the GEE box, and I did the following.  I went to the
"Repeated Tab" and enter subj into the "subject variables" box and trt
into the "within-subject variables" box.  Next I selected the type of
model tab, here I can specify "Binary Logistic" as the type.  Then I
moved to the response tab here I entered PSCH and selected Binary for
the Type of Dependent Variable.  Next I went to the Predictors tab and
inserted Dis, Wo and logitcount into the "Factors" Box.  Then I went
to the Model tab, and I put Dis, Wo, and trt in the "Model" box (can
also specify any of the appropriate interactions here either now or at
a later time). I left the default on the estimation, statistics, EM
Means tabs.  Then I hit OK.  When I did this, I got the message "There
are at least two records with the same values for the subject and
within-subject variables. No output will be displayed. This command is
not executed."
Presumably, this means that the information on the "Repeated Tab" for
"Subject Variables" and "within Subject variables" are redundant.  I
tried removing the trt from the "within-subjects" box, and I get a
message that "The Hessian matrix is singular. Some convergence
criteria are not satisfied.
The GENLIN procedure continues despite the above warning(s).
Subsequent results shown are based on the last iteration. Validity of
the model fit is uncertain."  Thus I'm assuming that something is awry
still.  Can you offer any further insight?  My current syntax text is
GENLIN PSCH (REFERENCE=LAST) BY dis wo trt (ORDER=ASCENDING)
  /MODEL dis wo trt dis*trt INTERCEPT=YES
 DISTRIBUTION=BINOMIAL LINK=LOGIT
  /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=subj SORT=YES CORRTYPE=INDEPENDENT ADJUSTCORR=YES
COVB=ROBUST MAXITERATIONS=100
    PCONVERGE=1e-006(ABSOLUTE) UPDATECORR=1
  /MISSING CLASSMISSING=EXCLUDE
  /PRINT CPS DESCRIPTIVES MODELINFO FIT SUMMARY SOLUTION.
Thanks,
D
Here's what I came up with:

GENLIN psych (REFERENCE=LAST) BY dis wo trt (ORDER=ASCENDING)
/MODEL dis wo trt INTERCEPT=YES
DISTRIBUTION=BINOMIAL LINK=LOGIT
/REPEATED SUBJECT=subj WITHINSUBJECT=trt SORT=YES
CORRTYPE=EXCHANGEABLE ADJUSTCORR=YES
/PRINT CPS DESCRIPTIVES MODELINFO FIT SUMMARY SOLUTION.

The above code assumes the following:
(1) dis wo and trt are categorical independent variables
(2) subj is the subjects variable
(3) trt is a within subjects independent variable
(4) the var-cov matrix is exchangeable
(5) psych is the dichotomous dependent variable

*The above code should work. If it doesn't there's something about
your data I'm not grasping. With regard to the first warning message,
are you sure your data look like this?:

Subj Trt
1 1
1 2
1 3
2 1
2 2
2 3
.
.

Is there ever a situation where a subject is exposed to the same
treatment twice?:

Subj Trt
1 1
1 2
1 2
.
.
.

Ryan
DH
2009-06-02 14:57:05 UTC
Permalink
Hi Ryan,

I'll try the code you listed above, and yes you were correct about the
first error message. I have a few different subject labels, one
identifies them individually, one by session. I used the one by
session, thus the redundancy message. I've got that taken care of
now, and I'll work on the other issues. Thanks for your help.

D
DH
2009-06-02 15:35:55 UTC
Permalink
Hi Ryan,

So spot on again with all the assumptions of the variable descriptions
and the model works for the main effects. Thank you very much.
However, I seem to be unable to specify and interaction in the model
for the dis*trt (a between Ss factor with a within Ss factor) without
getting the singular hessian matrix error message. Is there anyway to
get around this?

Thanks again for all of your help.

D
DH
2009-06-02 18:30:19 UTC
Permalink
Actually, I'm finding that for some reason, I don't have an issue with
the word*trt interaction. It's only when I include the trt*dis
interaction term that there is the Hessian matrix issue.
Ryan
2009-06-03 12:05:50 UTC
Permalink
Post by DH
Actually, I'm finding that for some reason, I don't have an issue with
the word*trt interaction.  It's only when I include the trt*dis
interaction term that there is the Hessian matrix issue.
Time is against me today but I have a few brief suggestions:

(1) Check for high levels of multicollinearity
(2) Examine the number of events that occur with each possible
combination of trt*dis. You might be asking for more than your data
can give.
(3) Consider changing the estimation method and/or convergence
criteria.

I'm not sure if any of the three above suggestions will help you, but
I can't think of anything else at the moment.

Hopefully others will chime in.

Best,

Ryan
DH
2009-06-04 23:40:19 UTC
Permalink
Hi Ryan,

I have narrowed the problem down. The issue is as you stated in #2.
For one of the dis levels there are not enough "0" responses on the
binary DV (in fact all of them are "1") to have the model work
correctly. I'm trying to figure out ways to get around that and I
have a meeting in the works with a statistical ace.

Thanks very much for your help. Unfortunately, it appears that my
data set might be the issue, not the methods/programming. Hopefully
there will be some way to get around this.

Best,
D
Ryan
2009-05-31 01:51:11 UTC
Permalink
Post by d***@gmail.com
Hi,
I'm trying to analyze some data from an experimental design where I
have two between subjects factors and a repeated measure with a
categorical response (Yes or No) in 3 different treatments for the
same subject. Factors Dis and Wo, are the between subjects (BS)
factors (also categorical, both Hi/Low manipulations), PreF (Hi/Low)
is the within subjects factor and PSCH is the repeated measure.  If
PSCH were a continuous variable, I could do a repeated measures under
the GLM option, alas it's not.
I'm trying to test whether the Dis, Wo, PreF, Dis*PreF or Dis*Wo*PreF
have any significant effects on the PSCH measure response.    Is there
a way to do this with SPSS code?  If so is there a way to do it with
the 3 repeated measures in one row of data for the subject instead of
having 3 rows of data for each subject with dummy variables?
I think the codes should look something like the below with 3 rows for
each subject and dummy variables for each level of treatment
(t1,t2,t3), but I can't seem to get it quite right.  Can some point me
in the right direction?  Please let me know if you can or if I'm
unclear or if there's an easier way to attack this problem.
GENLIN PSCH (REFERENCE=FIRST) BY Dis Wo WITH t1 t2 t3
  /MODEL Dis Wo Dis*Wo t1 t2 t3  INTERCEPT=YES
   DISTRIBUTION=BINOMIAL LINK=LOGIT
  /REPEATED SUBJECT=fileNum WITHINSUBJECT=t2*t3
  /MISSING CLASSMISSING=EXCLUDE
  /PRINT CPS DESCRIPTIVES MODELINFO FIT SUMMARY.
Thanks,
D
Does your dataset look like this:

************************************
Subj Dis Wo Trt PreF Psch
1 1 2 1 1 1
1 1 2 2 2 2
1 1 2 3 1 2
2 2 1 1 2 2
2 2 1 2 1 1
2 2 1 3 2 1
.
.
.
**********************************
DH
2009-06-01 15:56:56 UTC
Permalink
Hi Ryan,
Pretty close, but not exactly. I realized after I should have posted
Post by Ryan
************************************
Subj  Dis  Wo  Trt PreF1 PreF2 PreF3 Psch
1        1     2     1    1       0 0 1
1        1     2     2    0       1 0 0
1        1     2     3    0       0 1 1
2        2     1     1    1       0 0 0
2        2     1     2    0       1 0 1
2        2     1     3    0      0 1 0
So The Dis and Wo factors are between subjects and thus constant for
the 3 measures in the same subject. All participants see the same 3
Trt options, which I've Dummy Coded with the PreF variables, and PSCH
is the Binary DV. All IVs are categorical.

I'm interested in the Dis main effects, the trt (or alternatively
PreF) main effect and the interaction between the two.

Thanks,
Dan
p***@gmail.com
2012-10-30 16:34:10 UTC
Permalink
You need to use GEE in SPSS.
To do GEE you need to restructure your data.
Subj Dis Wo Trt Psch PreF Within subject variable
1 1 2 1 1 0 1
1 1 2 2 0 0 1
1 1 2 3 1 0 1
2 2 1 1 0 1 1
2 2 1 2 1 0 1
2 2 1 3 0 0 1
1 1 2 1 1 0 2
1 1 2 2 0 1 2
1 1 2 3 1 0 2
2 2 1 1 0 0 2
2 2 1 2 1 1 2
2 2 1 3 0 0 2
1 1 2 1 1 0 3
1 1 2 2 0 1 3
1 1 2 3 1 0 3
2 2 1 1 0 0 3
2 2 1 2 1 1 3
2 2 1 3 0 0 3



The code would then be

GENLIN PreF (REFERENCE=FIRST) BY Dis Wo Trt Psch Withinsubjectvariable (ORDER=ASCENDING)
/MODEL Dis Wo Trt Psch Withinsubjectvariable INTERCEPT=YES
DISTRIBUTION=BINOMIAL LINK=LOGIT
/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=Subj WITHINSUBJECT=Withinsubjectvariable SORT=YES CORRTYPE=UNSTRUCTURED
ADJUSTCORR=YES COVB=ROBUST MAXITERATIONS=100 PCONVERGE=1e-006(ABSOLUTE) UPDATECORR=1
/MISSING CLASSMISSING=EXCLUDE
/PRINT CPS DESCRIPTIVES MODELINFO FIT SUMMARY SOLUTION.

Loading...