rwMetropolisR: A random walk Metropolis sampler using R

Description Usage Arguments Value Examples

View source: R/rwMetropolisR.R

Description

A random walk Metropolis sampler using R

Usage

1

Arguments

sigma

the sd

x0

the initial value

N

the number of samples

Value

a random sample of size n

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
N <- 2000
sigma <- c(.05, .5, 2, 16)
set.seed(1234)
x0 <- 25
rw1 <- rwMetropolisR(sigma[1], x0, N)
rw2 <- rwMetropolisR(sigma[2], x0, N)
rw3 <- rwMetropolisR(sigma[3], x0, N)
rw4 <- rwMetropolisR(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))

## End(Not run)

zheng017/SC19062 documentation built on Jan. 2, 2020, 12:53 a.m.