Questions tagged [lme4]

lme4 is an R package for fitting and analyzing linear, nonlinear and generalized linear mixed models.

Overview

lme4 is an package for fitting and analyzing linear, nonlinear and generalized linear .

Repositories

Vignettes

Books

Other resources

Related tags


Tag usage

Questions on tag should be about implementation and programming problems, not about the statistical or theoretical properties of the technique. Consider whether your question might be better suited to Cross Validated, the StackExchange site for statistics, machine learning and data analysis.

1729 questions
9
votes
1 answer

How to unscale the coefficients from an lmer()-model fitted with a scaled response

I fitted a model in R with the lmer()-function from the lme4 package. I scaled the dependent variable: mod <- lmer(scale(Y) ~ X + (X | Z), data = df, REML = FALSE) I look at the…
lord.garbage
  • 5,884
  • 5
  • 36
  • 55
9
votes
1 answer

nlmer longitudinal data

I've been working with the R Orthodont dataset in the "nlme" package. Just use install.packages("nlme");library(nlme);head(Orthodont) to take a look. The dataset is comprised of distance between the pituitary and the pterygomaxillary fissure…
iantist
  • 833
  • 2
  • 12
  • 27
9
votes
2 answers

glmulti runs indefinitely when using genetic algorithm with lme4

I'm using glmulti for model averaging in R. There are ~10 variables in my model, making exhaustive screening impractical - I therefore need to use the genetic algorithm (GA) (call: method = "g"). I need to include random effects so I'm using…
Thomas
  • 392
  • 5
  • 18
8
votes
1 answer

Using imputed datasets from library mice() to fit a multi-level model in R

I'm new to package mice in R. But I'm trying to impute 5 datasets from popmis and then fit an lmer() model with() each and finally pool() across them. I think the pool() function in mice() doesn't work with the lmer() call from lme4 package,…
rnorouzian
  • 7,397
  • 5
  • 27
  • 72
8
votes
1 answer

Pass a named list of models to anova.merMod

I want to be able to pass a named list of models (merMod objects) to anova() and preserve the model names in the output. This is particularly useful in the context of using mclapply() to run a batch of slow models like glmers more efficiently in…
Dan Villarreal
  • 119
  • 1
  • 12
8
votes
1 answer

Are random effect variables automatically taken as factors in lmer (or lme) in R?

I understand that having a continuous or numeric variable as a random effect in a mixed effects model doesn't make much sense (e.g., see here). But what I'm wondering is if lme4::lmer or nlme::lme in R purposefully prevent you from doing…
theforestecologist
  • 4,667
  • 5
  • 54
  • 91
8
votes
1 answer

Incorporating time series into a mixed effects model in R (using lme4)

I've had a search for similar questions and come up short so apologies if there are related questions that I've missed. I'm looking at the amount of time spent on feeders (dependent variable) across various conditions with each subject visiting…
wonderburg
  • 95
  • 1
  • 1
  • 5
8
votes
1 answer

A caterpillar plot of just the "significant" random effects from a mixed effects model

I've had great experiences asking for help here before and I'm hoping to get some help again. I'm estimating a rather large mixed effects model in which one of the random effects has over 150 different levels. That would make a standard caterpillar…
steve
  • 593
  • 6
  • 22
8
votes
1 answer

Post-hoc test for glmer

I'm analysing my binomial dataset with R using a generalized linear mixed model (glmer, lme4-package). I wanted to make the pairwise comparisons of a certain fixed effect ("Sound") using a Tukey's post-hoc test (glht, multcomp-package). Most of it…
Jeroen
  • 85
  • 1
  • 1
  • 6
8
votes
1 answer

How to predict terms of merMod objects (lme4)?

For simple glm objects, I can use predict(fit, type = "terms") to retrieve a matrix with fitted values for each term. What is the equivalent for lmer resp. glmer fitted models? As far as I can see, the predict.merMod function does not support type =…
Daniel
  • 7,252
  • 6
  • 26
  • 38
8
votes
1 answer

Generalised linear mixed model error (binary response)

I am running a generalised linear mixed model in R for a binary response variable and I am getting an error message. My code is: library('lme4') m1<-glmer(data=mydata, REPRODUCE~F1TREAT*SO+(1|LINE/MATERNAL_ID), family=binomial) Where REPORDUCE =…
Shannon Hodges
  • 163
  • 1
  • 6
8
votes
1 answer

unscale and uncenter glmer parameters

I've been struggling with converting scaled and centered model coefficients from a glmer model back to uncentered and unscaled values. I analysed a dataset using GLMM in the lme4 (v1.1.7) package. It involves the calculation of maximum detection…
FlyingDutch
  • 1,100
  • 2
  • 14
  • 24
7
votes
1 answer

How to extract the original formula (fixed-effects and random-effects) from an lmerMod object?

Suppose we have postulated the following linear mixed model (LMM), which we generically call fit. library(lme4) fit <- lmer(Reaction ~ Days + (1 | Subject), data = sleepstudy) Suppose that we are also interested in extracting the original formula…
Dion Groothof
  • 1,406
  • 5
  • 15
7
votes
5 answers

How to extract just the random effects part of the formula from lme4

Let us say I have fitted a model such mymodel <- lmer(Y~X1+(1|fac1)+(1|fac2),mydata) How can I extract just the random effects part of the formula ((1|fac1)+(1|fac2)) ? I know I can do formula(mymodel)[-2] but this just returns X1 + (1| fac1) +…
Robert Long
  • 5,722
  • 5
  • 29
  • 50
7
votes
1 answer

How do I manually plot SE/CI around a model estimate

I am trying to manually plot model estimates on top of data. My real problem is far more complicated than this, so I want to avoid using predict if I can, and would prefer to understand how these predictions would be calculated rather than relying…
Dylan_Gomes
  • 2,066
  • 14
  • 29