Solved
Contributor
Posts: 22

# interaction of continuous and categorical variable in contrast/estimate statement

Hi All,

I’m working with some longitudinal binomial data in glimmix.   I’ve got 3 time points (0, 1, and 2 as values) and I have some subgroups that are of interest (6, to be exact, two of which are race/ethnicity of White and Black).  I have treated subgroup as a class variable, time as continuous.

I have crafted ESTIMATE statements that provide the estimate for subgroups at each time point (e.g. White at time 0, time 1…Black at time 0, time 1).   I’m also trying to estimate the difference between two points (e.g. say, between time 0 and time 1 for White students.  I’ve been able estimate differences between time, differences between subgroup (White in position 6, Black in position 1)…but I keep getting Non-Est for my interaction of subgroup*time.  I’ve been working from this resource:

https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_glimmix_a00...

Below are the estimate statements I have thus far...all but the last one appear to work as I expect.  Can someone kindly tell me what I’m missing (I must be in the weeds on this one)

proc glimmix data=cgr_sch method=rspl pconv=.001;

class school_code time_class subgroup;

model cgr_num/cgr_den=time subgroup  subgroup*time/link=logit dist=binomial solution ddfm=bw htype=1;

random intercept time/subject=school_code type=un g gcorr;

estimate 'white at time 0' intercept 1 time 0 subgroup 0 0 0 0 0 1 subgroup*time [1,0 6],

'white at time 1' intercept 1 time 1 subgroup 0 0 0 0 0 1 subgroup*time [1,1 6]/cl exp ilink e;

estimate 'diff 0 vs 1' time [-1,0] [1,1];

estimate 'diff white v black' subgroup [-1,1] [1,6]/e;

estimate 'diff 0 vs 1-white' subgroup*time [1,0 6] [-1,1 6]/e;

run;

Jason

Accepted Solutions
Solution
‎04-07-2016 05:47 AM
Contributor
Posts: 22

## Re: interaction of continuous and categorical variable in contrast/estimate statement

Hi All,

Finally got a solution from Susan Durham at Utah State.  Effectively, you have to subtract the code for time 0:

estimate intercept 1 subgroup [1, 6] time [1, 0] subgroup*time [1, 0 6];

and time 1:

estimate intercept 1 subgroup [1, 6] time [1, 1] subgroup*time [1, 1 6];

With some cancellation of intercept and subgroup, you get:

estimate 'diff 0 vs 1-white' time [1,1] [-1,0] subgroup*time [1,1 6] [-1,0 6];

All Replies
Occasional Contributor
Posts: 12

## Re: interaction of continuous and categorical variable in contrast/estimate statement

Try changing your model statement to this:

`model cgr_num/cgr_den= subgroup*time /link=logit dist=binomial solution ddfm=bw htype=1;`

Which may get your last Estimate statement to work, but will break the others.

Otherwise you willl need to specify the contrast values for time and subgroup, as well as time*subgroup.

Contributor
Posts: 22

## Re: interaction of continuous and categorical variable in contrast/estimate statement

Hi, thanks for the reply. I know I can re-parameterize the model and get the estimates directly. But I have other models where quadratics may come in to play. I'm wondering why, based on the hyperlink I included in the post, the way I have it coded won't work.

I have ESTIMATE statements like those that follow that give me the estimates for each time point, but I can't seem to get an estimate of the difference between, say time 0 and time 1 for White students:
estimate 'time 0-white' intercept 1 time 0 subgroup 0 0 0 0 0 1 time*subgroup 0 0 0 0 0 0 /cl exp ilink;
estimate 'time 1-white' intercept 1 time 1 subgroup 0 0 0 0 0 1 time*subgroup 0 0 0 0 0 1 /cl exp ilink;
estimate 'time 2-white' intercept 1 time 2 subgroup 0 0 0 0 0 1 time*subgroup 0 0 0 0 0 2 /cl exp ilink;

Occasional Contributor
Posts: 12

## Re: interaction of continuous and categorical variable in contrast/estimate statement

Not sure, but based on the example SAS may have parameterized Time as the last effect. Try this:

`estimate 'diff 0 vs 1-white' subgroup*time [1,6 0] [-1,6 0]/e;`

If you have just a few times, you can make Time a class effect and use LSMeans or LSEstimate / AT Time = 0.

This is sometimes useful with the /e option to show you the correct contract vector, which you can then plug into the Estimate statement.

Contributor
Posts: 22

## Re: interaction of continuous and categorical variable in contrast/estimate statement

I did try that too...SAS kicks an error: "The level 0 is not valid for CLASS variable subgroup."
I think the 'continuous' effect has to come first.
Occasional Contributor
Posts: 12

## Re: interaction of continuous and categorical variable in contrast/estimate statement

Some days I hate SAS. ;-)

I can't say why it's not working without seeing the parameterization (and maybe not even then), but I suspect the cause is there. I can't always get all the estimates I need from a single paramerterization, sometimes multiple passes at the model are needed.

You might try looking at the different parameterizations you get from:

subgroup*time

subgroup subgroup*time

subgroup|time
to see it that gives you any hints at what is missing.

Solution
‎04-07-2016 05:47 AM
Contributor
Posts: 22

## Re: interaction of continuous and categorical variable in contrast/estimate statement

Hi All,

Finally got a solution from Susan Durham at Utah State.  Effectively, you have to subtract the code for time 0:

estimate intercept 1 subgroup [1, 6] time [1, 0] subgroup*time [1, 0 6];

and time 1:

estimate intercept 1 subgroup [1, 6] time [1, 1] subgroup*time [1, 1 6];

With some cancellation of intercept and subgroup, you get:

estimate 'diff 0 vs 1-white' time [1,1] [-1,0] subgroup*time [1,1 6] [-1,0 6];

☑ This topic is solved.