gbs_norm: Gibbs Algorithm for Generating Multivariate Normal...

Description Usage Arguments Value Examples

View source: R/gbs_norm.R

Description

MCMC method for generating vectors with multivariate normal distribution using Gibbs sampler.

Usage

1
gbs_norm(n, mu, A, init, burn = 1000)

Arguments

n

The numbers of samples one wants to obtain.

mu, A

Parameters for normal distribution, mu being the mean vecter while A being the covariance matrix

init

The initial value vector, which indicates the dimensions.

burn

Times of iterations one wants to omit before recording.

Value

A "mcmcn" object 'list("chain" = chain)' with chain storing samples by row.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# Generating Multivariate Normal Distribution Samples------------------------

# provide some parameters
# mu <- c(1,3)
# A <- matrix(c(1, 0.1, 0.1, 1), nrow = 2)

# generating random variates using function `gibbs_norm`
x.norm <- gbs_norm(10000, c(1,3), matrix(c(1, 0.1, 0.1, 1), nrow = 2), c(1,3), burn = 0)

# exploring the results
summary(x.norm)
plot(x.norm)
qqnorm(x.norm$chain[, 1], main = "QQ plot, 1st variable")

hjy78/mcmcn documentation built on Jan. 1, 2020, 1:03 p.m.