inst/doc/tab_bayes.R

params <-
list(EVAL = FALSE)

## ----echo = FALSE-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE, 
  comment = "#>", 
  message = FALSE
)

m1 <- m2 <- NULL

if (!requireNamespace("insight", quietly = TRUE) ||
    !requireNamespace("httr", quietly = TRUE) ||
    !requireNamespace("brms", quietly = TRUE)) {
  knitr::opts_chunk$set(eval = FALSE)
} else {
  knitr::opts_chunk$set(eval = TRUE)
  library(insight)
  library(httr)
  library(sjPlot)
  library(brms)
  m1 <- tryCatch(insight::download_model("brms_zi_2"), error = function(e) NULL)
  m2 <- tryCatch(insight::download_model("brms_mv_3"), error = function(e) NULL)
}

if (is.null(m1) || is.null(m2)) {
  knitr::opts_chunk$set(eval = FALSE)
}

## ---- results='hide', message=FALSE, warning=FALSE, eval=FALSE----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#  # load required packages
#  library(sjPlot)
#  library(brms)
#  
#  # sample models
#  zinb <- read.csv("http://stats.idre.ucla.edu/stat/data/fish.csv")
#  set.seed(123)
#  m1 <- brm(bf(
#      count ~ persons + child + camper + (1 | persons),
#      zi ~ child + camper + (1 | persons)
#    ),
#    data = zinb,
#    family = zero_inflated_poisson()
#  )
#  
#  data(epilepsy)
#  set.seed(123)
#  epilepsy$visit <- as.numeric(epilepsy$visit)
#  epilepsy$Base2 <- sample(epilepsy$Base, nrow(epilepsy), replace = TRUE)
#  f1 <- bf(Base ~ zAge + count + (1 |ID| patient))
#  f2 <- bf(Base2 ~ zAge + Trt + (1 |ID| patient))
#  m2 <- brm(f1 + f2 + set_rescor(FALSE), data = epilepsy)

## -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
tab_model(m1)

## -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
tab_model(m2)

## -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
tab_model(m2, show.ci50 = TRUE)

## -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
tab_model(m1, m2)

Try the sjPlot package in your browser

Any scripts or data that you put into this service are public.

sjPlot documentation built on Aug. 17, 2023, 5:11 p.m.