Questions tagged [random-effects]

170 questions
36
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
  • 815
  • 3
  • 15
  • 23
31
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
  • 52,167
  • 46
  • 207
  • 345
11
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
  • 131
  • 1
  • 1
  • 3
9
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,081
  • 1
  • 11
  • 24
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
  • 801
  • 7
  • 20
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
  • 737
  • 3
  • 11
  • 29
6
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
  • 491
  • 1
  • 6
  • 17
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
  • 4
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
  • 592
  • 6
  • 18
4
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…
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…
4
votes
1 answer

Survey Weighted Random Effects Logit Model in R

I am trying to predict a binary outcome with a model that includes a random effect using survey data. I've included a description of the sampling design below, so feel free to comment on my survey weighting approach. My primary question is how to…
mike
  • 19,373
  • 28
  • 72
  • 93
3
votes
1 answer

How to reproduce average marginal effects from xtlogit model

I am interested in reproducing average marginal effects from a random effects logit model (run in Stata using xtlogit). I understand how to reproduce the average marginal effects from a logit model using the Delta method. For instance, in the code…
3
votes
1 answer

How to predict gam model with random effect in R?

I am working on predicting gam model with random effect to produce 3D surface plot by plot_ly. Here is my code; x <- runif(100) y <- runif(100) z <- x^2 + y + rnorm(100) r <- rep(1,times=100) # random effect r[51:100] <- 2 # replace 1 into 2, making…
imtaiky
  • 113
  • 6
1
2 3
11 12