[R-sig-ME] Mixed linear model with nested and interaction term
Steve Denham
@tevedrd @ending from y@hoo@com
Tue May 8 11:42:27 CEST 2018
The point of the REML method is that there are no sums of squares for the covariance effects. In fact, there are no sums of squares for any of the effects. Type III calculates covariance parameters using method of moments, while REML uses restricted maximum likelihood.
Steve Denham Senior Director, Bioinformatics Sciences MPI Research, Inc.
On Monday, May 7, 2018, 3:41:37 PM EDT, Lin, Heng-An <henganl2 at illinois.edu> wrote:
Hi,
When I using SAS with default REML, it won't display the sum of square.
It only shows covariance parameter estimates for random effect, for the fixed effect, it still using Type 3.
I am trying using the code below in r to see the difference with smaller and balanced data set anova(model_MW, ddf="Kenward-Roger")anova(model_MW, type=3)anova(model_MW, type=3, ddf="Kenward-Roger")
here is what I got in R
> anova(model_Test, type="3", ddf="Kenward-Roger")Type III Analysis of Variance Table with Kenward-Roger's method Sum Sq Mean Sq NumDF DenDF F value Pr(>F)Treatment 60.219 15.055 4 4 0.8347 0.5674
and in SAS (with type3 and KR method) df Sum Sq F value p-value Treatment 4 78.9246 0.81 0.5801
They seems more similar for F and P value, but the Sum sq still different...not sure why Sorry for sending repeating email.
Thanks for your time again. 從: Steve Denham [stevedrd at yahoo.com]
寄件日期: 2018年5月7日 上午 06:14
至: Ben Bolker; Lin, Heng-An
副本: r-sig-mixed-models at r-project.org
主旨: Re: [R-sig-ME] Mixed linear model with nested and interaction term
Hi Heng-An,
What do you get when you let SAS use the default REML method (i.e. remove the method=type3 statement)? I suspect that it is much closer to the R results, and would be what most SAS modelers would consider more appropriate for this design.
Steve Denham Senior Director, Bioinformatics Sciences MPI Research, Inc.
On Friday, May 4, 2018, 4:16:04 PM EDT, Lin, Heng-An <henganl2 at illinois.edu> wrote:
** Sorry I didn't notice that the format of the previous email was off, so I just send the same email again
Here is my SAS syntax and output :
proc mixed data=A method=type3; class Location Block Treatment;
model Yield= Treatment/ddfm=kr;
random Location Location*Treatment Block(Location);
run;quit;
Source Df Sum_of_squares F_value
Treatment 4 46.196951 0.41
Location 2 4670.0979652 44.74
Location*Treatment 8 224.44332 1.66
Block (Location) 9 369.782487 2.43
Residual 34 574.051330
And here is R output:
> anova(model_MW)
Analysis of Variance Table
Df Sum Sq Mean Sq F value
Treatment 4 34.847 8.7118 0.5085
I am not sure why the sum of square, and the F- value are different.
Maybe is because I use type III in SAS and in lmer is using REML?
I would also like to check the sum of square of other factors as SAS did, is there any way could do this in lmer?
I am really new to this, Thanks for your time!
Heng-An
________________________________________
從: R-sig-mixed-models [r-sig-mixed-models-bounces at r-project.org] 代表 Lin, Heng-An [henganl2 at illinois.edu]
寄件日期: 2018年5月4日 下午 02:36
至: Ben Bolker
副本: r-sig-mixed-models at r-project.org
主旨: Re: [R-sig-ME] Mixed linear model with nested and interaction term
Thanks!!
Here is my SAS syntax and output :
proc mixed data=A method=type3; class Location Block Treatment;
model Yield= Treatment/ddfm=kr;
random Location Location*Treatment Block(Location);
run;quit;
Source
DF
Sum of Squares
Mean Square
Error DF
F Value
Pr > F
Treatment
4
46.196951
11.549238
8.0509
0.41
0.7954
Location
2
4670.979652
2335.489826
9.2885
44.74
<.0001
Location*Treatment
8
224.443332
28.055417
34
1.66
0.1442
Block(Location)
9
369.782487
41.086943
34
2.43
0.0295
Residual
34
574.051330
16.883863
.
.
.
And here is R output:
> anova(model_MW)
Analysis of Variance Table
Df Sum Sq Mean Sq F value
Treatment 4 34.847 8.7118 0.5085
I am not sure why the sum of square, and the F- value are different.
Maybe is because I use type III in SAS and in lmer is using REML?
I would also like to check the sum of square of other factors as SAS did, is there any way could do this in lmer?
[[elided Yahoo spam]]
Heng-An
________________________________________
�q: Ben Bolker [bbolker at gmail.com]
�H����: 2018�~5��4�� �U�� 01:39
��: Lin, Heng-An
�ƥ�: r-sig-mixed-models at r-project.org
�D��: Re: [R-sig-ME] Mixed linear model with nested and interaction term
This seems like a reasonable model specification. Can you show us
the results you're getting from R and SAS, and your SAS syntax (some
people here understand that language), so that we can see what looks
different? (It would help if you also wrote a few sentences about
what you see as the important differences between the results.)
On Fri, May 4, 2018 at 2:30 PM, Lin, Heng-An <henganl2 at illinois.edu> wrote:
> Hi all,
>
> I am analyzing my data with following model,
>
> model1 <- lmer(Yield~Treatment+(1|Location)+(1|Location:Treatment)+(1|Location:Block), data=A)
>
> in here, I want to set an random interaction term (Location*treatment) and an random nested term (block nested within location).
>
> But I couldn't get similar ANOVA results when I compare the output with SAS porc mixed output.
>
> So, I think i might make some mistake in the model in R...
>
> Can anyone give me some suggestion?
>
> Thanks in advance!
>
> Heng-An
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
[[alternative HTML version deleted]]
_______________________________________________
R-sig-mixed-models at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list