[R-sig-ME] [R] Proc Mixed variance of random effects in R

Thierry Onkelinx thierry.onkelinx at inbo.be
Thu Jun 18 09:54:50 CEST 2015


Dear Gram,

A few things first: Please don't post in HTML, it mangles your text.
R-sig-mixed model is a better list for questions on mixed models. Send
further replies only to that list and not to r-help.

You are probably not fitting the same model in R as the one in SAS. Please
provide the equations of the SAS model and then you can help you translate
that into R code. You are assuming that we all speak SAS, but this is an R
mailing list. The lingua franca among statistical software is mathematics.

Best regards,


ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2015-06-17 19:52 GMT+02:00 Grams Robins <grams_robins op yahoo.com>:

> Hi, I'm trying to convert the following SAS code in R to get the same
> result that I get from SAS. Here is the SAS code:
>     DATA plants;
>     INPUT  sample $  treatmt $ y ;
>     cards;
>
>     1   trt1    6.426264755
>     1   trt1    6.95419631
>     1   trt1    6.64385619
>     1   trt2    7.348728154
>     1   trt2    6.247927513
>     1   trt2    6.491853096
>     2   trt1    2.807354922
>     2   trt1    2.584962501
>     2   trt1    3.584962501
>     2   trt2    3.906890596
>     2   trt2    3
>     2   trt2    3.459431619
>     3   trt1    2
>     3   trt1    4.321928095
>     3   trt1    3.459431619
>     3   trt2    3.807354922
>     3   trt2    3
>     3   trt2    2.807354922
>     4   trt1    0
>     4   trt1    0
>     4   trt1    0
>     4   trt2    0
>     4   trt2    0
>     4   trt2    0
>     ;
>     RUN;
>
>     PROC MIXED ASYCOV NOBOUND  DATA=plants ALPHA=0.05 method=ML;
>     CLASS sample treatmt;
>     MODEL  y = treatmt ;
>     RANDOM int treatmt/ subject=sample ;
>     RUN; I get the following covariance estimates from SAS:Intercept
> sample ==> 5.5795treatmt sample ==> -0.08455Residual ==> 0.3181I tried the
> following in R, but I get different results.   options(contrasts = c(factor
> = "contr.SAS", ordered = "contr.poly"))
>     df$sample=as.factor(df$sample)
>     lmer(y~ 1+treatmt+(1+treatmt|sample),REML=FALSE, data = df) Since the
> results from R are standard deviations, I have to square all results to get
> the variances.    sample==> 2.357412^2 = 5.557391
>     sample*treatmt==>0.004977^2 = 2.477053e-05
>     residual==>0.517094^2 = 0.2673862As shown above, the results from SAS
> and R are different. Do you know how to get the exact values in R?I
> appreciate any help.Thanks,Gram
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help op r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

	[[alternative HTML version deleted]]



More information about the R-sig-mixed-models mailing list