New Contributor
Posts: 4

# Estimate interaction effect with splines

I have a model with a third order interaction with splines:

class trt sex;

effect spl = spline(age);

model aval = trt|sex|spl

I am looking for a way to get an estimate for the trt*sex interaction effect at specific values for age.

I managed to get an estimate for the effect of either trt or sex at a specific value for age with for instance:

estimate 'Diff trt at sex 1 x= 20' trtn [1,1] [-1,2] trtn*sex [1,1 1] [-1,2 1] trt*spl [1,1 20] [-1,2 20]  trt*sex*spl[1,1 1 20] [-1,2 1 20] /e;

but fail at producing an estimate for the interaction effect.

Help much appreciated!

KR Sophie

Posts: 2,655

## Re: Estimate interaction effect with splines

Have you tried using an LSMESTIMATE statement with the AT option?

For two treatments and two sexes, it would look like:

lsmestimate trt*sex*spl 'Trt diff for sex=1 at age = 20' 1 0 -1 0/at age=20;

and if you have multiple comparisons, more like;

lsmestimate trt*sex*spl 'Trt diff for sex=1 at age = 20' 1 0 -1 0,

'Trt diff for sex=2 at age = 20' 0 1 0 -1/at age=20;

Of course, nonpositional syntax shuch as you have can also be used, but the advantage is in comparing the lsmeans at a given level.

Steve Denham

New Contributor
Posts: 4

## Re: Estimate interaction effect with splines

Dear Steve,

Many thanks for your responds. Actually I had tried something like this but all my attempts gave the message

ERROR: The constructed effect spl*trtn*SEXN is not a valid LSMESTIMATE effect.

I have two treatments and two sexes so I just tried exactly the code you provided and got the same error message again.

Kind regards, Sophie

Posts: 2,655

## Re: Estimate interaction effect with splines

Have you tried:

lsmestimate trt*sex 'Trt diff for sex=1 at age = 20' 1 0 -1 0,

'Trt diff for sex=2 at age = 20' 0 1 0 -1/at age=20;

It appears that you cannot use the constructed effect (or its interactions) in the LSMEANS or LSMESTIMATE statement.  But you might be able to look at the trt*sex interaction, and see what the effect is at various ages by using the AT option.  I am trying to generalize from the documentation--Details: GLIMMIX Procedure> Parameterization of Generalized Linear Mixed Models> Notes on the EFFECT Statement.

Steve Denham

New Contributor
Posts: 4

## Re: Estimate interaction effect with splines

Dear Steve,

Many thanks for trying to help me. But I still have not what I need because my interest is in the estimate and se for the difference in difference. The extent that the “trt diff for sex = 1” is different from the “trt diff for sex=2” at specific ages. I was already able to get an estimate for the effect of either trt or sex at a specific value for age with for instance:

estimate 'Diff trt at sex 1 x= 20' trtn [1,1] [-1,2] trtn*sex [1,1 1] [-1,2 1] trt*spl [1,1 20] [-1,2 20]  trt*sex*spl[1,1 1 20] [-1,2 1 20] /e;

lsmestimate trt*sex 'Trt diff for sex=1 at age = 20' 1 0 -1 0;

works as well

(even though this one fails:

lsmestimate trt*sex 'Trt diff for sex=1 at age = 20' 1 0 -1 0,

'Trt diff for sex=2 at age = 20' 0 1 0 -1/at age=20

but what I need is the contrast of 'Trt diff for sex=1 at age = 20' versus 'Trt diff for sex=2 at age = 20’.

Kind regards,

Sophie

Posts: 2,655

## Re: Estimate interaction effect with splines

Difference of the differences would be:

lsmestimate trt*sex "Differences between sexes for treatment differences at age = 20' 1 -1 -1 1/at age=20;

Note that this is the first line minus the second line of the previous lsmestimate statement.

Good luck.

Steve Denham

New Contributor
Posts: 4