# Can we fit a mixed model with separate covariance matrix for each treatment group in R?

Here is the SAS proc mixed model procedure. I wonder how I can fit the same model in R with separate within-subject variance/covariance matrices for each treatment arm.

proc mixed data=cRMData method=reml;

class time subj;

model y=time2 arm arm*time2/ddfm=kenwardroger solution;


repeated time/subject=subj type=un group=arm rcorr;

run;

I tried this in R but it does not give me different covariance matrices

mixed.model<-gls(y~time2+arm:time2,data=cRM,
correlation=corSymm(form = ~ 1 | subj),
weights=varIdent(form=~1|arm),
method="REML")