--- title: "Frequently Asked Questions" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Frequently Asked Questions} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ``` ```{r setup} library(simpleMH) ``` ## How to restrict the possible parameter range? There is no built-in way to define hard limits for the parameter and make sure they never go outside of this range. The recommended way to address this issue is to handle these cases in the function `f` you provide. For example, to keep parameters in the 0-1 range: ```{r} p.log.restricted <- function(x) { if (any(x < 0, x > 1)) { return(-Inf) } B <- 0.03 # controls 'bananacity' -x[1]^2 / 200 - 1 / 2 * (x[2] + B * x[1]^2 - 100 * B)^2 } res <- simpleMH( p.log.restricted, inits = c(a = 0, b = 0), theta.cov = diag(2), max.iter = 3000, coda = TRUE ) summary(res$samples) ``` ```{r, eval = identical(Sys.getenv("IN_PKGDOWN"), "true")} plot(res$samples) ```