Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Correlation between 2 variables overtime- accounting for repeated measures

From   David Hoaglin <>
Subject   Re: st: Correlation between 2 variables overtime- accounting for repeated measures
Date   Sun, 17 Mar 2013 13:58:21 -0400


I would not focus on surgery.  That feature of the study was not part
of the initial question.  It emerged only in subsequent discussion.
The times are baseline, year 1, and year 2.  Unless the data suggest
it, I would not assume a time trend.  It would be appropriate to use
the constant term for baseline and have separate effects for year 1
and year 2.  If surgery has an effect, it will be reflected in the
effects for year 1 and year 2 (and confounded with them).

Formulating the analysis as regression does not reflect the idea that
x and y (initially a and b) are both dependent variables, and need to
be placed on an equal footing.  The question is the relation between x
and y, not the effect of x on y (unless Megan says that she is
interested in the effect of x on y).

The data are longitudinal, and it seems reasonable for a
random-effects model to give each participant a random intercept on x
and a random intercept on y (probably correlated).  In this
formulation, the model for each of x and y would have a constant term,
an effect for year 1, an effect for year 2, a random intercept for
each participant, and an error term.  I'm not sure whether the error
terms in the two models should be correlated.  I have not investigated
how one would fit such a model in Stata.

David Hoaglin

On Sun, Mar 17, 2013 at 11:22 AM, Robson Glasscock <> wrote:
> I am going to refer to a as y and b as x in this post.
> If I’m understanding you correctly, you want to estimate the
> relationship between y and x. You are not really interested in the
> relationship between y and the surgery, and you don’t think that the
> effect of x on y changed based on the surgery or over time.  I also
> know you said originally that you wanted the correlation, but I’m
> going to approach this using regression and a panel data setup. It
> also sounds like the jury is still out on whether the fixed effects
> transformation is appropriate for your research question.
> I think the following model with standard errors adjusted for
> correlation in the error term by individual (subject to the discussion
> below) is similar to what you are trying to estimate. Surg is a dummy
> variable equal to 1 in year 2 and year 3, else 0. Year_2 is a dummy
> variable equal to 1 in year 2, else 0. Year 3 is a dummy variable
> equal to 1 in year 3, else 0.
> y= B0 + B1(x) + B2(surg) + B3(year_2) + B4(year_3) + e
> This model estimates marginal effect of x on y and controls for the
> influences of both surgery and time. However, this model cannot be
> estimated because surg is a linear function of year_2 and year_3 (i.e.
> surg= year_2 + year_3).
> I think this leaves you with two options. The first is to treat the
> two post-surgery years as one period:
> y= Bo + B1(x) +B2(surg) + e
> I am less confident with the second option, but I think depending on
> your assumptions about how the distribution of y changes over time,
> that you can include a trend term in the model. The trend variable
> equals 1 in year 1, 2 in year 2, 3 in year 3.
> y= B0 + B1(x) + B2(surg) + B3(trend) + e
> I would like to hear from others if my reasoning is flawed on
> including the trend in the model.
> Lastly, depending on your assumptions about fixed effects, you could
> estimate the above models with
> -reg, cluster(individual)-
> or
> -xtreg, fe-
> best,
> Robson Glasscock

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index