You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

线性混合效应模型表格生成求助:sjt.lmer报错及Broom输出问题

Hey there! Let's work through your linear mixed-effects model table generation problems one by one.

Fixing the sjt.lmer() Issue

First off, that message you're seeing:

Computing p-values via Kenward-Roger approximation. Use p.kr = FALSE if computation takes too long.

is actually an informational prompt, not a hard error—but it might cause delays or prevent table rendering if the approximation takes too long (especially with larger datasets). Here's how to address it:

  • Switch to faster p-value calculation: As the message suggests, add the p.kr = FALSE argument to use Wald tests instead, which are quicker. Try this code:
    sjt.lmer(fit1, p.kr = FALSE)
    
  • Install required dependencies: The Kenward-Roger approximation relies on the pbkrtest package. If you haven't installed it yet, run:
    install.packages("pbkrtest")
    
    Reload sjPlot and try generating the table again.
  • Update sjPlot: Outdated versions might have compatibility issues with lme4. Refresh the package with:
    install.packages("sjPlot")
    

If you still hit snags, check if your model has convergence problems using isSingular(fit1)—singular models can sometimes break table generation tools.

Getting the Right Output with Broom/Tidyverse

The core issue here is that the base broom package has limited support for lmer objects. You'll want to use broom.mixed, which is built specifically for mixed-effects models. Here's how to get the exact outputs you need:

  1. Install and load broom.mixed:

    install.packages("broom.mixed")
    library(broom.mixed)
    
  2. Extract fixed effects (with confidence intervals and p-values):
    This gives you the same core details as summary(fit1) for fixed effects, formatted for easy table use:

    fixed_table <- tidy(fit1, effects = "fixed", conf.int = TRUE)
    # Format it nicely (round values, select key columns)
    fixed_table %>%
      select(term, estimate, std.error, conf.low, conf.high, p.value) %>%
      mutate(across(c(estimate, std.error, conf.low, conf.high), round, 3))
    
  3. Extract random effect variance components:
    To get variance estimates for your Week and Pair random intercepts (matching the output from rand(fit1)), use:

    random_vars <- tidy(fit1, effects = "ran_pars")
    
  4. Extract ANOVA-style results:
    If you want a table equivalent of anova(fit1), run:

    anova_table <- tidy(anova(fit1))
    

You can combine or rearrange these tables using dplyr or formatting packages like gt/kableExtra to match the exact report-ready format you need.

内容的提问来源于stack exchange,提问作者Amanda

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 04:12:57