[R-sig-ME] Adding random subject or item slopes for a specific contrast
Thierry Onkelinx
thierry@onkelinx @ending from inbo@be
Thu Nov 22 11:55:25 CET 2018
Dear Dave,
I strongly suggest that you write down the equation of the model with a
random slope for each factor level and the equation of the model you have
in mind. That would allow you to see which coefficients need to be zero.
Best regards,
ir. Thierry Onkelinx
Statisticus / Statistician
Vlaamse Overheid / Government of Flanders
INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
FOREST
Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
thierry.onkelinx using inbo.be
Havenlaan 88 bus 73, 1000 Brussel
www.inbo.be
///////////////////////////////////////////////////////////////////////////////////////////
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
///////////////////////////////////////////////////////////////////////////////////////////
<https://www.inbo.be>
Op ma 19 nov. 2018 om 21:03 schreef David Sidhu <dsidhu using ucalgary.ca>:
> Hi Thierry
>
> Thank you very much for the reply, and apologies for the troubling code.
>
> I have two follow up questions:
>
> 1) Suppose IV is a three level factor. Would I still use this variable for
> the fixed effects, but then create a dummy variable reflecting the random
> slope that I want to include? I assume this works out the same as creating
> a pair of dummy variables to use for fixed effects, and then using one for
> the random slope.
>
> 2) Is it advisable to do this? I.e., to only include the slope for a
> single contrast. Or, is this problematic statistically.
>
> Thanks very much.
>
> Dave
>
> ---
> David M. Sidhu, MSc
> PhD Candidate
> Department of Psychology
> University of Calgary
>
>
>
>
>
>
> On Nov 19, 2018, at 1:54 AM, Thierry Onkelinx <thierry.onkelinx using inbo.be>
> wrote:
>
> Dear David,
>
> I think you can solve this by creating a dummy variable which has zero's
> in case you are not interested in the random slope.
>
> Please note that sending HTML has ruined the code formating, making your
> code much harder to read.
>
> Best regards,
>
> ir. Thierry Onkelinx
> Statisticus / Statistician
>
> Vlaamse Overheid / Government of Flanders
> INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
> FOREST
> Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
> thierry.onkelinx using inbo.be
> Havenlaan 88 bus 73, 1000 Brussel
> www.inbo.be
>
>
> ///////////////////////////////////////////////////////////////////////////////////////////
> 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
>
> ///////////////////////////////////////////////////////////////////////////////////////////
>
> <https://www.inbo.be/>
>
>
> Op do 8 nov. 2018 om 16:55 schreef David Sidhu <dsidhu using ucalgary.ca>:
>
>> Hi There
>>
>> I have been following the approach described in Bates et al. (2018) to
>> simplify my random effects structure. I will use the data pasted below as
>> an example (though the effects I describe aren’t present there, I use it
>> only to have an example to refer to).
>>
>> Now, if it seems that there is variance in the random subject slope
>> comparing IV1 level 2 vs. IV1 level 1, but in no other contrast’s random
>> subject slope, I would like to only include a random subject slope for that
>> one specific contrast. Also assume that the method described by Bates et
>> al. (2018) suggests that the random effects structure should only have one
>> component.
>>
>> Two questions: Is it sensible to only include this one slope? Is it
>> possible in lme4 to only include this one slope?
>>
>> Thanks!
>> Dave
>>
>>
>>
>>
>>
>> Subj <- rep(1:10, each = 10) Item <- rep(1:10, times = 10) IV1 <-
>> rep(1:5, times = 20) DV <- rnorm(100) library(data.table) data <-
>> as.data.table(cbind(Subj, Item, IV1, DV)) data$Subj <- as.factor(data$Subj)
>> data$Item <- as.factor(data$Item) data$IV1 <- as.factor(data$IV1)
>> library(MASS) contrasts(data$IV1) <- contr.sdif(5) library(lme4) m <-
>> lmer(DV ~ IV1 + (1 + IV1|Subj) + (1|Item), data = data)
>>
>>
>>
>>
>> ---
>> David M. Sidhu, MSc
>> PhD Candidate
>> Department of Psychology
>> University of Calgary
>>
>>
>>
>>
>>
>>
>>
>> [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-mixed-models using 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