Re: [R] Conveting SAS Proc mixed to R code

From: Ben Bolker <bbolker_at_gmail.com>
Date: Fri, 15 Apr 2011 13:45:20 +0000

Kevin Wright <kw.stat <at> gmail.com> writes:

>
> > 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)
>

  Can I please suggest that (Treatment|Stream:Group) or something like it is more appropriate than (1|Stream:Group:Treatment)? In general, what goes on the LEFT of the bar is an intercept or fixed effect (i.e. something that varies between groups); what goes on the RIGHT of the bar is a grouping variable. Thus if a fixed effect terms ends up on the right of the bar, something funny is going on.

  Ben Bolker



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 15 Apr 2011 - 13:47:28 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 16 Apr 2011 - 14:30:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive