I would like to know if it is acceptable to use a factor as both fixed and random. My understanding is that it is not a general practice.
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3881361/
http://avesbiodiv.mncn.csic.es/estadistica/curso2011/regm26.pdf
In the following model, I am using Sp
as a fixed as well as random factor, and my model does not converge.
Model1 <- lmer (C1 ~ Place*Voicing*Length*Sp +
(1+Place+Voicing+Length|Sp),data =
C1,control=lmerControl(optCtrl=list(maxfun=50000)))
anova (Model1)
str(LME_Model1)
$ Sp : Factor w/ 5 levels
$ Place : Factor w/ 3 levels
$ Voicing : Factor w/ 2 levels
$ Length : Factor w/ 2 levels
Warning messages:
1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
unable to evaluate scaled gradient
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
Model failed to converge: degenerate Hessian with 4 negative eigenvalues
If I exclude Sp
from the fixed factors, then the model converges.
Could someone explain whether it is OK to use Sp
as a fixed factor?
The model you want to fit is theoretically OK but practically difficult.
To be more precise, when you say "include a factor as both fixed and random" you mean "include a factor as both fixed and as a term within a particular grouping variable". I would typically interpret "include g
as a a random effect" as "include g
as a random effect grouping variable", i.e. something like (1|g)
.
In general when you include a variable x
as a varying term, e.g. (1 + x | f)
, you should include it in the fixed effects as well (response ~ ... + x + ... + (1 + x | f)
). Otherwise you will be assuming that the population-level average effect is exactly zero, which is usually an unrealistic assumption.
Your convergence problems probably have more to do with the complexity of your model.
When you include (1+Place+Voicing+Length|Sp)
in your model, what you are assuming is that the effect of Place
, Voicing
, and Length
are allowed to vary across levels of the grouping variable (Sp
). Given that you are using a randomized block design (each, or at least most, levels of Sp
have observations for all, or most, of the levels of Place
, Voicing
, and Length
), this variability is theoretically estimable.
However ... you will typically need a big experiment if you want to estimate all of this variability. Suppose Place
, Voicing
, and Length
have m1
, m2
, and m3
levels respectively. lme4
assumes that all of the terms included for a particular grouping variable could covary; this means that you'll be estimating a variance-covariance matrix with 1+m1+m2+m3-3 = m1+m2+m3-2
rows and columns (the different effects share an intercept term), or a total of (m1+m2+m3-2)*(m1+m2+m3-1)/2
variance-covariance parameters - a minimum of 10, if those are each two-level factors.
In your case you seem to be trying to estimate a 60x60 covariance matrix (!!), which will be thoroughly impractical with 300 observations ...
There is a great deal of debate about the proper procedure when a mixed model is theoretically identifiable, but you don't practically have enough data to fit the maximal model. Some discussion is given here. You could fit the maximal model and throw away terms in some sensible order until it's no longer overspecified; use a Bayesian method, specifying priors to regularize the model; try to decide a priori on a simpler model ...