smoking-jags"

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(BCEA)

Load the R2jags package and the the data file

library(R2jags)

Specify the name of the jags model file.

model.file <- here::here("inst/jags/smoking_model_RE.txt")

Load smoking data.

data("Smoking")

Copy smoking data frame columns to local variables.

attach(smoking)
nobs <- nobs
s <- s
t <- i
r <- r_i
n <- n_i
b <- b_i + 1
detach(smoking)
# number of trials
ns <- length(unique(s))

# number of comparators
nt <- length(unique(t))

# number of observations
nobs <- dim(smoking)[1]

# how many studies include baseline
incb <- sum(table(s, b)[, 1] > 0)

Define data and parameters to monitor and run.

inputs <- list ("s", "n", "r", "t", "ns", "nt", "b", "nobs", "incb")#, "na")
pars <- c("rr ", "pi ", "p", "d", "sd ")#, "T")

smoking_output <-
  jags(
    data = inputs,
    inits = NULL,
    parameters.to.save = pars,
    model.file = model.file,
    n.burnin = 5000,
    n.chains = 2,
    n.iter = 10000,
    n.thin = 20)
smoking_output
save(smoking_output, file = here::here("inst/extdata/smoking_output.RData"))


Try the BCEA package in your browser

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

BCEA documentation built on Nov. 25, 2023, 5:08 p.m.