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