Hi.
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.
[Variable]
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;
run;
[R code]
library(nlme)
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.