BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
plf515
Lapis Lazuli | Level 10

I have data on approximately 50 people who were treated for drug abuse with a novel treatment.  At baseline and at 5 equally spaced follow ups, they were evaluated for various problems on continuous scales.  I want to test the hypothesis that there was an improvement from baseline to 3 months and then no retreat from that improvement.

 

I know I can do equivalence testing on pairs of follow up points, but I am thinking of some sort of spline effect in MIXED or GLIMMIX. But I haven't quite figured out how to code it.

 

Any hints appreciated.

 

Using SAS 9.4.

1 ACCEPTED SOLUTION

Accepted Solutions
JacobSimonsen
Barite | Level 11

What a funny question. I think I have a kind of solution, but its not perfect.

 

I suggest to make a model with a natural cubic spline. In the second model I suggest making a variable that is minimum of time and 3, and then make a natural cubic spline on that one. Then test from the first model to the second model. It is not perfect, because the second model has a non-differentiabable point at time=3. So it is neccessary to allow the same in the first model if the second model should be contained in the first model.

Secondly, it is very difficult to test that the change in the interval from 0 to 3 should be positive (improvement). The method here only test that there is a spline up to time=3, and constant for time>3.

 

 

Here is the code:

 


  data mydata;
    do i=1 to 500;
	  time=6*ranuni(-1);
  time2=min(time,3);
	  effekt=mod(i,2);
	  y=2+time+rannor(-1);
	  output;
	end;
run;

*The test is seen it the type3 tests;
proc glimmix data=mydata;
  effect spline1 = spline(time / NATURALCUBIC  knotmethod=list(0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5) );
  effect spline2 = spline(time2 / NATURALCUBIC  knotmethod=list(0.5,1,1.5,2,2.5) );
  model y=effekt effekt*spline1 effekt*spline2 /dist=normal ;
  store out=model1;
run;
proc glimmix data=mydata;
  effect spline2 = spline(time2 / NATURALCUBIC  knotmethod=list(0.5,1,1.5,2,2.5) );
  model y=effekt  effekt*spline2 /dist=normal ;
  store out=model2;
run;


data template;
  do effekt=0 to 1;
    do time=0 to 6 by 0.01;
  time2=min(time,3);

	output;
	end;
  end;
ruN;
proc plm restore=model1;
  score data=template out=pred1;
run;
proc plm restore=model2;
  score data=template out=pred2;
run;

data pred;
  merge pred1(rename=(predicted=pred1)) pred2(rename=(predicted=pred2));
  by effekt time;
run;
symbol1 c=black i=none v=dot;
symbol2 c=red i=none v=dot;
proc gplot data=pred(where=(effekt));
  plot (pred1 pred2 )*time/overlay;
run;

 

and here is the figure:predict.JPG

 

View solution in original post

3 REPLIES 3
JacobSimonsen
Barite | Level 11

What a funny question. I think I have a kind of solution, but its not perfect.

 

I suggest to make a model with a natural cubic spline. In the second model I suggest making a variable that is minimum of time and 3, and then make a natural cubic spline on that one. Then test from the first model to the second model. It is not perfect, because the second model has a non-differentiabable point at time=3. So it is neccessary to allow the same in the first model if the second model should be contained in the first model.

Secondly, it is very difficult to test that the change in the interval from 0 to 3 should be positive (improvement). The method here only test that there is a spline up to time=3, and constant for time>3.

 

 

Here is the code:

 


  data mydata;
    do i=1 to 500;
	  time=6*ranuni(-1);
  time2=min(time,3);
	  effekt=mod(i,2);
	  y=2+time+rannor(-1);
	  output;
	end;
run;

*The test is seen it the type3 tests;
proc glimmix data=mydata;
  effect spline1 = spline(time / NATURALCUBIC  knotmethod=list(0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5) );
  effect spline2 = spline(time2 / NATURALCUBIC  knotmethod=list(0.5,1,1.5,2,2.5) );
  model y=effekt effekt*spline1 effekt*spline2 /dist=normal ;
  store out=model1;
run;
proc glimmix data=mydata;
  effect spline2 = spline(time2 / NATURALCUBIC  knotmethod=list(0.5,1,1.5,2,2.5) );
  model y=effekt  effekt*spline2 /dist=normal ;
  store out=model2;
run;


data template;
  do effekt=0 to 1;
    do time=0 to 6 by 0.01;
  time2=min(time,3);

	output;
	end;
  end;
ruN;
proc plm restore=model1;
  score data=template out=pred1;
run;
proc plm restore=model2;
  score data=template out=pred2;
run;

data pred;
  merge pred1(rename=(predicted=pred1)) pred2(rename=(predicted=pred2));
  by effekt time;
run;
symbol1 c=black i=none v=dot;
symbol2 c=red i=none v=dot;
proc gplot data=pred(where=(effekt));
  plot (pred1 pred2 )*time/overlay;
run;

 

and here is the figure:predict.JPG

 

plf515
Lapis Lazuli | Level 10

Thanks!  That looks like a good approach

SteveDenham
Jade | Level 19

I really like Jacob's approach.

 

Here is something a little simpler, along the lines of a Helmert contrast.  You do have to expand this out, as I have only put in the time coefficients, so this would be for the first treatment arm:

 

LSMESTIMATE time*treatment 'pre vs all follow' -5 1 1 1 1 1 divisor 5,
                                                  'time 1 vs follow' 0 -4 1 1 1 1 divisor 4,
                                                  'time 2 vs follow' 0 0 -3 1 1 1 divisor 3,
                                                  'time 3 vs follow' 0 0 0 -2 1 1 divisor 2,
                                                  'time 4 vs follow' 0 0 0 0 -1 1/joint;

Additional arms, and comparisons between them follow from this.

 

Steve Denham

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1571 views
  • 5 likes
  • 3 in conversation