Questions tagged [random-effects]

238 questions
40
votes
7 answers

How to get coefficients and their confidence intervals in mixed effects models?

In lm and glm models, I use functions coef and confint to achieve the goal: m = lm(resp ~ 0 + var1 + var1:var2) # var1 categorical, var2 continuous coef(m) confint(m) Now I added random effect to the model - used mixed effects models using lmer…
Tomas
  • 57,621
  • 49
  • 238
  • 373
39
votes
4 answers

Plot random effects from lmer (lme4 package) using qqmath or dotplot: How to make it look fancy?

The qqmath function makes great caterpillar plots of random effects using the output from the lmer package. That is, qqmath is great at plotting the intercepts from a hierarchical model with their errors around the point estimate. An example of…
Captain Murphy
  • 855
  • 3
  • 15
  • 23
13
votes
2 answers

Prediction with lme4 on new levels

I'm trying to fit a mixed effects model and then use that model to generate estimates on a new dataset that may have different levels. I expected that the estimates on a new dataset would use the mean value of the estimated parameters, but that…
random_forest_fanatic
  • 1,232
  • 1
  • 12
  • 30
12
votes
2 answers

Python Statsmodels Mixedlm (Mixed Linear Model) random effects

I am a bit confused about the output of Statsmodels Mixedlm and am hoping someone could explain. I have a large dataset of single family homes, including the previous two sale prices/sale dates for each property. I have geocoded this entire dataset…
Tommy Shay
  • 141
  • 1
  • 1
  • 3
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
7
votes
1 answer

`nlme` with crossed random effects

I am trying to fit a crossed non-linear random effect model as the linear random effect models as mentioned in this question and in this mailing list post using the nlme package. Though, I get an error regardless of what I try. Here is an…
7
votes
1 answer

R geepack: unreasonably large estimates using GEE

I am using geepack for R to estimate logistic marginal model by geeglm(). But I am getting garbage estimates. They about 16 orders of magnitude too large. However the p-values seems to similar to what I expected. This means that the response…
Mikkel Rev
  • 863
  • 3
  • 12
  • 31
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
5
votes
0 answers

Need clarification on the Coef. and St.Err. of random parameter in MixedLM results

I am trying to understand the results of Mixed Linear Models provided by Python statsmodel package. I want to avoid pitfalls in my data analysis and interpretation. The questions are after the data loading/output code block. Loading data and fitting…
5
votes
0 answers

how to allow for factor-specific variance of random effect in lme

I assume that the random effects variances in my mixed effect model will be different for different levels of the fixed factor BTyp. Here is my model fm2 <- lme(CA ~ 1 + pF+Tiefe+BTyp+Tiefe:pF+BTyp:pF, data=data2, random = list(~ 1 +…
Olga Fishkis
  • 83
  • 1
  • 2
  • 5
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
0 answers

"optim" function fails to converge for maximum likelihood estimation in a random-effect model

I have a longitudinal dataset for plant growth that includes repeated measurements in different seasons. I am trying to estimate the parameters for a growth equation using this dataset. The growth equation is as follows: Lt = 150*((1 +…
TKH_9
  • 105
  • 1
  • 7
4
votes
1 answer

Specify correlation between varying intercepts with same level in different groups

Say I have 2 factor variables foo and bar which both contain the same levels "a", "b", and "c". Is there any way to specify in lme4 (or any other package) a model with random intercepts for foo and bar with correlation between intercepts with the…
Jeff
  • 718
  • 8
  • 20
4
votes
1 answer

Most straightforward R package for setting subject as random effect in mixed logit model

I have a dataset in which individuals, each belonging to a particular group, repeatedly chose between multiple discrete outcomes. subID group choice 1 Big A 1 Big B 2 Small B 2 Small B 2 Small C 3 Big …
jjcii
  • 139
  • 3
  • 10
4
votes
0 answers

Random effects modeling using mgcv and using lmer. Basically identical fits but VERY different likelihoods and DF. Which to use for testing?

I am aware that there is a duality between random effects and smooth curve estimation. At this link, Simon Wood describes how to specify random effects using mgcv. Of particular note is the following passage: For example if g is a factor then…
1
2 3
15 16