# NOT RUN {
#Print data
data("LDL")
LDL
###
# Run analysis from Dobi & Zempleni 2019.
# Note that the code below is generated with updated HUF-EUR rate and
# a more accurate R implementation than in the original paper.
stat_LDL_cost <- Markovstat(
shiftfun = 'exp', h = 50, k = 3.15-LDL$target_value,
sigma = LDL$standard_deviation,
s = LDL$num_exp_daily_shifts,
delta = LDL$expected_shift_size,
RanRep = TRUE, alpha = LDL$rep_size_first, beta = LDL$rep_size_second,
RanSam = TRUE, q = LDL$samp_prob_first, z = LDL$samp_prob_second,
Vd = 100, V = 6-LDL$target_value)
# }
# NOT RUN {
#Defining parallel_opt parallel settings.
#parallel_opt can also be left empty to be defined automatically by the function.
require(parallel)
num_workers <- min(c(detectCores(),2))
parall <- list(cl=makeCluster(num_workers), forward=FALSE, loginfo=TRUE)
res_LDL_cost <- Markovchart(
statdist = stat_LDL_cost,
OPTIM = TRUE, p = 1,
cs = LDL$sampling_cost,
cf = LDL$base_rep_cost,
coparams = c(0,LDL$OOC_cost),
crparams = c(LDL$base_rep_cost,LDL$prop_rep_cost),
parallel_opt = parall)
num_workers <- min(c(detectCores(),2))
parall <- list(cl=makeCluster(num_workers), forward=FALSE, loginfo=TRUE)
res_LDL_cost_grid <- Markovchart(
statdist = stat_LDL_cost,
h=seq(50,75,2.5),
k=seq(0.05,0.25,0.02),
p = 1,
cs = LDL$sampling_cost,
cf = LDL$base_rep_cost,
coparams = c(0,LDL$OOC_cost),
crparams = c(LDL$base_rep_cost,LDL$prop_rep_cost),
parallel_opt = parall)
require(ggplot2)
plot(res_LDL_cost_grid,
y = 'Expected \ndaily cost',
mid = '#ff9494',
high = '#800000',
xlab = 'Days between samplings',
ylab = 'Critical LDL increase') +
geom_point(aes(x = res_LDL_cost$Parameters[[1]],
y = res_LDL_cost$Parameters[[2]]))
# }
Run the code above in your browser using DataLab