Dear Simone,
Glad that was useful, and yes everything you say sounds right to me. For p
values, my understanding is that LRTs are fine, however. Or you could also
use a bootstrap, or MCMC.
As for autocorrelation, sorry, I hadn't been thinking through the
implications of your having a binary outcome variable. And I had been under
the impression that nlme could fit logit models, but a quick investigation
around the web suggests I was wrong about that. (If anyone knows otherwise,
please correct me/us.)
I am not an expert on dealing with autocorrelation in the case of binary
outcomes. Someone else may have advice about that, however.
Best wishes,
Malcolm
On 16 November 2015 at 16:07, Simone <miseno77 at hotmail.com> wrote:
Dear Malcolm,
Thank you so much for your detailed (very interesting references!) and
helpful answer. I have centered Var2 by IND and I have used both the
individual-specific mean Var2 (Var2meanIND) as well as the
individual-specific centered Var2 (Var2varIND). I understand that this
I can test if the variation among individuals (first case) or within them
(second case) relate to the response variable.
As you suspected, DATEs are often close each other and it is quite
probable I have autocorrelated data. You mentioned that the nlme package
handles correlated residuals and I have found the code to do that but the
problem is that I cannot do it for my case study since the distribution I
am using is a binomial and nlme is only for linear mixed model, isn?it?
For now, I have being using the below syntax and using LRT (anova)
reduced nested models to compute the p-value for each predictor. I know
that LRT is very criticized but I have been asked to calculate p-values
each predictor.
Mod1<-glmer(Var1 ~ SEX + AGE + Var2meanIND + Var2varIND + (1|DATE) +
(1|IND) , data = mydata, family = binomial, control =
glmerControl(optimizer="bobyqa"))
This way I am not accounting at all for the autocorrelation, do you have
any suggestions?
Thanks again,
Simone
------------------------------
Date: Sun, 15 Nov 2015 16:41:28 +0100
Subject: Re: [R-sig-ME] glmer random effects structure: a case
From: M.Fairbrother at bristol.ac.uk
To: miseno77 at hotmail.com
CC: r-sig-mixed-models at r-project.org
Dear Simone,
How many INDs and DATEs are in your dataset? It sounds like you have
plenty of INDs, but it's less clear how many DATEs you have. If you have
lot, you may have a situation of cross-classification: observations are
nested both in INDs and DATEs, but neither of those is nested in the
If you don't have many DATEs, it will make more sense to use fixed
for those. And even if you have a lot, if the DATEs are located close to
each other in time, you may have a lot of autocorrelation, and that
requires other techniques. (In R, you may need to use the older package
nlme, which allows for correlated residuals.)
In any event, if INDs are in many cases captured on multiple DATEs, it
definitely doesn't make sense to nest INDs in DATEs. Clearly they aren't
nested. (Assuming I've understood your data structure correctly.)
It also sounds like you should be centering Var2 by IND. This is pretty
much de rigueur in multilevel models with x variables that vary within
clusters. Enders and Tofighi 2007 is a useful, clear paper on this issue,
and you might also want to look at these recent papers by me and
in the Centre for Multilevel Modelling at Bristol:
doi:10.1017/psrm.2014.7
doi:10.1017/psrm.2013.24
Basically, take the mean of Var2 for each individual, and enter that as a
covariate. Then take the difference between the original Var2 and its
for that individual, and enter that as a covariate as well. You'll get
pieces of information in your fitted model: the distinct "between" and
"within" effects of Var2. It sounds like that is what you want.
Hope that's useful.
- Malcolm
Date: Sat, 14 Nov 2015 17:48:46 +0100
From: Simone <miseno77 at hotmail.com>
Cc: "r-sig-mixed-models at r-project.org"
<r-sig-mixed-models at r-project.org>
Subject: [R-sig-ME] glmer random effects structure: a case
Hi all,
I have a simple (but not that simple to me) question on how to specify
random structure in R.A binary response variable (Var1) has been measured
from a number of individuals (IND) that have been susceptible of being
captured over a number of dates (DATE). I suspect that Var1 might depend
either on its sex (SEX), or age (AGE) or Var2 which is a continuous
variable measured from each individual every time it is captured. Since
Var2 is a measure of the quality of each individual, it is likely that
individuals will tend to have greater values of Var2 than others during
entire study period.Note that some individuals have been captured only
time, other two, other three and so on (very unbalanced). For each date
individual can be captured only one time.So, I have two groups: IND and
DATE. I would think this is a two-level model with IND nested to DATE so
that:
model1 <- glmer(Var1 ~ SEX + AGE + Var2 + (1|DATE/IND), family =
data = mydata)
Does it make sense? I think i am not taking into account the fact that
mean of Var2 may be different among individuals but I don't know how to
that.I would really appreciate an answer to this question that I am sure
would help me a lot to understand better how mixed models work.
[[alternative HTML version deleted]]