Questions tagged [lmer]

Function of the lme4 package for running linear mixed-effects regressions.

Function of the package for running linear mixed-effects regressions.

88 questions
69
votes
1 answer

Restart mixed effect model estimation with previously estimated values

I'm using lmer() in package lme4 to estimate mixed effects models. This works well, but now I want to run the estimation process for a fixed number of iterations, then resume the process by specifying start values, as calculated by the last…
Andrie
  • 176,377
  • 47
  • 447
  • 496
25
votes
1 answer

plot mixed effects model in ggplot

I am new with mixed effect models and I need your help please. I have plotted the below graph in ggplot: ggplot(tempEf,aes(TRTYEAR,CO2effect,group=Myc,col=Myc)) + facet_grid(~N) + geom_smooth(method="lm",se=T,size=1) + geom_point(alpha = 0.3)…
fede_luppi
  • 1,063
  • 4
  • 17
  • 29
15
votes
1 answer

increase iterations for new version of lmer?

I just updated lme4 to version 1.0-4 and when I run lmer() my mixed effects model, which was converging before, now prints this warning: Warning message: In (function (fn, par, lower = rep.int(-Inf, n), upper = rep.int(Inf, : failure to converge…
Sol
  • 724
  • 1
  • 5
  • 18
13
votes
1 answer

Do I need to set refit=FALSE when testing for random effects in lmer() models with anova()?

I am currently testing whether I should include certain random effects in my lmer model or not. I use the anova function for that. My procedure so far is to fit the model with a function call to lmer() with REML=TRUE (the default option). Then I…
lord.garbage
  • 5,884
  • 5
  • 36
  • 55
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

How does lmer (from the R package lme4) compute log likelihood?

I'm trying to understand the function lmer. I've found plenty of information about how to use the command, but not much about what it's actually doing (save for some cryptic comments here:…
stewbasic
  • 831
  • 7
  • 21
8
votes
1 answer

How to use tryCatch in R

I would like to use try() or tryCatch() or a function like this to detect if there is an error in my model called "fit1". If the model is fine, I want to use "fit1", otherwise I want to use "fit2" fit1<-glmer(stat ~ dataint + DBH + DBH2 +…
user52463
  • 81
  • 1
  • 1
  • 3
7
votes
2 answers

Standardized coefficients for lmer model

I used to use the code below to calculate standardized coefficients of a lmer model. However, with the new version of lme the structure of the returned object has changed. How to adapt the function stdCoef.lmer to make it work with the new lme4…
majom
  • 7,863
  • 7
  • 55
  • 88
7
votes
1 answer

How to plot random intercept and slope in a mixed model with multiple predictors?

Is it possible to plot the random intercept or slope of a mixed model when it has more than one predictor? With one predictor I would do like this: #generate one response, two predictors and one factor (random effect) resp<-runif(100,1,…
Oritteropus
  • 531
  • 2
  • 6
  • 18
6
votes
1 answer

behavior of na.action = na.exclude using lmer in lme4 1.0-5 inconsistent with lm and with older versions of lme4

Consider a simple example: > library(lme4) Loading required package: lattice Loading required package: Matrix > set.seed(1) > df <- data.frame(x = c(rnorm(7), NA), y = rep(c("A", "B"), 4)) > length(fitted(lm(data = df, x ~ y, na.action =…
David Kane
  • 363
  • 1
  • 2
  • 8
5
votes
1 answer

Accounting for temporal correlation in GLMM

I am trying to account for autocorrelation in a GLMM. My response variable is boolean, it represents the presence and absence of a en event in the life cycle of a set of bee nests. I am trying to predict the probability of such an event with a set…
AtiQP
  • 51
  • 1
  • 4
5
votes
1 answer

What does this mean in lme4: function 'dataptr' not provided by package 'Rcpp'

I'm trying to do LMM using lme4, and this message pops up: Error in initializePtr() : function 'dataptr' not provided by package 'Rcpp' What should I do?
user3288202
  • 313
  • 1
  • 4
  • 14
5
votes
1 answer

How do I run diagnostic plots for lmer in R?

I am trying to run diagnostic plots on an lmer model but keep hitting a wall. I'm not sure how much information I need to provide here, but here goes: The model is simple: best <- lmer(MSV_mm ~ Size_treat + (1|Rep) + (1|Patch) + (1|Trap), data=…
Kika Tarsi
  • 47
  • 1
  • 1
  • 2
5
votes
2 answers

Extracting the number of observations and the modes of random effects from a mer object

I have a mer object created with a called to lmer(). I can obtain the random effects with ranef() but I would also like to have corresponding number of observations for each random effect - is there an easy way to do that ? Additional Info: I may…
Robert Long
  • 5,722
  • 5
  • 29
  • 50
4
votes
1 answer

Extract raw model matrix of random effects from lmer objects (lme4, R)

I have a question regarding the extraction of the (raw) model matrix of random effects from models fitted with lmer (lme4) in R. More specifically, I want to obtain a data frame or a matrix that contains all variables that are involved in random…
SimonG
  • 4,701
  • 3
  • 20
  • 31
1
2 3 4 5 6