duos_plot: Plot PDF or CDF

Description Usage Arguments Details Value Examples

Description

Plots the posterior mean PDF or CDF based on the output from duos.

Usage

1
duos_plot(duos_output, type = "pdf", burnin = NA, cri = FALSE, data = FALSE, interact = FALSE)

Arguments

duos_output

The list returned by duos containing the density estimate results.

type

The desired type of graph (see details).

burnin

The desired burnin to discard from the results. If no value is entered, the default is half the number of iterations.

cri

An option to include credible intervals. The default is FALSE.

data

An option to include data in the graph (see details).

interact

An option to make the plots interactive. The default is FALSE.

Details

Options for type

The input from duos can be used to plot a Bayesian estimate of the PDF or the CDF.

Options for cri

Credible intervals can also be added to the plot of the PDF or CDF.

Options for data

Incorporates the data into the PDF and CDF.

Options for interact

Provides the PDF or CDF plot in an interactive setting using plotly.

Value

A plot of the PDF or CDF estimate.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
## --------------------------------------------------------------------------------
## Uniform Distribution
## --------------------------------------------------------------------------------

# First run 'duos' on data sampled from a Uniform(0,1) distribution with 50 data points.
y <- runif(50)
duos_unif <- duos(y = y, k = 4, MH_N = 20000)

# Plot the PDF with all default values
duos_plot(duos_unif)

# Plot the PDF with the data overlayed
duos_plot(duos_unif, data = TRUE)

# Plot the CDF with the credible intervals and the empirical CDF
duos_plot(duos_unif, type="cdf", cri=TRUE)

## --------------------------------------------------------------------------------
## Beta Distribution
## --------------------------------------------------------------------------------

# First run 'duos' on data sampled from a Beta(0.5,0.5) distribution with 300 data points.
y <- rbeta(300, 0.5, 0.5)
duos_arcsin <- duos(y, k = 10, MH_N = 20000)

# Plot the PDF with the data in an interactive setting
duos_plot(duos_arcsin, type = "pdf", data = TRUE, interact = TRUE)

# Plot the CDF with the empirical cdf
duos_plot(duos_arcsin, type = "cdf", data = TRUE)

## --------------------------------------------------------------------------------
## Bimodal Distribution
## --------------------------------------------------------------------------------

# Sample 150 random uniforms
u  <- runif(150)
y <- rep(NA,150)
# Sampling from the mixture
for(i in 1:150){
  if(u[i] < 0.3){
   y[i]  <-  rnorm(1, 0, 1)
  }else {
   y[i] <- rnorm(1, 4, 1)
  }
}

# First run 'duos' on data sampled from a bimodal distribution with 150 data points.
duos_bimodal <- duos(y, k = 8, MH_N = 20000, scale_l = 0.5*sd(y), scale_u = 0.5*sd(y))

# Plot the PDF with the data and credible intervals
duos_plot(duos_bimodal, data = TRUE, cri = TRUE)

#Plot the PDF with credible intervals and a histogram of the data
duos_plot(duos_bimodal, cri=TRUE, data=TRUE)

# Plot the CDF interactively
duos_plot(duos_bimodal, type = "cdf", interact = TRUE)

reykp/BEDr documentation built on May 28, 2019, 8:40 a.m.