Running the rtnorm_0_1_90ci function with the upper range set to 0.99 leads to a completely different distribution than with upper bound set to 0.98 for example.
The redlines indicate the lower bound, the mean and the upper bound. As you can see, the last example produces a completely different distribution. No warning appears. I suspect the same distribution appears when running mcSimulation with a variable which distribution is set to be tnorm_0_1 and upper range is 0.99.
I think it would be safe, if the function returns an error which sais that upper range with 0.99 is not valid
Running the
rtnorm_0_1_90ci
function with the upper range set to 0.99 leads to a completely different distribution than with upper bound set to 0.98 for example.Here is an example: `tnorm_90 <- decisionSupport::rtnorm_0_1_90ci(n = nsim, lower = 0.53, upper = 0.90 ,correlationMatrix = 1) tnorm_95 <- decisionSupport::rtnorm_0_1_90ci(n = nsim, lower = 0.53, upper = 0.95 ,correlationMatrix = 1) tnorm_98 <- decisionSupport::rtnorm_0_1_90ci(n = nsim, lower = 0.53, upper = 0.98 ,correlationMatrix = 1) tnorm_99 <- decisionSupport::rtnorm_0_1_90ci(n = nsim, lower = 0.53, upper = 0.99 ,correlationMatrix = 1)
tnorm_df <- rbind(data.frame(dist = tnorm_90, type = 'upper limit = 0.90'), data.frame(dist = tnorm_95, type = 'upper limit = 0.95'), data.frame(dist = tnorm_98, type = 'upper limit = 0.98'), data.frame(dist = tnorm_99, type = 'upper limit = 0.99'))
line_df <- data.frame(upper = c(0.9, 0.95, 0.98, 0.99), lower = rep(0.53), middle = c(mean(c(0.53, 0.90)), mean(c(0.53, 0.95)), mean(c(0.53, 0.98)), mean(c(0.53, 0.99))), type = c('upper limit = 0.90', 'upper limit = 0.95', 'upper limit = 0.98', 'upper limit = 0.99'))
ggplot(tnorm_df, aes(x = dist)) + geom_histogram(bins = 150) + geom_vline(data = line_df, aes(xintercept = upper), col = 'red')+ geom_vline(data = line_df, aes(xintercept = lower), col = 'red')+ geom_vline(data = line_df, aes(xintercept = middle), col = 'red')+ facet_wrap(~type, scales = 'free_y', ncol = 1, nrow = 4) + xlim(0,1) + theme_bw()`
This produces the following distributions
The redlines indicate the lower bound, the mean and the upper bound. As you can see, the last example produces a completely different distribution. No warning appears. I suspect the same distribution appears when running
mcSimulation
with a variable which distribution is set to be tnorm_0_1 and upper range is 0.99.I think it would be safe, if the function returns an error which sais that upper range with 0.99 is not valid