Ratio-of-Uniforms Simulation with Transformation

Uses the generalised ratio-of-uniforms (RU) method to simulate from univariate and (low-dimensional) multivariate continuous distributions. The user specifies the log-density, up to an additive constant. The RU algorithm is applied after relocation of mode of the density to zero, and the user can choose a tuning parameter r. For details see Wakefield, Gelfand and Smith (1991) , Efficient generation of random variates via the ratio-of-uniforms method, Statistics and Computing (1991) 1, 129-133. A Box-Cox variable transformation can be used to make the input density suitable for the RU method and to improve efficiency. In the multivariate case rotation of axes can also be used to improve efficiency. See the rust website for more information, documentation and examples.


rust: ratio-of-uniforms simulation with transformation ------------------------------------------------------ The rust package implements the multivariate generalized ratio-of-uniforms method of simulating random variates from a d-dimensional continuous distribution. The user specifies (the log of) a positive target function f that is proportional to the density function of the distribution.

we use the main function ru is used to simulate a sample of size 1000 from a two-dimensional standard normal distribution with strong positive correlation between the components. Of course, this particular example is purely illustrative: there are better ways to simulate from a multivariate normal distribution.

rho <- 0.9
covmat <- matrix(c(1, rho, rho, 1), 2, 2)
log_dmvnorm <- function(x, mean = rep(0, d), sigma = diag(d)) {
  x <- matrix(x, ncol = length(x))
  d <- ncol(x)
  - 0.5 * (x - mean) %*% solve(sigma) %*% t(x - mean)
}
x <- ru(logf = log_dmvnorm, sigma = covmat, d = 2, n = 1000, init = c(0, 0))

To get the current released version from CRAN:

install.packages("rust")

See vignette("rust-vignette", package = "rust") for an overview of the package.

News

rust 1.1.0

  • plot.ru() can now be used when d > 2: it produces pairwise plots of the simulated values.

  • find_lamba(): argument init_lambda added to enable the user to supply an initial value for the Box-Cox transformation vector lambda.

  • Unnecessary print statement print(dim(phi)) removed from function find_lambda().

  • Unnecessary print statement print(a_algor) removed from function ru().

  • Correct lambda$init to lambda$init_psi in ru() when extracting Box-Cox information.

  • Documentation of ru() updated to include a description of the returned function logf_rho() and simulated values sim_vals_rho and to clarify the meaning of the returned value of f_mode.

  • ru(): the expression for the inverse Box-Cox transformation in the case where lambda is exactly 0 has been corrected.

  • find_lambda(): carry out calculation of the target on a shifted log scale to avoid underflow.

  • Set up plot.ru() so that if the user supplies axis labels then they are used and otherwise the column name(s) of ru_object$sim_vals are used.
    Also enable plotmath symbols to be rendered in the axis labels.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("rust")

1.1.0 by Paul J. Northrop, 4 months ago


http://github.com/paulnorthrop/rust


Report a bug at http://github.com/paulnorthrop/rust/issues


Browse source code at https://github.com/cran/rust


Authors: Paul J. Northrop [aut, cre, cph]


Documentation:   PDF Manual  


GPL (>= 2) license


Imports stats, graphics, methods, spatstat

Suggests knitr, rmarkdown, testthat, devtools


Imported by revdbayes.


See at CRAN