0

我正在尝试创建如下图(取自https://cran.r-project.org/web/packages/dotwhisker/vignettes/dotwhisker-vignette.html),但没有截距,也没有重新缩放:

我一直在关注 https://cran.r-project.org/web/packages/glmmTMB/vignettes/model_evaluation.pdf中的代码:

if (requireNamespace("broom.mixed") && requireNamespace("dotwhisker")) {
(t1 <- broom.mixed::tidy(owls_nb1, conf.int = TRUE))
if (packageVersion("dotwhisker")>"0.4.1") {
## to get this version (which fixes various dotwhisker problems)
## use devtools::install_github("bbolker/broom.mixed") or
## wait for pull request acceptance/submission to CRAN/etc.
dwplot(owls_nb1)+geom_vline(xintercept=0,lty=2)
} else {
owls_nb1$coefficients <- TRUE ## hack!
dwplot(owls_nb1,by_2sd=FALSE)+geom_vline(xintercept=0,lty=2)
}
} 

我尝试通过以下方式应用此代码以实现多个模型的 dwplot(没有截距且没有重新缩放):

mod1 <- glmmTMB(Species1_Occupancy ~ offset(log(Study_Unit_Area)) + (1|Site) + scale(Var1) + scale(Var2) + scale(Var3) + scale(Var4) + scale(Var5) + scale(Var6), data=data, family=binomial(link="cloglog"))

mod2 <- glmmTMB(Species2_Occupancy ~ offset(log(Study_Unit_Area)) + (1|Site) + scale(Var1) + scale(Var2) + scale(Var3) + scale(Var4) + scale(Var5) + scale(Var6), data=data, family=binomial(link="cloglog")) 

mod3 <- glmmTMB(Species3_Occupancy ~ offset(log(Study_Unit_Area)) + (1|Site) + scale(Var1) + scale(Var2) + scale(Var3) + scale(Var4) + scale(Var5) + scale(Var6), data=data, family=binomial(link="cloglog"))      

dwplot(list(mod1,mod2,mod3), show_intercept = FALSE, by_2sd = FALSE)

但我收到此错误消息:

Error in tidy.glmmTMB(., conf.int = TRUE, ...) : 
  unknown effect type list(par = c(beta = 0, beta = 0, beta = 0, beta = 0, beta = 0, beta = 0, beta = 0, theta = 0), fn = function (x = last.par[-random], ...) 
{
    if (tracepar) {
        cat("par:\n")
        print(x)
    }
    if (!validpar(x)) 
        return(NaN)
    ans <- try({
        if (MCcontrol$doMC) {
        ff(x, order = 0)
        MC(last.par, n = MCcontrol$n, seed = MCcontrol$seed, order = 0)
    }
    else ff(x, order = 0)
}, silent = silent)
if (is.character(ans)) 
    NaN
else ans
}, gr = function (x = last.par[-random], ...) 
{
ans <- try({
    if (MCcontrol$doMC) {
        ff(x, order = 0)
        MC(last.par, n = MCcontrol$n, seed = MCcontrol$seed, order = 1)
        }
        else ff(x, order = 1)
    }, silent = silent)
    if (is.character(ans)) 
        ans <- rep(NaN, length(x))
    if (tracemgc) 
        cat("outer mgc: ", max(abs(ans)), "\n")
    ans
}, he = function (x = last.par[-random], ...) 
{

当我在没有该by_2sd()功能的情况下运行它时,我没有收到错误消息,但仍显示截距。

dwplot(list(mod1,mod2,mod3), show_intercept = FALSE)

任何帮助将非常感激。

4

0 回答 0