Hot answers tagged lmer
16
This may become clearer by writing out the model formula for each of these three models. Let $Y_{ij}$ be the observation for person $i$ in site $j$ in each model and define $A_{ij}, T_{ij}$ analogously to refer to the variables in your model.
glmer(counts ~ A + T, data=data, family="Poisson") is the model
$$ \log \big( E(Y_{ij}) \big) = \beta_0 + \beta_1 ...
11
I will answer each of your queries in turn.
Is the syntax correctly specifying the clustering and random effects?
The model you've fit here is, in mathematical terms, the model
$$ Y_{ijk} = {\bf X}_{ijk} {\boldsymbol \beta} + \eta_{i} + \theta_{ij} + \varepsilon_{ijk}$$
where
$Y_{ijk}$ is the reaction time for observation $k$ during session $j$ on ...
10
Using the given regression table, we can compute the table of expected value of the dependent variable, DV, for each combination of the two factors, which might make this more clear (Note I've used the ordinary estimates, not the MCMC estimates):
$$
\begin{array}{c|cc}
\phantom{} & {\rm GroupA} & {\rm GroupB} \\
\hline
{\rm Condition1} & ...
10
I'm going to describe what model each of your calls to lmer() fits and how they are different and then answer your final question about selecting random effects.
Each of your three models contain fixed effects for practice, context and the interaction between the two. The random effects differ between the models.
lmer(ERPindex ~ practice*context + ...
9
Rank deficiency in this context says there is insufficient information contained in your data to estimate the model you desire. It stems from many origins. I'll talk here about modeling in a fairly general context, rather than explicitly logistic regression, but everything still applies to the specific context.
The deficiency may stem from simply too little ...
9
You should note that T is none of your model's a random effects terms, but a fixed effect. Random effects are only those effects that appear after the | in a lmer formula!
A more thorough discussion of what this specification does you can find in this lmer faq question.
From this questions your model should give the following (for your fixed effect T):
A ...
8
I think the problem is with your expectations:) Note that when you added a random intercept for each individual, the standard error of the intercepts increased. Since each individual can have his/her own intercept, the group average is less certain. The same thing happened with the random slope: you are not estimating one common (within-group) slope anymore, ...
8
The lmer package's author made a conscious choice not to create p-values for the fixed effects. Some packages do, but he feels that they are doing simplistic calculations that are misleading. (Many statisticians feel that there's a p-value obsession that causes confusion in and of itself, but that's a separate matter.)
He addresses the question in: this ...
7
lmer uses Laplace approximation, when the whole normal distribution of the random effect is approximated at its mode. This approximation is known to produce the estimates of the variance components that are biased down. lme uses a more thorough approximation via Gaussian quadrature approximation, but I neither know the default number of integration points ...
6
The results of a linear model and a linear mixed-model can differ if the design is unbalanced, i.e., the number of observations per cell is different.
First, consider a balanced design:
df <- data.frame(x = rep(0:1, each = 10), y = 1:20, m = rep(1:10, each = 2))
lm(y ~ x, df)
# Coefficients:
# (Intercept) x
# 5.5 10.0
...
6
I think this is a bug in the predict function (and hence my fault), which in fact nlme does not share. (Edit: should be fixed in most recent R-forge version of lme4.) See below for an example ...
I think your understanding of orthogonal polynomials is probably just fine. The tricky thing you need to know about them if you are trying to write a predict ...
6
This is a highly-cited paper on mixed models for ecology and evolution:
Bolker et al. (2009) Generalized linear mixed models: a practical guide for ecology and evolution Trends in Ecology & Evolution Vol. 24 pp127-135 (PDF) (from ScienceDirect with links to Supplementary Content).
6
Mixed models are (generalized versions of) variance components models. You write down the fixed effects part, add error terms that may be common for some groups of observations, add link function if needed, and put this into a likelihood maximizer.
The various variance structures you are describing, however, are the working correlation models for the ...
6
The estimate, ID's variance = 0, indicates that the level of
between-group variability is not sufficient to warrant incorporating random
effects in the model; ie. your model is degenerate.
As you correctly identify yourself: most probably, yes; ID as a random effect is unnecessary. Few things spring to mind to test this assumption:
You could compare ...
5
There is a post on the R list by lme4's author for why p-values are not displayed. He suggests using MCMC samples instead, which you do using the pvals.fnc from the languageR package:
library("lme4")
library("languageR")
model=lmer(...)
pvals.fnc(model)
See http://www2.hawaii.edu/~kdrager/MixedEffectsModels.pdf for an example and details.
5
With just three farms, there is no point in trying to pretend that you can fit a Gaussian distribution to three points. Analyze this simply as lm(response~as.factor(farm) + treat+other stuff), and won't bother with lmer; you won't be able to do much better than ANOVA, anyway.
Generally, hitting exactly zero is not that unusual. The variance estimate is a ...
5
For the definition of the rank of a matrix, you can refer to any good textbook on algebra, or have a look at the Wikipedia page.
A $n \times p$ matrix $X$ is said to be full rank if $n < p$, and its columns are not a linear combination of each other . In that case, the $n \times n$ matrix $X^TX$ is positive definite, which implies that it has an inverse ...
5
If you have repeated measures then you should defnintely be able to use the longpower package. This implements the sample size calculations in Liu and Liang (1997) and Diggle et al (2002). The documentation has example code. Here's one, using the lmmpower() function:
> require(longpower)
> require(lme4)
> fm1 <- lmer(Reaction ~ Days + ...
4
Nominally, you are right, but it looks odd that you force no random intercept in the model, which smells like regression through the origin, in terms of making strong assumptions that some terms (or some sources of variability) in the model are zero. I would start with
lmer(y~x+x:z+(1+x|forest))
instead and see how that works.
4
The lmer function requires multiple measures / random effect (at least for some of them). Furthermore, the grouping factor in the random effect is typically nominal values, not continuous. You say X2 is continuous yet you tell the model that the intercept is grouped by it as a random effect.
Either you just want straight linear modelling here or something ...
3
You include them as you would a level-1 predictor, like so:
lmer(level1_depend ~ level1_feat1 + level1_feat2 + level2_feat1 + level2_feat2 + (1 | level2_ID), data = example_data)
This would be a model in which level1_depend is a function of two level-1 predictors, two level-2 predictors, with intercepts for level-2 varying. Note if your data are not ...
3
It sounds like what you want to know is if each little detail in the pattern of data is significant or not. This is a bad path. The worst reason is probably because the difference between significant and not significant is not a direct comparison of two things and may not itself be significant. Therefore, what you really need to be doing, if you want to ...
3
I was just reading a paper that used a pretty similar setup the other day, looking at congruence effects over a time-course.
You can find it here: "The Flexibility of Nonconsciously Deployed Cognitive Processes: Evidence from Masked Congruence Priming" (Finkbeiner and Friedman, 2011)
To control for the multiple comparisons over the time-course, they:
...
3
Did you check the help page of lmer? It is pretty clear about the relationship between lmer and glmer:
The ‘lmer’ and ‘glmer’ functions are nearly interchangeable. If
‘lmer’ is called with a non-default ‘family’ argument the call is
replaced by a call to ‘glmer’ with the current arguments. If ‘glmer’
is called with the default ‘family’, namely ...
3
The results of lmer and glmer should be identical if you specify the gaussian family for glmer.
The difference between the results of your models ist most likely due to specifying REML=FALSE for the first one but not for the second. Try specifying REML=FALSE or REML=TRUE (the default) for both models and check the results.
3
Consider what you're asking. If you just want to know if the overall p-value for the effect of status passes some some sort of arbitrary cutoff value, like 0.05, then that's easy. First, you want to find out the overall effect. You could get that from anova.
m <- lmer(...) #just run your lmer command but save the model
anova(m)
Now you have an F ...
3
Looks like there was probably no effect due to Farm built in from the experimental design; each farm has exactly half treated and half not.
> xtabs(~treat+farm, territory)
farm
treat 1 2 3
0 14 12 10
1 14 12 10
It can also be instructive to fit farm as a fixed effect and see what happens; we see that the Farm effect is very, very small ...
3
Q1: Either is fine. They will give you same fits. lme will give you p-values, and lmer won't, but that's more than I want to get into here. The most famous reference is one of Doug Bates's posts to the R-help mailing list here.
(caveat: They do use slightly different algorithms so there are potentially some computationally difficult cases where one or ...
3
Welcome to the site. This has been discussed many times here, e.g. this question
Briefly, it is very rarely a good idea to include an interaction term in a model without the main effects, and the main effects do not have a simple interpretation when there is an interaction.
2
In a random effects or mixed effects model a random effect is used when you want to treat the effect that you observed as if it were drawn from some probability distribution of effects. One of the best examples I can give is when modeling clinical trial data from a multicentered clinical trial. A site effect is often modeled as a random effect. This is ...
Only top voted, non community-wiki answers of a minimum length are eligible
