Proc mixed in SAS vs. R (Additional questions)

I am trying to reproduce output from the PROC MIXED procedure using R.

But SAS result and R result are so different.

There are variables, SAS code and R code below.


Y : Numeric

Year: Numeric (2017, 2018) but want to analyze as a categorical variable

Level: Numeric (1, 2) but want to analyze as a categorical variable

[SAS code]

data m (keep=country y year level) ; set m2;

y=_8_4q ; year=2017; output m;

y=_0_2q; year=2018; output m; run;

proc mixed data=m;
class level y country;
model y = level|year;
repeated / type=ar(1) sub=country;

[R code]
gls(y ~ level*year, correlation = corAR1(form = ~ 1 | Country), weights = varIdent(form = ~ 1 | year), data=data, method = "REML")

Please give me advice on how to change the R code to similar values to SAS results.
And how do I change the level and year as the categorical variable in R?

Thank you in advance.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.