[R-sig-ME] Mixed linear model with nested and interaction term
@@muel@kn@pp @ending from tum@de
Mon May 7 22:53:39 CEST 2018
it is good practice to reply also to the mailing list in Cc.
Is this dataset fully balanced now? What is the number of levels of each
of the factors and what is the number of total observations now?
Why is the SAS ANOVA now only containing the fixed effect, while before
it also contained the random effects? Did you change any other model
It is really strange, that the estimates differ.
Could you please report also the estimated variances? See summary(model)
in R and the beginning of the SAS output. It should be 4 variances (one
for each random effecct and the residual variance).
One more thing, will you get same results for Satterthwaite ddf?
On 07/05/18 21:42, Lin, Heng-An wrote:
> Hi Samuel,
> Thanks for the suggestion, that's really helpful.
> so I tried to use the code below in r to see the difference with smaller and balanced data set
> 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.
> 從: Samuel Knapp [samuel.knapp at tum.de]
> 寄件日期: 2018年5月7日 上午 03:39
> 至: Lin, Heng-An
> 副本: r-sig-mixed-models-request at r-project.org
> 主旨: Re: [R-sig-ME] Mixed linear model with nested and interaction term
> Hi Heng-An,
> The SAS model specification seems to be in accordance with the lmer
> model. However, I'm slightly surprised, that the SAS ANOVA also contains
> the random effects.
> Looking at the degrees of freedom, I get the impression that your data
> is not fully orthogonal, e.g. that you don't have the same number of
> reps at each location or some missing values. If you dont't have fully
> orthogonal and balanced data (i.e. n obs = n treatments * n locations *
> n replications), there could be differences between different SS methods
> (Type 1, 2 or 3) or df methods (Kenward-Roger, Satterthwaite).
> In order to test that, you could
> 1) create an orthogonal and balanced subset of your data and compare
> 2) Test other df methods in R with the lmerTest package
> anova(model_MW, ddf="Satterthwaite")
> # or
> anova(model_MW, ddf="Kenward-Roger")
> 3) Test other SS methods in R, also implemented now in the lmerTest package
> anova(model_MW, type =1) # or type=2 or type=3
> 4) Test the same settings in SAS using the method statement in the proc
> mixed call, and the ddfm statement in the model line.
> Additionally, to just simply playing around, also get familiar with the
> different concepts (The SAS documentation on proc mixed has quite a good
> overview). This shall rather be an overview on how to specify different
> I'd be interested, if you get similar results....
> Best regards,
> On 04/05/18 22:15, r-sig-mixed-models-request at r-project.org wrote:
>> Date: Fri, 4 May 2018 20:15:30 +0000
>> From: "Lin, Heng-An" <henganl2 at illinois.edu>
>> To: Ben Bolker <bbolker at gmail.com>
>> Cc: "r-sig-mixed-models at r-project.org"
>> <r-sig-mixed-models at r-project.org>
>> Subject: Re: [R-sig-ME] Mixed linear model with nested and interaction
>> <14FC5E11B32FB84FB0D08FE2F4127AFE2B53751C at CHIMBX6.ad.uillinois.edu>
>> Content-Type: text/plain; charset="utf-8"
>> ** 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);
>> 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:
>> 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!
>> �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!
>>> [[alternative HTML version deleted]]
>>> R-sig-mixed-models at r-project.org mailing list
>> [[alternative HTML version deleted]]
>> Subject: Digest Footer
>> R-sig-mixed-models mailing list
>> R-sig-mixed-models at r-project.org
>> End of R-sig-mixed-models Digest, Vol 137, Issue 6
More information about the R-sig-mixed-models