This document illustrates use of barca package for the Type V GBS case-control data.

topconc = 2
suppressPackageStartupMessages({
library(barca)
library(modeest)
})

Type V illustration

The layout of the input data is:

dat = read.csv(system.file("csv/TypeV.csv", package="barca"))
head(dat)

Here we manage the access to the data, the hyperparameter selections, and execution of limited MCMC sampling.

library(barca)
bugpath = system.file("bugs/weib.bug", package="barca")
curtext = readLines(bugpath)
curtext = barca:::editBugPars(curtext, beta_a=25, beta_b=2500)
jnk = csv2jags("TypeV") # formatted
dV = read.jagsdata("TypeV.jagsdata")
writeLines(curtext, "TypeV.bug")
mV = jags.model("TypeV.bug", data=dV, inits= 
    list( llam= c(.75,.5), v = c(.75,.5)), n.chains = 3, quiet=TRUE)
update(mV, 5000, progress.bar="none")
cV = coda.samples(mV, "post", 10000, progress.bar="none")
cV.summ = summary(cV)

Plot quantiles of pointwise posterior risk.

xco = matrix(seq(.1,topconc,.1),nc=1)
matplot(xco, cV.summ[[2]], xlab="anti-GBS Type V conc.",
   ylab="posterior risk")

Posterior modes and posterior 75th percentiles.

getModes = function(run) {
 sapply(run, function(z) apply(z,2,function(w)mlv(w,method="venter", type="shorth")))
}

getQ3 = function(run) {
 sapply(run, function(z) apply(z,2,function(w)quantile(w, .75)))
}

doplot = function(run, type="Ia", at0=.01, topconc=2, toprate=1.2) {
 m = rowMeans(getModes(run))
 q = rowMeans(getQ3(run))
 x = seq(0,topconc,len=length(q)+1)
 plot(x, 100*c(at0, m), pch=19, ylim=c(0,toprate), ylab="Risk of Disease (per 100 Live Births)",
   xlab = paste(type, "CPS-Specific IgG (ug/ml)"))
 points(x, 100*c(at0, q), pch=17)
}

doplot(cV, type="V")

Type III illustration

bugpath = system.file("bugs/weib.bug", package="barca")
curtext = readLines(bugpath)
curtext = barca:::editBugPars(curtext, beta_a=25, beta_b=2500)
jnk = csv2jags("TypeIII") # formatted
dIII = read.jagsdata("TypeIII.jagsdata")
writeLines(curtext, "TypeIII.bug")
mIII = jags.model("TypeIII.bug", data=dIII, inits= 
    list( llam= c(.75,.5), v = c(.75,.5)), n.chains = 3, quiet=TRUE)
update(mIII, 5000, progress.bar="none")
cIII = coda.samples(mIII, "post", 10000, progress.bar="none")
cIII.summ = summary(cIII)
doplot(cIII, type="III")

barca

Bayesian absolute risk with case-control data. This is an R package that uses the JAGS system to perform sensitivity analysis for the relationship between antibody concentration and disease risk.

Application: inference on protective antibody concentrations in case-control study of Group B Strep infections in neonates.

Reference: https://www.ncbi.nlm.nih.gov/pubmed/11252588 (Carey VJ, Baker CJ, Platt R. Bayesian inference on protective antibody levels using case-control data. Biometrics 2001 Mar;57(1):135-42.)



vjcitn/barca documentation built on June 16, 2020, 11:18 p.m.