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, statalist.org is already up and running.

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

 From Robson Glasscock To statalist@hsphsun2.harvard.edu Subject Re: st: Correlation between 2 variables overtime- accounting for repeated measures Date Sun, 17 Mar 2013 11:22:32 -0400

```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

On Sat, Mar 16, 2013 at 7:46 PM, JVerkuilen (Gmail)
<jvverkuilen@gmail.com> wrote:
> On Sat, Mar 16, 2013 at 6:49 PM, megan rossi <megan_rossi@msn.com> wrote:
>> Yes The surgery was 1-3weeks after the baselines were taken...a fairly strict protocol. Then one year follow up and two year follow up...variable a &b were both low at baseline (still detectable and possibly correlated) but rise following surgery so are high at year 1 and year 2...perhaps best to just combine year 1 and 2 as if they're both high a correlation would be easier to find then if they're both low?
>>
>
> I don't think I'd combine them. You have different measures and that
> should be respected.
>
> To me the fact that this is longitudinal means that there's a clear
> logical priority. I'd consider the first measurement as "causal" of
> the second one, at least in some respect. So I'm not sure a pure
> correlation makes sense. But I'd like to hear what others might say.
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```