Mixed-effects logistic regression is widely used for binary outcomes in hierarchical data, yet formal goodness-of-fit tests remain limited to random-intercept models and do not address sparse cluster settings. We extend a grouping-based Wald test to mixed-effects logistic models with random slopes. The procedure groups observations by predicted probabilities within clusters, augments the model with pooled group indicators, and tests their joint significance using a Wald statistic. To accommodate small clusters, we introduce a data-driven rule for selecting the number of groups, G=min(10,n_min), where n_min is the smallest cluster size, ensuring feasible estimation. Simulation studies across 24 null scenarios show that the test maintains nominal Type I error in three-level random slope models, including at smaller sample sizes than previously studied. The test exhibits increasing power to detect fixed-effects misspecification: power against omitted nonlinearity rises from 0.07 to 1.00 across effect sizes, and power against omitted interactions reaches 0.87. As expected, the test has no power to detect omission of a clustering level, reflecting its focus on residual structure in predicted probabilities. In sparse balanced designs, fixing G=10 leads to complete test failure, whereas the data-driven rule performs reliably. The method is implemented in the Stata program mlm_gof.
翻译:混合效应Logistic回归广泛应用于分层数据中的二元结局变量,但现有的正式拟合优度检验仅局限于随机截距模型,且无法应对稀疏聚类场景。本文将基于分组的Wald检验拓展至含随机斜率的混合效应Logistic模型。该流程按聚类内预测概率对观测值分组,为模型添加合并组别指标,并采用Wald统计量检验其联合显著性。为适应小样本聚类,我们引入数据驱动规则确定组数G=min(10,n_min)(其中n_min为最小聚类规模),确保估计可行性。针对24种零假设情景的模拟研究表明,该检验在三水平随机斜率模型中能够维持名义第一类错误率,包括在较既往研究更小样本量下的表现。检验对固定效应误设的检测效能呈递增趋势:针对遗漏非线性项的检验效能随效应量从0.07增至1.00,针对遗漏交互项的检验效能可达0.87。符合预期的是,该检验对遗漏聚类层级无检测能力,这反映了其对预测概率残差结构的聚焦。在稀疏均衡设计中,固定G=10导致检验完全失效,而数据驱动规则表现稳健。该方法已在Stata程序mlm_gof中实现。