[R-lang] Re: Random slopes
Alex Fine
afine@bcs.rochester.edu
Thu Dec 30 17:59:47 PST 2010
Zhenguang Cai wrote:
> Hi Alex,
>
> Thanks. Yes, I actually made mistakes in the script.
cool
> However, another question came up. In determining whehter to include
> the by-subject slope for the main effect of A (in a 2*2 design), shall
> I just compare two simple models with A as the predictor only, as in
> the following:
>
> model1 <- lmer (Y~A+(1|Subject)+(1|Item), data=dat, family=binomial)
> model2 <- lmer (Y~A+(A+1|Subject)+(1|Item), data=dat, family=binomial)
>
> or shall I do it between two full models, as the following:
>
> model1 <- lmer (Y~A*B+(1|Subject)+(1|Item), data=dat, family=binomial)
> model2 <- lmer (Y~A*B+(A+1|Subject)+(1|Item), data=dat, family=binomial)
if the model you're interested in working with is Y ~ A*B, then you'd
want to do the latter comparison. that way you're asking if a random
by-subject slope for A is justified for the model you're interested in
using to analyze your data. if you're doing stepwise regression and
adding one predictor at a time, then it's more complicated. but you
already said it's a 2x2 design, so it sounds like this isn't relevant.
right, everyone?
>
> Thanks,
>
> Garry
>
>
> 于 2010-12-30 23:42, Alex Fine 写道:
>> "A*B" denotes the two main effects A and B in addition to the
>> interaction between A and B. "A:B" is just the interaction.
>> in the code you provided, you called both models "model1". i assume this
>> was a mistake in your e-mail?
>> this is indeed the way you'd test to see if the by-subject random slope
>> for the interaction is justified, though. if you wanted the code to be a
>> little more transparent, you could change "A*B+1" to "A+B+A:B+1", just
>> to make it really clear that the models are a minimal pair.
>>
>> hope that helps,
>> alex
>>
>> Zhenguang Cai wrote:
>>> Hi all,
>>>
>>> I built the following models and did a comparison of them (to
>>> determine whether I should include in the model the subject slope for
>>> the interaction).
>>>
>>> model1 <- lmer (Y ~ A*B+(A+B+1|Subject)+(1|Item), data=dat,
>>> family=binomial)
>>> model1 <- lmer (Y ~ A*B+(A*B+1|Subject)+(1|Item), data=dat,
>>> family=binomial)
>>>
>>> In order to determine whehter the inclusion of the subject slope for
>>> the A*B interaction signficantly improves the model fit, I did a
>>> comparison of the the two models.
>>>
>>> anova (model1, model2)
>>>
>>> In the output, model1 was autmoatically changed into
>>>
>>> model1 <- lmer (Y ~ A*B+(A:B+1|Subject)+(1|Item), data=dat,
>>> family=binomial)
>>>
>>> What does the A:B mean here? In my original model, I intended to have
>>> the main effects of A and B (i.e., A+B). Is there any other way to
>>> determine whether the subject slope for the A*B interaction shold be
>>> included in the final model?
>>>
>>> Thanks,
>>>
>>> Zhenguang
>>>
>>
>
More information about the ling-r-lang-L
mailing list