Pyrite | Level 9

## Compare two slopes

Hi.

I have the following situation:

The data:

there is onset of disease information (visit -2  -varies for each id)

Enrollment date (visit 0 -- varies for each id)

Follow-up visits (visit 1,2,3,4....so on, varies per ID)

marker of disease (my Y)

End of Study

So far we have done analyses using visit 0 (enrollment) to last visit.

We were able to find the slope (or rate of disease progression) using OLS:

proc reg data = my_data;

by id;

model marker_of_disease = time;

ods output ParameterEstimates = estimates;

run;

Some data manipulation and eventually we get a slope (rate) for each subject.

(Then we use that slope to do other things).

OK, now, it has been of interest to check if there is a significant difference between the slope (rate of disease progression) from onset of disease to enrollment (visit -2 to 0 ) versus the slope from enrollment to...the end.

|

|          *

|            \   y_hat = intercept + b0*time

|              \

|               0

|                 \

|                   \     y1_hat = intercept + b1*time

|                     \

__________________________________________________Time

-2      0    1    2    3    4     5

One way I solved this:

proc reg data = my_data;

where visit in (-2,0);

model y = time;

output estimates1;

run;

Then

proc reg data = my_data;

where visit>= 0

model y = time;

output estimates2;

run;

do some cleaning and manipulation and then do a t-test for differences in the slopes.

(I am not sure if this is right)

However, I may be able to implement

proc mixed data = my_data;

class id;

model y = time group time*group/s;

random int time/subject =id;

run;

Where group is an indicator of time -2 to 0, vs time >= 0.

My issue is how do I handle the 0 (enrollment visit) since it contributes to both groups, so to speak?

Do I create a duplicate record...which seems fishy...

Is it the t-test fine/similar for such analysis?

Any suggestions would be greatly appreciated.

Thanks!

Cheers!

4 REPLIES 4
Diamond | Level 26

## Re: Compare two slopes

```However, I may be able to implement
proc mixed data = my_data;
class id;
model y = time group time*group/s;
random int time/subject =id;
run;
Where group is an indicator of time -2 to 0, vs time >= 0.
My issue is how do I handle the 0 (enrollment visit) since it contributes to both groups, so to speak?
Do I create a duplicate record...which seems fishy...
Is it the t-test fine/similar for such analysis?
```

It's not clear why you even need to handle the 0, if your group variable is created properly. (Not sure why you need PROC MIXED here, instead of OLS which you were using, but that's another issue)

You probably can get the answer via

PROC GLM data=my_data;

class group;

model y=time group time*group;

run;

The F-test for time*group is the comparison of the slopes.

--
Paige Miller
Pyrite | Level 9

## Re: Compare two slopes

Sure, understood.

Do I code group like this?

ID Visit Date           Y     Group

1  -2   Sept1999     34        1

1  0  Oct2000     40          1

1  1   Jan2001     50         0

1  2   August2001    32     0

OR:

ID Visit Date           Y     Group

1  -2   Sept1999     34        1

1  0  Oct2000     40          1

1  0  Oct2000     40          0

1  1   Jan2001     50         0

1  2   August2001    32     0

OR like this:

ID Visit Date           Y     Group

1  -2   Sept1999     34        1

1  0  Oct2000     40          0

1  1   Jan2001     50         0

1  2   August2001    32     0

Thanks!

Diamond | Level 26

## Re: Compare two slopes

If the grouping you used in PROC REG worked for you, then that's the same grouping you would use in my example. It seems to be the middle of your three examples.

--
Paige Miller
Pyrite | Level 9

## Re: Compare two slopes

Thank you, Mr. Paige.

I did not have a group vairable int he first proc reg, because we were only interested in the individual slopes so:

proc reg;

by id;

model y = time;

run;

was sufficient.

Trying to assess for difference in slope, I implemented using proc glm by adding a duplicate of the enrollment record (Just like I explained in the second scenario) and I get the interaction p-value and I am all set.

I wasn't sure if by manipulating the enrollment row, I am "artificially" doing something or other.

(limited understanding, obviously)

Thanks!

Cheers!

Discussion stats
• 4 replies
• 3145 views
• 6 likes
• 2 in conversation