0

I ask you, what is the corresponding code in R for this model with repeated measurements in SAS? In particular, how can I derive the estimate for each of the 5 visits?


ODS OUTPUT ESTIMATES=trtdiff;
PROC MIXED DATA=dataset ORDER=FORMATTED METHOD=reml;
CLASS subject trt visit strata1 strata2;
MODEL value = trt visit trt*visit strata1 strata2  / noint ddfm=KR solution ;
REPEATED visit /subject = subject type = TOEPH;
LSMEANS trt*visit / CL ;
/* EXAMPLE FOR THE MONTH X CORRESPONDING TO THE 3rd VISIT POST BASELINE
IN A DATASET CONTAINING A TOTAL OF 5 VISITS */
ESTIMATE "trt1 vs. trt2 at Month x" trt -1 1 trt*visit 0 0 -1 0 0 
                                                       0 0  1 0 0 / cl;
/* ESTIMATING THE OVERALL TREATMENT EFFECT */
LSMEANS trt / CL
ESTIMATE "trt1 vs. trt2 overall" trt -1 1 / cl;
run;

This is an example of how I did it in SAS for the third visit (out of 5)

ESTIMATE "trt1 vs. trt2 at Month x" trt -1 1 trt*visit 0 0 -1 0 0 
                                                       0 0  1 0 0 / cl;
SUBJECT VALUE   VISIT   TRT STRATA1 STRATA2
1          1      1        1     A       Y
1         -5      2        1     A       Y
1          1      3        1     A       Y
1          2      4        1     A       Y
1          0      5        1     A       Y 
2          7      1        2     C       Y
2         -5      2        2     C       Y
2          3      3        2     C       Y
2         -3      4        2     C       Y
2          1      5        2     C       Y
3         19      1        2     A       N
3          4      2        2     A       N
3         -1      3        2     A       N
3          7      4        2     A       N
4          4      1        1     B       Y
4         -1      2        1     B       Y
4          3      3        1     B       Y
4          4      4        1     B       Y
4         12      5        1     B       Y

Bibi
  • 19
  • 4
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Just asking for code translation is [off-topic](https://meta.stackoverflow.com/questions/296119/is-how-do-i-convert-code-from-this-language-to-this-language-too-broad). Say what the code needs to do and describe where exactly you are getting stuck during your translation. – MrFlick Jan 23 '23 at 15:58
  • I have added a dataset similar to mine, I would like to obtain LS Mean (SE) and 95% CI for each visit and each treatment – Bibi Jan 23 '23 at 16:45

0 Answers0