Questions tagged [mixed-models]

Programming problems related to the analysis of statistical models with random-effects terms, also variously: repeated measures, hierarchical, multilevel models

Overview

"Mixed models" refers to a class of models that are variously known as: mixed-effects models, multilevel models, hierarchical linear models,... This class of models was developed to account for correlation that may occur within nested data. A classic example is the estimation of test scores of students: if test scores are correlated within classes, schools, districts, etc., mixed models allow the modeler to simultaneously estimate the differences between individual students and between the groups to which they belong (with the possibility of including covariates at all levels).

References

StatsExchangers often recommend the following resources for learning more about mixed models:

Software packages

Mixed models are available in the following statistical packages:

  • lme4 and nlme for R
  • PROC MIXED and GLIMMIX for SAS
  • MLwiN
  • xtreg, xtmixed, xtlogit, xtmelogit, xtmepoisson, and other xt* commands; user-contributed package GLLAMM for Stata
  • Mplus
  • HLM

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.

1368 questions
-1
votes
1 answer

Low power and singular fit in mixed model despite high number of observations and low number of factors

Despite I made 276 independent observations across 5 sites (lowest number of obs per site: 23), I get the singularity warning and low power to fit a model with one categorical factor (two levels) and one random factor (site). Anybody could tell why…
Agus camacho
  • 868
  • 2
  • 9
  • 24
-1
votes
1 answer

How can I solve the error: "The R package "lme4" is not installed when using the pymer4 library within python?

I am trying to follow the example detailed here: Mixed effects logistic regression, but I get a "PackageNotInstalledError: The R package "lme4" is not installed" at the line results = model.fit() The dataset can be downloaded here:…
-1
votes
1 answer

Why does predict() not accept 'newdata' work for my lmer model?

When I try to use predict(), or predictInterval(), or bootMer() by giving it newdata (even if it's the same data that I built the model with), I get the following error: Error in [.data.frame(fr, vars) : undefined columns selected I've been using…
-1
votes
1 answer

Using proc mixed to estimate parameters

I have a mixed model with the following parameters: A slope and intercept term for group 1 A different slope and intercept term for group 2 A random effect which is indexed by group/subject within group Is there a way to model this using proc…
user5827909
-1
votes
2 answers

How does plot.cld in multcomp package calculate boxes?

To visualise significant differences with letters there is a plotting function in the multcomp package: library(multcomp) tuk <- glht(model, linfct = mcp(effect = "Tukey")) plot(cld(tuk)) How are the boxes calculated (i.e. upper and lower quartiles…
erc
  • 10,113
  • 11
  • 57
  • 88
-1
votes
1 answer

Get class membership output in R package lcmm

I'm playing around with learning the lcmm package. I ran the following code and received a good fit for three latent classes: ext2<-lcmm(Startle~Trial,random=~Trial,subject='StudyID', …
-1
votes
1 answer

How to generate a plot of residuals versus predictor variable for a mixed model?

My mixed model is as follows: model <- lme(Cost~1+Units, random=~1+Units|Factory, method="ML", data=A) I was told to apply the code below to plot residuals versus fitted values and it worked: plot(fitted(model), resid(model)) However, it showed me…
Guess Gucci
  • 253
  • 1
  • 3
  • 11
-2
votes
0 answers

can you provide Corresponding Python code for lmer r code(mixed model)

R code : model =lmer( "BRAND_TRX ~ CALLS + ( 1 + CALLS|SPECIALTYGROUPING:MARKET_SALES_segment )",data = data) Please provide the corresponding python code using statsmodel library. I tried variance covariance but could not find the desired…
-2
votes
1 answer

plotting glmer model with sjPlot

df <- data.frame(C=c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8), Y=c("F","F","F","F","F","F","F","F","F","F","F","F","F","F","F","F", …
locus
  • 387
  • 2
  • 9
-2
votes
1 answer

Recurring error using lmer() function for a linear mixed-effects model

I attempted to construct a linear mixed effects model using lmer function from lme4 package and I ran into a recurring error. The model uses two fixed effects: DBS_Electrode (factor w/3 levels) and PostOp_ICA (continuous variable). I use (1 |…
-2
votes
1 answer

plotting fixed effects from lme4

I am plotting the estimates from the fixed effects model. Is there a way to only plot some of the fixed effects, rather than all? sjp.lmer (model.name, type = "ri.pc", facet.grid = FALSE) I am also using lmerTest to obtain p values for…
sar
  • 182
  • 6
  • 26
-2
votes
1 answer

Model selection with beta and quassi families using gamm4

I have two responses which conform to beta (also known as betar) and Poisson families, and I am looking into fitting additive mixed-models with beta and quasi-families (count data is over-dispersed), respectively. I am aware that I could use gamm…
Gitu
  • 33
  • 5
-3
votes
1 answer

estimate change in R of linear model

I'm doing the statistical analysis for my thesis with a linear mixed model, using the nlme package. Now I work with several orientations (west, east, north), and R takes the estimate as the alphabetically first value. However, I want the estimate to…
1 2 3
90
91