Shah,
I am the maintainer of the lhs package. Please feel free to contact
package maintainers directly for help specific to their package.
If I understood your request, this is how I would construct the lhs...
prior_lhs <- data.frame(
name = c("r_mu", "r_sd", "lmp",
"gr_mu", "gr_sd", "alpha1",
"alpha2", "alpha3", "beta"),
lower = c(0.00299, 0.001, 0.40, 0.14, 0.01, 0.0001, 0.0017, 0.005, 0.69),
upper = c(0.00320, 0.002, 0.43, 0.16, 0.20, 0.0018, 0.0028, 0.009, 0.75),
place = c(100000, 1000, 100, 100, 100, 10000, 10000, 1000, 100)
)
require(lhs)
nb_simul <- 10000
nparam <- nrow(prior_lhs)
random_tab <- randomLHS(nb_simul, nparam)
X <- random_tab
for (i in 1:nparam)
{
X[,i] <- floor(qunif(random_tab[,i],
prior_lhs$lower[i]*prior_lhs$place[i],
prior_lhs$upper[i]*prior_lhs$place[i] + 1)) / prior_lhs$place[i]
}
apply(X, 2, range)
> On Apr 12, 2021, at 08:21, Shah Alam <dr.alamsolangi at gmail.com>
wrote:
>
> Hello everyone,
>
> I am using the LHS package to generate a combination of a
> set of parameter values. However, I am not sure how to fix some parameter
> values to 2 decimal points.
> For example:
>
> I want to make combinations in such a way that values for parameter
> c("lmp", 0.40, 0.43) are taken as 0.40, 0.41, 0.42,0.43.
>
> My codes are:
>
> prior_lhs <- list(c("r_mu", 0.00299, 0.0032),
> c("r_sd", 0.001, 0.002),
> c("lmp", 0.40, 0.43),
> c("gr_mu", 0.14, 0.16),
> c("gr_sd", 0.01, 0.020),
> c("alpha1", 0.0001, 0.0018),
> c("alpha2", 0.0017, 0.0028),
> c("alpha3", 0.005, 0.009),
> c("beta", 0.69, 0.75)
> )
>
>
> ### Simulation with priors from LHS ####
> nb_simul <- 10000
> nparam <- length(prior_lhs)
> random_tab = randomLHS(nb_simul, nparam)
> lhs_index = 1
> param <- matrix(rep(0, nparam), nrow = 1, ncol = nparam)
>
> for (i in 1:nb_simul) {
> temp_par <- matrix(rep(0, nparam), nrow = 1, ncol = nparam)
> for (j in 1:nparam) {
> temp_par[j] = as.numeric(prior_lhs[[j]][2]) +
> (as.numeric(prior_lhs[[j]][3]) - as.numeric(prior_lhs[[j]][2])) *
> random_tab[lhs_index, j]
> }
> param <- rbind(param, temp_par)
> lhs_index <- lhs_index+1
> }
> param <- param[-1,]
>
> Best regards,
> Shah
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.