# \donttest{
# Using the triptans data
network <- mbnma.network(triptans)
######## Dose-response functions ########
# Fit a dose-response MBNMA with a linear function
# with common treatment effects
result <- mbnma.run(network, fun=dpoly(degree=1), method="common")
# Fit a dose-response MBNMA with a log-linear function
# with random treatment effects
result <- mbnma.run(network, fun=dloglin(), method="random")
# Fit a dose-response MBNMA with a fractional polynomial function
# with random treatment effects
# with a probit link function
result <- mbnma.run(network, fun=dfpoly(), method="random", link="probit")
# Fit a user-defined function (quadratic)
fun.def <- ~ (beta.1 * dose) + (beta.2 * (dose^2))
result <- mbnma.run(network, fun=duser(fun=fun.def), method="common")
# Fit an Emax function
# with a single random (exchangeable) parameter for ED50
# with common treatment effects
result <- mbnma.run(network, fun=demax(emax="rel", ed50="random"),
method="common")
# Fit an Emax function with a Hill parameter
# with a fixed value of 5 for the Hill parameter
# with random relative effects
result <- mbnma.run(network, fun=demax(hill=5), method="random")
# Fit a model with natural cubic splines
# with 3 knots at 10% 30% and 60% quartiles of dose ranges
depnet <- mbnma.network(ssri) # Using the sSRI depression dataset
result <- mbnma.run(depnet, fun=dspline(type="ns", knots=c(0.1,0.3,0.6)))
# Fit a model with different dose-response functions for each agent
multifun <- dmulti(list(dloglin(), # for placebo (can be any function)
demax(), # for eletriptan
demax(), # for sumatriptan
dloglin(), # for frovatriptan
demax(), # for almotriptan
demax(), # for zolmitriptan
dloglin(), # for naratriptan
demax())) # for rizatriptan
multidose <- mbnma.run(network, fun=multifun)
########## Class effects ##########
# Using the osteoarthritis dataset
pain.df <- osteopain
# Set a shared class (NSAID) only for Naproxcinod and Naproxen
pain.df <- pain.df %>% dplyr::mutate(
class = dplyr::case_when(agent %in% c("Naproxcinod", "Naproxen") ~ "NSAID",
!agent %in% c("Naproxcinod", "Naproxen") ~ agent
)
)
# Run an Emax MBNMA with a common class effect on emax
painnet <- mbnma.network(pain.df)
result <- mbnma.run(painnet, fun = demax(),
class.effect = list(emax = "common"))
####### Priors #######
# Obtain priors from a fractional polynomial function
result <- mbnma.run(network, fun=dfpoly(degree=1), method="random")
print(result$model.arg$priors)
# Change the prior distribution for the power
newpriors <- list(power.1 = "dnorm(0,0.001) T(0,)")
newpriors <- list(sd = "dnorm(0,0.5) T(0,)")
result <- mbnma.run(network, fun=dfpoly(degree=1), method="random",
priors=newpriors)
########## Sampler options ##########
# Change the number of MCMC iterations, the number of chains, and the thin
result <- mbnma.run(network, fun=dloglin(), method="random",
n.iter=5000, n.thin=5, n.chains=4)
####### Examine MCMC diagnostics (using mcmcplots or coda packages) #######
# Density plots
mcmcplots::denplot(result)
# Traceplots
mcmcplots::traplot(result)
# Caterpillar plots
mcmcplots::caterplot(result, "rate")
# Autocorrelation plots (using the coda package)
coda::autocorr.plot(coda::as.mcmc(result))
####### Automatically run jags until convergence is reached #########
# Rhat of 1.08 is set as the criteria for convergence
#on all monitored parameters
conv.res <- mbnma.run(network, fun=demax(),
method="random",
n.iter=10000, n.burnin=9000,
autojags=TRUE, Rhat=1.08, n.update=8)
########## Output ###########
# Print R2jags output and summary
print(result)
summary(result)
# Plot forest plot of results
plot(result)
# }
Run the code above in your browser using DataLab