[R-sig-ME] lme4 observation level effects with indicator

Thierry Onkelinx thierry.onkelinx at inbo.be
Tue Apr 5 16:22:33 CEST 2016


Hi Tiffany,

The standard formula for a random slope is (slope | group). When slope is
numeric, the formula translate to b_i0 + b_i1*slope. b_i0 is the random
intercept for group i, b_i1 is its random slope.

(0 + slope | group) removes the intercept. In case of numeric slope this
sets all b_i0 = 0. Hence reducing the random effect to b_i1*slope.

In case of dummy coding slope is either 0 or 1. So (0 + PrePeriod|group) is
equivalent to b_i1 * 1 = b_i1 when Period == "Pre" and b_i1 * 0 = 0 when
Period != "Pre". Hence (0 + PrePeriod|group) is equivalent to a random
intercept for group when Period == "Pre".

When group is the finest level of grouping with only differences in period,
then (0 + PrePeriod|group) is an observation level random effect (OLRE) for
the observation with period == "Pre".

So (0 + PrePeriod|group)  + (0 + PostPeriod|group) gives two OLRE
conditional on period. Both random effects are independent and can have a
different variance.

(0 + period | group) will also estimate the covariance between the two
periodes. But that is probably to complex given the data.

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

2016-04-05 16:02 GMT+02:00 Tiffany Vidal <tiffany.vidal op gmail.com>:

> Hi Thierry,
>
> Thank you for the reply. Would you be able to explain what the 0 does (I
> have read the lme4 documentation, but it's not very clear to me), and why
> you would use the (0+ PrePeriod|...) for the site x year interaction term
> and not the other two random effects that should also vary by period? Would
> that coding be more appropriate for the year.factor and Site random effects
> too? Also, why does it work differently if I have a single factor column of
> 0s and 1s named 'period' and simply use (0+ period | Site:year.factor)?
>
> Thank you again!
> Tiffany
>
> On Tue, Apr 5, 2016 at 3:17 AM, Thierry Onkelinx <thierry.onkelinx op inbo.be
> > wrote:
>
>> Dear Tiffany,
>>
>> You could try to make dummy variables for each level of period.
>> dat$PrePeriod <- as.integer(dat$period == "Pre")
>> dat$PostPeriod <- as.integer(dat$period == "Post")
>>
>> mod.pois <- glmer( count ~ 1 + period + year  + year*period +
>> (period|year.factor) + (period|Site)  + (0 + PrePeriod|Site:year.factor)
>> + (0 + PostPeriod|Site:year.factor),
>>                         data=dat, family=poisson)
>>
>> 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
>>
>> 2016-04-02 21:23 GMT+02:00 Tiffany Vidal <tiffany.vidal op gmail.com>:
>>
>>> I am interested in estimating a mixed model with a random effect for
>>> year,
>>> site, and an observation-level effect to account for overdispersion,
>>> assuming Poisson error structure, using the lme4 package in R.
>>> Additionally, I have an indicator variable 'period' to adjust the
>>> parameter
>>> estimated by pre- and post- time periods. I am running into problems
>>> trying
>>> to specify the observation level effect by time period. I could model
>>> this
>>> using glmer.nb and avoid the observation-level effect, but I would like
>>> the
>>> flexibility to allow overdispersion to vary by time period as well. If
>>> there was a way to allow the negative binomial scaling parameter to vary
>>> by
>>> time period, I would probably use glmer.nb.
>>>
>>> My model as I'm trying to specify with glmer:
>>> mod.pois <- glmer( count ~ 1 + period + year  + year*period +
>>> (period|year.factor) + (period|Site) ,
>>>                         data=dat, family=poisson)
>>>
>>> The above runs and I think does what I want, but doesn't include the
>>> observation-level effect.
>>>
>>> I have tried:
>>> mod.pois <- glmer( count ~ 1 + period + year  + year*period +
>>> (period|year.factor) + (period|Site)  + (period|Site:year.factor),
>>>                         data=dat, family=poisson)
>>>
>>> but the error indicates identifiability issues. I have one observation at
>>> each site x year combination.
>>>
>>> Is there a way to achieve this using this package? Thank you in advance
>>> for
>>> any thoughts.
>>>
>>>         [[alternative HTML version deleted]]
>>>
>>> _______________________________________________
>>> R-sig-mixed-models op 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