plot.g12post: Generic Plotting of Prior and Posterior distribution.

Description Usage Arguments Details Examples

Description

Plot the columns of one matrix against the columns of anothor. These matrices come from different functions, including binombeta, nbinombeta, poisgamma, gamgam and normnorm.

Usage

1
2
3
4
## S3 method for class 'g12post'
plot(x, y, leg_pos = c("topright", "bottomright", "bottom",
  "bottomleft", "left", "topleft", "top", "right", "center"), which = c(1:5),
  prob = c(25, 50, 75, 95), ...)

Arguments

x, y

vectors or matrices of data for plotting. The number of row should match. If one of them are missing, the other is taken as y and an x vector of 1:n is used. Missing values (NAs) are allowed.

leg_pos

a character vector of legend place.

which

if matrices are from normnorm, a subset of the plots is required, specify a subset of the numbers 1:6. See below 'Details' for the different kinds.

prob

the probability level.

...

other arguments from matplot, legend and contour to plotting functions.

Details

The 1 plot shows the prior and posterior distribution of mu. The 2 plot shows the prior and posterior distribution of tau. The 3 plot shows the prior contour with probabilites. The 4 plot shows the posterior contour with probabilites. The 5 plot shows the prior and posterior contours with probabilites together.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Get the posterior distribution with Gamma-Gamma model and plot.
y <- rgamma(10, shape = 3)
ex <- gamgam(y, a = 3, 4, 1)
plot(ex, leg_pos = "center" , box.lty=0)

## Obtain the posterior distribution with Normal-Gamma model,
## assuming both mu and sigma are unknown.
x <- rnorm(100, mean = 1, sd = 0.5)
ex <- normnorm(y, m = 2, s = 1, a = 1, b = 2)
## show the fourth and fifth plot
plot(ex, which = 4, main = "Posterior Contour",
           xlim = c(-3,3), ylim = c(0,3))
plot(ex, which = 5, main = "Prior and Posterior Contour")

yijin71/statg012 documentation built on May 23, 2019, 4:04 p.m.