Как применить аргументы к многомодельному точечному и усеченному графику коэффициентов? - PullRequest
0 голосов
/ 01 мая 2020

Я пытаюсь создать график, подобный следующему (взят из 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<span class="math-container">$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$</span>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)

Любая помощь будет принята с благодарностью.

...