if (FALSE) {
data(RandomVA1)
fit0<- insilico(RandomVA1, subpop = NULL,
Nsim = 20, burnin = 10, thin = 1 , seed = 1,
auto.length = FALSE)
summary(fit0)
summary(fit0, id = "d199")
##
## Scenario 1: standard input without sub-population specification
##
fit1<- insilico(RandomVA1, subpop = NULL,
Nsim = 1000, burnin = 500, thin = 10 , seed = 1,
auto.length = FALSE)
summary(fit1)
plot(fit1)
##
## Scenario 2: standard input with sub-population specification
##
data(RandomVA2)
fit2<- insilico(RandomVA2, subpop = list("sex"),
Nsim = 1000, burnin = 500, thin = 10 , seed = 1,
auto.length = FALSE)
summary(fit2)
plot(fit2, type = "compare")
plot(fit2, which.sub = "Men")
##
## Scenario 3: standard input with multiple sub-population specification
##
fit3<- insilico(RandomVA2, subpop = list("sex", "age"),
Nsim = 1000, burnin = 500, thin = 10 , seed = 1,
auto.length = FALSE)
summary(fit3)
##
## Scenario 3: standard input with multiple sub-population specification
##
fit3<- insilico(RandomVA2, subpop = list("sex", "age"),
Nsim = 1000, burnin = 500, thin = 10 , seed = 1,
auto.length = FALSE)
summary(fit3)
##
## Scenario 5 - 7 are special situations rarely needed in practice,
## but included here for completeness.
## The below examples use no sub-population or physician codes,
## but specifying sub-population is still possible as in Scenario 2 - 4.
##
##
## Scenario 5: skipping re-estimation of conditional probabilities
##
# Though in practice the need for this situation is very unlikely,
# use only the default conditional probabilities without re-estimation
fit5<- insilico(RandomVA1, subpop = NULL,
Nsim = 1000, burnin = 500, thin = 10 , seed = 1,
updateCondProb = FALSE,
auto.length = FALSE)
summary(fit5)
##
## Scenario 6: modify default conditional probability matrix
##
# Load the default conditional probability matrix
data(condprob)
# The conditional probabilities are given in levels such as I, A+, A, A-, etc.
condprob[1:5, 1:5]
# To modify certain cells
new_cond_prob <- condprob
new_cond_prob["elder", "HIV/AIDS related death"] <- "C"
# or equivalently
new_cond_prob[1, 3] <- "C"
fit6<- insilico(RandomVA1, subpop = NULL,
Nsim = 1000, burnin = 500, thin = 10 , seed = 1,
CondProb = new_cond_prob,
auto.length = FALSE)
# note: compare this with fit1 above to see the change induced
# by changing Pr(elder | HIV) from "C+" to "C".
summary(fit6)
##
## Scenario 7: modify default numerical values in conditional probabilities directly
##
# Load the default conditional probability matrix
data(condprobnum)
# The conditional probabilities are given in numerical values in this dataset
condprobnum[1:5, 1:5]
# To modify certain cells, into any numerical values you want
new_cond_prob_num <- condprobnum
new_cond_prob_num["elder", "HIV/AIDS related death"] <- 0.004
# or equivalently
new_cond_prob_num[1, 3] <- 0.005
fit7<- insilico(RandomVA1, subpop = NULL,
Nsim = 1000, burnin = 500, thin = 10 , seed = 1,
CondProbNum = new_cond_prob_num,
auto.length = FALSE)
# note: compare this with fit1, fit5, and fit6
summary(fit7)
##
## Scenario 8: physician coding
## see also the examples in physician_debias() function section
##
# Load sample input for physicians
data(RandomPhysician)
# The symptom section looks the same as standard input
head(RandomPhysician[, 1:5])
# At the end of file, including a few more columns of physician id and coded cause
head(RandomPhysician[, 245:250])
# load Cause Grouping (if physician-coded causes are in larger categories)
data(SampleCategory)
head(SampleCategory)
# existing doctor codes in the sample dataset
doctors <- paste0("doc", c(1:15))
causelist <- c("Communicable", "TB/AIDS", "Maternal",
"NCD", "External", "Unknown")
phydebias <- physician_debias(RandomPhysician,
phy.id = c("rev1", "rev2"), phy.code = c("code1", "code2"),
phylist = doctors, causelist = causelist,
tol = 0.0001, max.itr = 100)
fit8 <- insilico(RandomVA1, subpop = NULL,
Nsim = 1000, burnin = 500, thin = 10 , seed = 1,
phy.debias = phydebias,
phy.cat = SampleCategory,
phy.external = "External", phy.unknown = "Unknown",
auto.length = FALSE)
summary(fit8)
# example to fit WHO2016 data
data(RandomVA5)
fit1a <- insilico(RandomVA5, data.type="WHO2016", subpop = NULL,
Nsim = 1000, burnin = 500, thin = 10 , seed = 1,
auto.length = FALSE)
summary(fit1a)
plot(fit1)
# example to change directory for error files
fit1b <- insilico(RandomVA5[1:50, ], data.type="WHO2016",
Nsim = 1000, burnin = 500, thin = 10 ,
seed = 1, auto.length=F)
fit1c <- insilico(RandomVA5[1:50, ], data.type="WHO2016",
Nsim = 1000, burnin = 500, thin = 10 ,
seed = 1, auto.length=F)
# similarly for WHO 2012 version
fit1<- insilico(RandomVA1, subpop = NULL,
Nsim = 1000, burnin = 500, thin = 10 , seed = 1,
auto.length = FALSE)
}
Run the code above in your browser using DataLab