Hello all, I am trying to teach myself R and replicate some previous SAS analysis. Could someone please help me translate the following SAS code into R. Proc mixed method=ml Class Group Treatment Stream Time Year; Model Logrpk=Treatment Time Treatment*Time; Random Group Stream (Group Treatment) Year(Time); Thank you to anyone that may help! -- View this message in context: http://r.789695.n4.nabble.com/Conveting-SAS-Proc-mixed-to-R-code-tp3450271p3450271.html Sent from the R help mailing list archive at Nabble.com.
> I am trying to teach myself R and replicate some previous SAS analysis. > Could someone please help me translate the following SAS code into R. > > Proc mixed method=ml > Class Group Treatment Stream Time Year; > Model Logrpk=Treatment Time Treatment*Time; > Random Group Stream (Group Treatment) Year(Time); >Assuming you have a data frame "dat" with these factors: Group Treatment Stream Time Year And continuous response: logrpk This code is a starting point: (I'm not sure exactly what the SAS syntax means). require(lme4) m1 = lmer(logrpk ~ treatment*time + (1|Group) + (1|Stream:Group:Treatment) + (1|Year:Time), data=dat) Kevin [[alternative HTML version deleted]]
I am desperate for help and thank you to everyone providing input. I am using lme4 for a mixed linear model, and trying to replicate a SAS analysis (see thread below). Variables: Dependent = logrkm; Independent = Group (Streams grouped by similarity), Treatment (3 treatments), Stream, Time (1 or 2; before treatment and after), Year (-8, -7,...7, 8; each yearly observation;negs before treatment and positive after). Design: Blocking by stream group results in unbalanced repeated measures with 3 treatments arranged in blocks with various numbers of observations (Streams) per treatment-block. Stream, Group, and Year are random variables and Treatment and Time are fixed effects. I have tried the following code, but can't seem to replicate the SAS results. Please correct the model below if you see where I am wrong, I am also open to other suggestions. m2<-lmer(logrkm~Treatment*Time+(Treatment|Stream:Group)+(1|Year),data=prototype) Thank you. -- View this message in context: http://r.789695.n4.nabble.com/Conveting-SAS-Proc-mixed-to-R-code-tp3450626p3452937.html Sent from the R help mailing list archive at Nabble.com.