## visualize random valuesboxplot(las =1,ylab ="Disability Weight",cbind("Mild"= sim_dw_dia_mld,"Moderate"= sim_dw_dia_mod,"Severe"= sim_dw_dia_sev))
Fit to a confidence interval
Gamma distribution
## function for fittingfit_gamma <-function(q, p =0.95) { p <-c(0, p) + (1- p)/2 f <-function(x, p, target) { dev <-qgamma(p = p, shape = x[1], rate = x[2])return(sum((dev - target) ^2)) } fit <-optim(par =c(1, 1), fn = f, p = p, target = q)return(fit$par)}
Simulate based on mean and SE
## Gamma distributionrgamma2 <-function(n, m, s) {rgamma(n, m^2/s^2, m/s^2)}## Beta distributionrbeta2 <-function(n, m, s) { a <- m^2* ((1- m) / s^2-1/ m) b <- (1/m -1) * arbeta(n, a, b)}
R session info
sessionInfo()
R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale:
[1] LC_COLLATE=English_Belgium.utf8 LC_CTYPE=English_Belgium.utf8
[3] LC_MONETARY=English_Belgium.utf8 LC_NUMERIC=C
[5] LC_TIME=English_Belgium.utf8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] digest_0.6.29 jsonlite_1.8.0 magrittr_2.0.3 evaluate_0.16
[5] rlang_1.0.6 stringi_1.7.8 cli_3.4.1 rstudioapi_0.14
[9] rmarkdown_2.16 tools_4.2.1 stringr_1.4.1 htmlwidgets_1.5.4
[13] xfun_0.32 yaml_2.3.5 fastmap_1.1.0 compiler_4.2.1
[17] htmltools_0.5.3 knitr_1.40