R/RcppExports.R

Defines functions gibbsC rwMetropolisC

Documented in gibbsC rwMetropolisC

# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' @title A Gibbs sampler using Rcpp
#' @description A Gibbs sampler using Rcpp
#' @param N the number of samples
#' @param thin the number of between-sample random numbers
#' @return a random sample of size \code{n}
#' @examples
#' \dontrun{
#' rnC <- gibbsC(100,10)
#' par(mfrow=c(2,1));
#' plot(rnC[,1],type='l')
#' plot(rnC[,2],type='l')
#' }
#' @export
gibbsC <- function(N, thin) {
    .Call('_SC19062_gibbsC', PACKAGE = 'SC19062', N, thin)
}

#' @title A random walk Metropolis sampler using R
#' @description A random walk Metropolis sampler using R
#' @param sigma the sd
#' @param x0 the initial value
#' @param N the number of samples
#' @return a random sample of size \code{n}
#' @examples
#' \dontrun{
#' N <- 2000
#' sigma <- c(.05, .5, 2, 16)
#' x0 <- 25
#' rw1 <- rwMetropolisC(sigma[1], x0, N)
#' rw2 <- rwMetropolisC(sigma[2], x0, N)
#' rw3 <- rwMetropolisC(sigma[3], x0, N)
#' rw4 <- rwMetropolisC(sigma[4], x0, N)
#' rw <- cbind(rw1$x, rw2$x, rw3$x, rw4$x)
#' print(c(rw1$k, rw2$k, rw3$k, rw4$k))
#' print(c(1-rw1$k/N,1-rw2$k/N,1-rw3$k/N,1-rw4$k/N))
#' }
#' @export
rwMetropolisC <- function(sigma, x0, N) {
    .Call('_SC19062_rwMetropolisC', PACKAGE = 'SC19062', sigma, x0, N)
}
zheng017/SC19062 documentation built on Jan. 2, 2020, 12:53 a.m.