[{"data":1,"prerenderedAt":1029},["ShallowReactive",2],{"content-query-ovXP0EsJjF":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"heading":8,"prompt":10,"tags":14,"files":16,"nav":6,"presets":17,"gallery":36,"body":38,"_type":1022,"_id":1023,"_source":1024,"_file":1025,"_stem":1026,"_extension":1027,"sitemap":1028},"/tools/mixed-effects-model","tools",false,"","Linear Mixed Effects Model","Fit linear mixed effects models online from Excel or CSV data. Model clustered or longitudinal outcomes with fixed and random effects using AI.",{"prefix":11,"label":12,"placeholder":13},"Fit a linear mixed effects model","Describe the outcome, fixed effects, and grouping structure","e.g. outcome = pain score; fixed effect = time and treatment; random intercept per patient; plot individual trajectories and fixed effect; report fixed effect estimates with 95% CI",[15],"statistics",true,[18,24,30],{"label":19,"prompt":20,"dataset_url":21,"dataset_title":22,"dataset_citation":23},"Patient Recovery Over Time","Linear mixed effects model: outcome = recovery score; fixed effects = time and treatment group; random intercept per patient; report fixed effect estimates with 95% CI; plot individual trajectories with population mean; caterpillar plot of random intercepts","https://data.cdc.gov/api/views/dppn-5tm3/rows.csv?accessType=DOWNLOAD","NCHS Health and Nutrition Examination Survey","CDC",{"label":25,"prompt":26,"dataset_url":27,"dataset_title":28,"dataset_citation":29},"Student Achievement in Schools","Mixed effects model: student test score ~ time + SES + (1|school); random intercept per school to account for clustering; fixed effects table with p-values; ICC to quantify school-level variance; random effects caterpillar plot","https://ourworldindata.org/grapher/pisa-test-score-mean-performance-on-the-reading-scale.csv","PISA Mean Reading Performance Scores","Our World in Data",{"label":31,"prompt":32,"dataset_url":33,"dataset_title":34,"dataset_citation":35},"GDP Growth Across Countries","LMM: GDP per capita growth ~ year + region + (1 + year|country); random slope and intercept per country; fixed effect of year (global trend); plot country-level trajectories with confidence band; report variance components","https://api.worldbank.org/v2/en/indicator/NY.GDP.PCAP.CD?downloadformat=excel","GDP per Capita (Current USD)","World Bank",[37],"/img/tools/mixed-effects-model.png",{"type":39,"children":40,"toc":1011},"root",[41,50,92,118,123,129,194,200,430,448,454,620,626,768,774,845,851,888,894,918,935,959],{"type":42,"tag":43,"props":44,"children":46},"element","h2",{"id":45},"what-is-a-linear-mixed-effects-model",[47],{"type":48,"value":49},"text","What Is a Linear Mixed Effects Model?",{"type":42,"tag":51,"props":52,"children":53},"p",{},[54,56,62,64,69,71,76,78,83,85,90],{"type":48,"value":55},"A ",{"type":42,"tag":57,"props":58,"children":59},"strong",{},[60],{"type":48,"value":61},"linear mixed effects model",{"type":48,"value":63}," (LMM, also called a multilevel model or hierarchical linear model) extends ordinary linear regression to handle data where observations are ",{"type":42,"tag":57,"props":65,"children":66},{},[67],{"type":48,"value":68},"not independent",{"type":48,"value":70}," — specifically, clustered data (students within schools, patients within hospitals) and ",{"type":42,"tag":57,"props":72,"children":73},{},[74],{"type":48,"value":75},"repeated measures",{"type":48,"value":77}," data (multiple measurements per subject over time). The \"mixed\" in the name refers to the combination of ",{"type":42,"tag":57,"props":79,"children":80},{},[81],{"type":48,"value":82},"fixed effects",{"type":48,"value":84}," (population-level parameters estimated the same way as in ordinary regression) and ",{"type":42,"tag":57,"props":86,"children":87},{},[88],{"type":48,"value":89},"random effects",{"type":48,"value":91}," (subject- or group-specific deviations from the fixed effects that are modeled as draws from a probability distribution). This structure allows LMMs to correctly account for within-cluster correlation without discarding data from partially-observed subjects.",{"type":42,"tag":51,"props":93,"children":94},{},[95,97,102,104,109,111,116],{"type":48,"value":96},"The model is written as: ",{"type":42,"tag":57,"props":98,"children":99},{},[100],{"type":48,"value":101},"y = Xβ + Zu + ε",{"type":48,"value":103},", where X is the design matrix for fixed effects (β), Z is the design matrix for random effects (u ~ N(0, G)), and ε ~ N(0, R) is the residual. The most common specification is the ",{"type":42,"tag":57,"props":105,"children":106},{},[107],{"type":48,"value":108},"random intercept model",{"type":48,"value":110},": each subject has their own baseline level (random intercept u_i), but the rate of change over time (the slope) is assumed the same for everyone. The ",{"type":42,"tag":57,"props":112,"children":113},{},[114],{"type":48,"value":115},"random slope model",{"type":48,"value":117}," additionally allows each subject to have a different rate of change, capturing heterogeneity in trajectories. Random effects are not estimated as free parameters — instead, their variance (σ²_u) is estimated, and individual-level predictions (BLUPs — Best Linear Unbiased Predictors) are shrunk toward the group mean in proportion to the reliability of each subject's data.",{"type":42,"tag":51,"props":119,"children":120},{},[121],{"type":48,"value":122},"A concrete example: a clinical trial measures pain scores in 80 patients at baseline, 1 month, 3 months, and 6 months. Some patients miss visits, creating an unbalanced dataset that would require listwise deletion in RM-ANOVA. An LMM with random intercept per patient and fixed effects of time and treatment group correctly uses all available data, handles the missing observations under a missing-at-random (MAR) assumption, and produces: fixed effect of treatment = −12.3 points (95% CI: −18.1 to −6.5, p \u003C 0.001); fixed effect of time = −2.1 points/month; random intercept variance σ²_u = 48.2 (ICC = 0.63, meaning 63% of total variance is between-patient). The random effects plot reveals that 6 patients have systematically higher pain throughout the study, suggesting an unmeasured subgroup.",{"type":42,"tag":43,"props":124,"children":126},{"id":125},"how-it-works",[127],{"type":48,"value":128},"How It Works",{"type":42,"tag":130,"props":131,"children":132},"ol",{},[133,151,167],{"type":42,"tag":134,"props":135,"children":136},"li",{},[137,142,144,149],{"type":42,"tag":57,"props":138,"children":139},{},[140],{"type":48,"value":141},"Upload your data",{"type":48,"value":143}," — provide a CSV or Excel file in ",{"type":42,"tag":57,"props":145,"children":146},{},[147],{"type":48,"value":148},"long format",{"type":48,"value":150},": one row per observation, with columns for the outcome, grouping variable (subject/cluster ID), time or condition variable, and any predictors. Unbalanced data (different numbers of observations per subject) is fully supported.",{"type":42,"tag":134,"props":152,"children":153},{},[154,159,161],{"type":42,"tag":57,"props":155,"children":156},{},[157],{"type":48,"value":158},"Describe the model",{"type":48,"value":160}," — e.g. ",{"type":42,"tag":162,"props":163,"children":164},"em",{},[165],{"type":48,"value":166},"\"outcome = pain_score; fixed effects = time, treatment; random intercept per patient_id; report fixed effects table with 95% CI; plot trajectories; caterpillar plot of random intercepts\"",{"type":42,"tag":134,"props":168,"children":169},{},[170,175,177,184,186,192],{"type":42,"tag":57,"props":171,"children":172},{},[173],{"type":48,"value":174},"Get full results",{"type":48,"value":176}," — the AI writes Python code using ",{"type":42,"tag":178,"props":179,"children":181},"a",{"href":180},"https://www.statsmodels.org/stable/mixed_linear.html",[182],{"type":48,"value":183},"statsmodels MixedLM",{"type":48,"value":185}," or ",{"type":42,"tag":178,"props":187,"children":189},{"href":188},"https://eshinjolly.com/pymer4/",[190],{"type":48,"value":191},"pymer4",{"type":48,"value":193}," to fit the model, extract fixed and random effects, compute ICC, plot individual trajectories, and produce caterpillar plots of random effects",{"type":42,"tag":43,"props":195,"children":197},{"id":196},"required-data-format",[198],{"type":48,"value":199},"Required Data Format",{"type":42,"tag":201,"props":202,"children":203},"table",{},[204,228],{"type":42,"tag":205,"props":206,"children":207},"thead",{},[208],{"type":42,"tag":209,"props":210,"children":211},"tr",{},[212,218,223],{"type":42,"tag":213,"props":214,"children":215},"th",{},[216],{"type":48,"value":217},"Column",{"type":42,"tag":213,"props":219,"children":220},{},[221],{"type":48,"value":222},"Description",{"type":42,"tag":213,"props":224,"children":225},{},[226],{"type":48,"value":227},"Example",{"type":42,"tag":229,"props":230,"children":231},"tbody",{},[232,268,317,357,390],{"type":42,"tag":209,"props":233,"children":234},{},[235,246,251],{"type":42,"tag":236,"props":237,"children":238},"td",{},[239],{"type":42,"tag":240,"props":241,"children":243},"code",{"className":242},[],[244],{"type":48,"value":245},"subject_id",{"type":42,"tag":236,"props":247,"children":248},{},[249],{"type":48,"value":250},"Grouping variable (cluster/subject)",{"type":42,"tag":236,"props":252,"children":253},{},[254,260,262],{"type":42,"tag":240,"props":255,"children":257},{"className":256},[],[258],{"type":48,"value":259},"P001",{"type":48,"value":261},", ",{"type":42,"tag":240,"props":263,"children":265},{"className":264},[],[266],{"type":48,"value":267},"school_12",{"type":42,"tag":209,"props":269,"children":270},{},[271,280,285],{"type":42,"tag":236,"props":272,"children":273},{},[274],{"type":42,"tag":240,"props":275,"children":277},{"className":276},[],[278],{"type":48,"value":279},"time",{"type":42,"tag":236,"props":281,"children":282},{},[283],{"type":48,"value":284},"Within-subject variable",{"type":42,"tag":236,"props":286,"children":287},{},[288,294,295,301,302,308,309,315],{"type":42,"tag":240,"props":289,"children":291},{"className":290},[],[292],{"type":48,"value":293},"0",{"type":48,"value":261},{"type":42,"tag":240,"props":296,"children":298},{"className":297},[],[299],{"type":48,"value":300},"1",{"type":48,"value":261},{"type":42,"tag":240,"props":303,"children":305},{"className":304},[],[306],{"type":48,"value":307},"3",{"type":48,"value":261},{"type":42,"tag":240,"props":310,"children":312},{"className":311},[],[313],{"type":48,"value":314},"6",{"type":48,"value":316}," (months)",{"type":42,"tag":209,"props":318,"children":319},{},[320,329,334],{"type":42,"tag":236,"props":321,"children":322},{},[323],{"type":42,"tag":240,"props":324,"children":326},{"className":325},[],[327],{"type":48,"value":328},"outcome",{"type":42,"tag":236,"props":330,"children":331},{},[332],{"type":48,"value":333},"Continuous response variable",{"type":42,"tag":236,"props":335,"children":336},{},[337,343,344,350,351],{"type":42,"tag":240,"props":338,"children":340},{"className":339},[],[341],{"type":48,"value":342},"42.3",{"type":48,"value":261},{"type":42,"tag":240,"props":345,"children":347},{"className":346},[],[348],{"type":48,"value":349},"38.1",{"type":48,"value":261},{"type":42,"tag":240,"props":352,"children":354},{"className":353},[],[355],{"type":48,"value":356},"29.5",{"type":42,"tag":209,"props":358,"children":359},{},[360,369,374],{"type":42,"tag":236,"props":361,"children":362},{},[363],{"type":42,"tag":240,"props":364,"children":366},{"className":365},[],[367],{"type":48,"value":368},"treatment",{"type":42,"tag":236,"props":370,"children":371},{},[372],{"type":48,"value":373},"Fixed effect predictor",{"type":42,"tag":236,"props":375,"children":376},{},[377,383,384],{"type":42,"tag":240,"props":378,"children":380},{"className":379},[],[381],{"type":48,"value":382},"control",{"type":48,"value":261},{"type":42,"tag":240,"props":385,"children":387},{"className":386},[],[388],{"type":48,"value":389},"treated",{"type":42,"tag":209,"props":391,"children":392},{},[393,402,407],{"type":42,"tag":236,"props":394,"children":395},{},[396],{"type":42,"tag":240,"props":397,"children":399},{"className":398},[],[400],{"type":48,"value":401},"covariate",{"type":42,"tag":236,"props":403,"children":404},{},[405],{"type":48,"value":406},"Optional: additional predictors",{"type":42,"tag":236,"props":408,"children":409},{},[410,416,417,423,424],{"type":42,"tag":240,"props":411,"children":413},{"className":412},[],[414],{"type":48,"value":415},"age",{"type":48,"value":261},{"type":42,"tag":240,"props":418,"children":420},{"className":419},[],[421],{"type":48,"value":422},"sex",{"type":48,"value":261},{"type":42,"tag":240,"props":425,"children":427},{"className":426},[],[428],{"type":48,"value":429},"baseline",{"type":42,"tag":51,"props":431,"children":432},{},[433,435,439,441,446],{"type":48,"value":434},"Data must be in ",{"type":42,"tag":57,"props":436,"children":437},{},[438],{"type":48,"value":148},{"type":48,"value":440}," (one row per observation per subject). Wide format (one column per time point) must be reshaped — ask the AI to ",{"type":42,"tag":162,"props":442,"children":443},{},[444],{"type":48,"value":445},"\"reshape from wide to long format first\"",{"type":48,"value":447},".",{"type":42,"tag":43,"props":449,"children":451},{"id":450},"interpreting-the-results",[452],{"type":48,"value":453},"Interpreting the Results",{"type":42,"tag":201,"props":455,"children":456},{},[457,473],{"type":42,"tag":205,"props":458,"children":459},{},[460],{"type":42,"tag":209,"props":461,"children":462},{},[463,468],{"type":42,"tag":213,"props":464,"children":465},{},[466],{"type":48,"value":467},"Output",{"type":42,"tag":213,"props":469,"children":470},{},[471],{"type":48,"value":472},"What it means",{"type":42,"tag":229,"props":474,"children":475},{},[476,492,508,524,540,556,572,588,604],{"type":42,"tag":209,"props":477,"children":478},{},[479,487],{"type":42,"tag":236,"props":480,"children":481},{},[482],{"type":42,"tag":57,"props":483,"children":484},{},[485],{"type":48,"value":486},"Fixed effect estimate (β)",{"type":42,"tag":236,"props":488,"children":489},{},[490],{"type":48,"value":491},"Population-average effect of each predictor — interpreted like regression coefficients",{"type":42,"tag":209,"props":493,"children":494},{},[495,503],{"type":42,"tag":236,"props":496,"children":497},{},[498],{"type":42,"tag":57,"props":499,"children":500},{},[501],{"type":48,"value":502},"95% CI on fixed effects",{"type":42,"tag":236,"props":504,"children":505},{},[506],{"type":48,"value":507},"Uncertainty in the population-level estimate",{"type":42,"tag":209,"props":509,"children":510},{},[511,519],{"type":42,"tag":236,"props":512,"children":513},{},[514],{"type":42,"tag":57,"props":515,"children":516},{},[517],{"type":48,"value":518},"t-value / p-value",{"type":42,"tag":236,"props":520,"children":521},{},[522],{"type":48,"value":523},"Significance of each fixed effect (approximate df from Satterthwaite or Kenward-Roger method)",{"type":42,"tag":209,"props":525,"children":526},{},[527,535],{"type":42,"tag":236,"props":528,"children":529},{},[530],{"type":42,"tag":57,"props":531,"children":532},{},[533],{"type":48,"value":534},"Random effect variance (σ²_u)",{"type":42,"tag":236,"props":536,"children":537},{},[538],{"type":48,"value":539},"How much subjects differ from each other in their intercepts (or slopes)",{"type":42,"tag":209,"props":541,"children":542},{},[543,551],{"type":42,"tag":236,"props":544,"children":545},{},[546],{"type":42,"tag":57,"props":547,"children":548},{},[549],{"type":48,"value":550},"Residual variance (σ²_ε)",{"type":42,"tag":236,"props":552,"children":553},{},[554],{"type":48,"value":555},"Within-subject residual variation unexplained by the model",{"type":42,"tag":209,"props":557,"children":558},{},[559,567],{"type":42,"tag":236,"props":560,"children":561},{},[562],{"type":42,"tag":57,"props":563,"children":564},{},[565],{"type":48,"value":566},"ICC (Intraclass Correlation)",{"type":42,"tag":236,"props":568,"children":569},{},[570],{"type":48,"value":571},"σ²_u / (σ²_u + σ²_ε) — proportion of variance due to between-subject differences",{"type":42,"tag":209,"props":573,"children":574},{},[575,583],{"type":42,"tag":236,"props":576,"children":577},{},[578],{"type":42,"tag":57,"props":579,"children":580},{},[581],{"type":48,"value":582},"BLUPs",{"type":42,"tag":236,"props":584,"children":585},{},[586],{"type":48,"value":587},"Subject-specific random effect predictions — used for individual trajectory plots",{"type":42,"tag":209,"props":589,"children":590},{},[591,599],{"type":42,"tag":236,"props":592,"children":593},{},[594],{"type":42,"tag":57,"props":595,"children":596},{},[597],{"type":48,"value":598},"AIC / BIC",{"type":42,"tag":236,"props":600,"children":601},{},[602],{"type":48,"value":603},"Model fit criteria for comparing alternative model specifications (lower = better)",{"type":42,"tag":209,"props":605,"children":606},{},[607,615],{"type":42,"tag":236,"props":608,"children":609},{},[610],{"type":42,"tag":57,"props":611,"children":612},{},[613],{"type":48,"value":614},"Caterpillar plot",{"type":42,"tag":236,"props":616,"children":617},{},[618],{"type":48,"value":619},"Random effects sorted with 95% CI — subjects whose CI excludes zero are reliably above/below average",{"type":42,"tag":43,"props":621,"children":623},{"id":622},"example-prompts",[624],{"type":48,"value":625},"Example Prompts",{"type":42,"tag":201,"props":627,"children":628},{},[629,645],{"type":42,"tag":205,"props":630,"children":631},{},[632],{"type":42,"tag":209,"props":633,"children":634},{},[635,640],{"type":42,"tag":213,"props":636,"children":637},{},[638],{"type":48,"value":639},"Scenario",{"type":42,"tag":213,"props":641,"children":642},{},[643],{"type":48,"value":644},"What to type",{"type":42,"tag":229,"props":646,"children":647},{},[648,661,674,687,700,717,734,751],{"type":42,"tag":209,"props":649,"children":650},{},[651,656],{"type":42,"tag":236,"props":652,"children":653},{},[654],{"type":48,"value":655},"Random intercept model",{"type":42,"tag":236,"props":657,"children":658},{},[659],{"type":48,"value":660},"`LMM: pain_score ~ time + treatment + (1",{"type":42,"tag":209,"props":662,"children":663},{},[664,669],{"type":42,"tag":236,"props":665,"children":666},{},[667],{"type":48,"value":668},"Random slope model",{"type":42,"tag":236,"props":670,"children":671},{},[672],{"type":48,"value":673},"`LMM with random slope: score ~ time + (1 + time",{"type":42,"tag":209,"props":675,"children":676},{},[677,682],{"type":42,"tag":236,"props":678,"children":679},{},[680],{"type":48,"value":681},"Interaction effect",{"type":42,"tag":236,"props":683,"children":684},{},[685],{"type":48,"value":686},"`LMM: outcome ~ time * group + (1",{"type":42,"tag":209,"props":688,"children":689},{},[690,695],{"type":42,"tag":236,"props":691,"children":692},{},[693],{"type":48,"value":694},"Clustered cross-sectional",{"type":42,"tag":236,"props":696,"children":697},{},[698],{"type":48,"value":699},"`LMM: test_score ~ SES + school_size + (1",{"type":42,"tag":209,"props":701,"children":702},{},[703,708],{"type":42,"tag":236,"props":704,"children":705},{},[706],{"type":48,"value":707},"Model comparison",{"type":42,"tag":236,"props":709,"children":710},{},[711],{"type":42,"tag":240,"props":712,"children":714},{"className":713},[],[715],{"type":48,"value":716},"fit 3 models: (1) random intercept, (2) random slope, (3) intercept + slope; compare AIC/BIC; likelihood ratio test",{"type":42,"tag":209,"props":718,"children":719},{},[720,725],{"type":42,"tag":236,"props":721,"children":722},{},[723],{"type":48,"value":724},"Variance components",{"type":42,"tag":236,"props":726,"children":727},{},[728],{"type":42,"tag":240,"props":729,"children":731},{"className":730},[],[732],{"type":48,"value":733},"report variance components: random intercept variance, residual variance, ICC; caterpillar plot of random intercepts",{"type":42,"tag":209,"props":735,"children":736},{},[737,742],{"type":42,"tag":236,"props":738,"children":739},{},[740],{"type":48,"value":741},"Missing data",{"type":42,"tag":236,"props":743,"children":744},{},[745],{"type":42,"tag":240,"props":746,"children":748},{"className":747},[],[749],{"type":48,"value":750},"LMM handles missing data; report how many observations per subject; compare to listwise deletion RM-ANOVA",{"type":42,"tag":209,"props":752,"children":753},{},[754,759],{"type":42,"tag":236,"props":755,"children":756},{},[757],{"type":48,"value":758},"Predictions",{"type":42,"tag":236,"props":760,"children":761},{},[762],{"type":42,"tag":240,"props":763,"children":765},{"className":764},[],[766],{"type":48,"value":767},"plot fixed effect trajectory with 95% CI band; overlay individual BLUPs for each subject",{"type":42,"tag":43,"props":769,"children":771},{"id":770},"assumptions-to-check",[772],{"type":48,"value":773},"Assumptions to Check",{"type":42,"tag":775,"props":776,"children":777},"ul",{},[778,788,798,808,818,835],{"type":42,"tag":134,"props":779,"children":780},{},[781,786],{"type":42,"tag":57,"props":782,"children":783},{},[784],{"type":48,"value":785},"Linearity",{"type":48,"value":787}," — the relationship between predictors and the outcome is linear at both the within-subject and between-subject level; inspect residual plots and consider adding polynomial terms or log-transforming skewed variables if curvature is visible",{"type":42,"tag":134,"props":789,"children":790},{},[791,796],{"type":42,"tag":57,"props":792,"children":793},{},[794],{"type":48,"value":795},"Normality of random effects",{"type":48,"value":797}," — random effects are assumed ~ N(0, σ²_u); inspect with a Q-Q plot of the BLUPs; moderate deviations are acceptable with n ≥ 50 clusters; severe non-normality (bimodal or heavily skewed BLUPs) may indicate model misspecification or unmodeled subgroups",{"type":42,"tag":134,"props":799,"children":800},{},[801,806],{"type":42,"tag":57,"props":802,"children":803},{},[804],{"type":48,"value":805},"Normality of residuals",{"type":48,"value":807}," — level-1 residuals (ε) should be approximately normal; check with a Q-Q plot; LMMs are robust to moderate non-normality with large datasets",{"type":42,"tag":134,"props":809,"children":810},{},[811,816],{"type":42,"tag":57,"props":812,"children":813},{},[814],{"type":48,"value":815},"Homoscedasticity",{"type":48,"value":817}," — residual variance should be constant across fitted values and time; heteroscedasticity can be addressed by modeling a variance structure (e.g., allowing variance to differ by group or increase over time)",{"type":42,"tag":134,"props":819,"children":820},{},[821,826,828,833],{"type":42,"tag":57,"props":822,"children":823},{},[824],{"type":48,"value":825},"Missing data mechanism",{"type":48,"value":827}," — LMMs produce valid estimates under ",{"type":42,"tag":57,"props":829,"children":830},{},[831],{"type":48,"value":832},"missing at random (MAR)",{"type":48,"value":834}," — missingness may depend on observed variables but not on unobserved outcomes; if data are missing not at random (MNAR, e.g., patients drop out because they got worse), LMM estimates will be biased and a selection model or pattern-mixture model is needed",{"type":42,"tag":134,"props":836,"children":837},{},[838,843],{"type":42,"tag":57,"props":839,"children":840},{},[841],{"type":48,"value":842},"Sufficient cluster size",{"type":48,"value":844}," — random effects are estimated from the variance across clusters; with \u003C 5–10 clusters, random effect variance estimates are unreliable; with > 30 clusters and ≥ 5 observations per cluster, LMM performs well",{"type":42,"tag":43,"props":846,"children":848},{"id":847},"related-tools",[849],{"type":48,"value":850},"Related Tools",{"type":42,"tag":51,"props":852,"children":853},{},[854,856,862,864,870,872,878,880,886],{"type":48,"value":855},"Use the ",{"type":42,"tag":178,"props":857,"children":859},{"href":858},"/tools/repeated-measures-anova",[860],{"type":48,"value":861},"Repeated Measures ANOVA Calculator",{"type":48,"value":863}," when you have balanced data (all subjects at all time points), no covariates, and want a simpler analysis — RM-ANOVA is a special case of LMM; for missing data or unbalanced designs, LMM is preferred. Use the ",{"type":42,"tag":178,"props":865,"children":867},{"href":866},"/tools/multiple-regression",[868],{"type":48,"value":869},"Multiple Regression",{"type":48,"value":871}," calculator for cross-sectional data where observations are independent — LMM is needed only when observations are clustered or repeated. Use the ",{"type":42,"tag":178,"props":873,"children":875},{"href":874},"/tools/cox-proportional-hazards",[876],{"type":48,"value":877},"Cox Proportional Hazards Model Calculator",{"type":48,"value":879}," when the outcome is time to an event (survival analysis) rather than a continuous measurement — the frailty model (Cox with random effects) is the survival analysis analogue of LMM. Use the ",{"type":42,"tag":178,"props":881,"children":883},{"href":882},"/tools/residual-plot",[884],{"type":48,"value":885},"Residual Plot Generator",{"type":48,"value":887}," to diagnose assumption violations in the LMM residuals after fitting.",{"type":42,"tag":43,"props":889,"children":891},{"id":890},"frequently-asked-questions",[892],{"type":48,"value":893},"Frequently Asked Questions",{"type":42,"tag":51,"props":895,"children":896},{},[897,902,904,909,911,916],{"type":42,"tag":57,"props":898,"children":899},{},[900],{"type":48,"value":901},"What is the difference between a mixed effects model and repeated measures ANOVA?",{"type":48,"value":903},"\nRepeated measures ANOVA and LMM answer the same question but under different constraints. RM-ANOVA requires ",{"type":42,"tag":57,"props":905,"children":906},{},[907],{"type":48,"value":908},"complete, balanced data",{"type":48,"value":910}," (every subject measured at every time point), does not easily handle time-varying covariates, and uses an F-test based on the sphericity assumption. LMM handles ",{"type":42,"tag":57,"props":912,"children":913},{},[914],{"type":48,"value":915},"unbalanced and missing data",{"type":48,"value":917}," (using all available observations per subject under MAR), naturally incorporates time-varying and between-subject covariates, allows random slopes (heterogeneous rates of change), and models the correlation structure explicitly. For simple balanced designs without covariates, the two approaches give equivalent results. For anything more complex — missing data, unequal time points, subject-specific slopes, multiple random factors — LMM is the appropriate tool.",{"type":42,"tag":51,"props":919,"children":920},{},[921,926,928,933],{"type":42,"tag":57,"props":922,"children":923},{},[924],{"type":48,"value":925},"What does the ICC tell me and why does it matter?",{"type":48,"value":927},"\nThe ",{"type":42,"tag":57,"props":929,"children":930},{},[931],{"type":48,"value":932},"intraclass correlation coefficient (ICC)",{"type":48,"value":934}," = σ²_u / (σ²_u + σ²_ε) measures what fraction of total outcome variance is due to between-subject (between-cluster) differences. ICC = 0.63 means 63% of variance in pain scores is explained by stable patient-level characteristics — patients are remarkably consistent relative to within-patient fluctuation. High ICC (> 0.5) means individual differences dominate and modeling them is critical — ignoring clustering (using ordinary regression) would severely underestimate standard errors and produce false-positive fixed effect tests. Low ICC (\u003C 0.05) means clustering has little impact and ordinary regression is adequate. ICC also informs sample size calculations for clustered designs: high ICC requires more clusters to achieve the same power as an unclustered design.",{"type":42,"tag":51,"props":936,"children":937},{},[938,943,945,950,952,957],{"type":42,"tag":57,"props":939,"children":940},{},[941],{"type":48,"value":942},"Should I use maximum likelihood (ML) or restricted maximum likelihood (REML)?",{"type":48,"value":944},"\nUse ",{"type":42,"tag":57,"props":946,"children":947},{},[948],{"type":48,"value":949},"REML",{"type":48,"value":951}," (restricted maximum likelihood) when estimating variance components (random effect variances, ICC) and when you are not comparing models with different fixed effects — REML produces unbiased variance estimates. Use ",{"type":42,"tag":57,"props":953,"children":954},{},[955],{"type":48,"value":956},"ML",{"type":48,"value":958}," when comparing models with different fixed effects structures using likelihood ratio tests (LRT) — REML likelihood values are not comparable across models with different fixed effect specifications because REML integrates out the fixed effects. The practical workflow: use REML for your final model's parameter estimates and standard errors; use ML for model selection (comparing models with different fixed effects by LRT or AIC/BIC).",{"type":42,"tag":51,"props":960,"children":961},{},[962,967,969,974,976,981,983,988,990,995,997,1002,1004,1009],{"type":42,"tag":57,"props":963,"children":964},{},[965],{"type":48,"value":966},"My model won't converge — what should I do?",{"type":48,"value":968},"\nConvergence problems are common in complex random effects structures. Try these fixes in order: (1) ",{"type":42,"tag":57,"props":970,"children":971},{},[972],{"type":48,"value":973},"Simplify the random effects",{"type":48,"value":975}," — remove random slopes and start with random intercept only; (2) ",{"type":42,"tag":57,"props":977,"children":978},{},[979],{"type":48,"value":980},"Scale your predictors",{"type":48,"value":982}," — center continuous predictors (subtract mean) and standardize (divide by SD); unscaled predictors create numerical issues; (3) ",{"type":42,"tag":57,"props":984,"children":985},{},[986],{"type":48,"value":987},"Check for multicollinearity",{"type":48,"value":989}," — highly correlated predictors cause estimation instability; (4) ",{"type":42,"tag":57,"props":991,"children":992},{},[993],{"type":48,"value":994},"Increase iterations",{"type":48,"value":996}," — some optimizers need more iterations for complex models; (5) ",{"type":42,"tag":57,"props":998,"children":999},{},[1000],{"type":48,"value":1001},"Try a different optimizer",{"type":48,"value":1003}," — switch between L-BFGS-B, Nelder-Mead, and Powell; (6) ",{"type":42,"tag":57,"props":1005,"children":1006},{},[1007],{"type":48,"value":1008},"Reduce model complexity",{"type":48,"value":1010}," — if random slope variance is estimated near zero, remove that random slope; a near-zero random effect variance is a sign it is not needed.",{"title":7,"searchDepth":1012,"depth":1012,"links":1013},2,[1014,1015,1016,1017,1018,1019,1020,1021],{"id":45,"depth":1012,"text":49},{"id":125,"depth":1012,"text":128},{"id":196,"depth":1012,"text":199},{"id":450,"depth":1012,"text":453},{"id":622,"depth":1012,"text":625},{"id":770,"depth":1012,"text":773},{"id":847,"depth":1012,"text":850},{"id":890,"depth":1012,"text":893},"markdown","content:tools:075.mixed-effects-model.md","content","tools/075.mixed-effects-model.md","tools/075.mixed-effects-model","md",{"loc":4},1775502472550]