QCSunny Lab

Mixed Effects Model (Random Intercept)混合效应模型(随机截距)

The FIRST column is the group id, the LAST column is the response; columns in between are fixed-effect regressors. An intercept is added automatically.第一列为组编号,最后一列为因变量,中间各列为固定效应自变量,自动添加截距。

A linear mixed model separates fixed effects (shared by every group) from random intercepts and optional random slopes (one draw per group): y = Xβ + ZGu + ε. This tool fits it by maximum profile likelihood — the variance components are optimised directly and the fixed effects are the GLS solution at each candidate.

The ICC (intra-class correlation) is the share of total variance that sits between groups — the single number that says whether clustering matters. Group-specific blocks are inverted through the Woodbury identity, so cost grows with group size squared, not sample size squared.

Frequently asked questions

Mixed model or clustered standard errors?

Clustered SEs answer "are my fixed-effect standard errors right given grouping?"; a mixed model additionally estimates how much groups differ and predicts each group's offset. Use the former for population-average claims, the latter for group-level structure.

Why is my random slope variance near zero?

Often the data genuinely has no slope variation between groups. The optimiser in log-space can then push that variance toward the boundary — the fixed effects remain valid.

中文说明

线性混合模型把固定效应(各组共享)与随机截距、可选随机斜率(每组一次抽取)分开:y = Xβ + ZGu + ε。本工具以极大剖面似然拟合——直接优化方差成分,固定效应取每个候选点的 GLS 解。

ICC(组内相关系数)是组间方差占总方差的比例——它一个数就能说明“分组是否重要”。组内分块经 Woodbury 恒等式求逆,代价随组大小平方而非样本量平方增长。

常见问题

用混合模型还是聚类稳健标准误?

聚类标准误回答“考虑分组后固定效应的标准误对不对”;混合模型还估计组间差异并预测每组的偏移。总体平均结论用前者,组级结构用后者。

随机斜率方差为什么接近 0?

常见原因是各组斜率确实没有差异。对数空间优化会把该方差推向边界——固定效应依然有效。