plot.BNPdens {BNPmix} | R Documentation |

Extension of the `plot`

method to the `BNPdens`

class. The method `plot.BNPdens`

returns suitable plots for a `BNPdens`

object. See details.

## S3 method for class 'BNPdens' plot( x, dimension = c(1, 2), col = "#0037c4", show_points = F, show_hist = F, show_clust = F, bin_size = NULL, wrap_dim = NULL, xlab = "", ylab = "", band = T, conf_level = c(0.025, 0.975), ... )

`x` |
an object of class |

`dimension` |
if |

`col` |
the color of the lines; |

`show_points` |
if |

`show_hist` |
if |

`show_clust` |
if |

`bin_size` |
if |

`wrap_dim` |
bivariate vector, if |

`xlab` |
label of the horizontal axis; |

`ylab` |
label of the vertical axis; |

`band` |
if |

`conf_level` |
bivariate vector, order of the quantiles for the posterior credible bands. Default |

`...` |
additional arguments to be passed. |

If the `BNPdens`

object is generated by `PYdensity`

, the function returns
the univariate or bivariate estimated density plot.
If the `BNPdens`

object is generated by `PYregression`

, the function returns
the scatterplot of the response variable jointly with the covariates (up to four), coloured according to the estimated partition.
up to four covariates.
If `x`

is a `BNPdens`

object generated by `DDPdensity`

, the function returns
a wrapped plot with one density per group.
The plots can be enhanced in several ways: for univariate densities, if `show_hist = TRUE`

,
the plot shows also the histogram of the data; if `show_points = TRUE`

,
the plot shows also the observed points along the
x-axis; if `show_points = TRUE`

and `show_clust = TRUE`

, the points are colored
according to the partition estimated with the `partition`

function.
For multivariate densities: if `show_points = TRUE`

,
the plot shows also the scatterplot of the data;
if `show_points = TRUE`

and `show_clust = TRUE`

,
the points are colored according to the estimated partition.

A `ggplot2`

object.

# PYdensity example data_toy <- c(rnorm(100, -3, 1), rnorm(100, 3, 1)) grid <- seq(-7, 7, length.out = 50) est_model <- PYdensity(y = data_toy, mcmc = list(niter = 200, nburn = 100, nupd = 100), output = list(grid = grid)) class(est_model) plot(est_model) # PYregression example x_toy <- c(rnorm(100, 3, 1), rnorm(100, 3, 1)) y_toy <- c(x_toy[1:100] * 2 + 1, x_toy[101:200] * 6 + 1) + rnorm(200, 0, 1) grid_x <- c(0, 1, 2, 3, 4, 5) grid_y <- seq(0, 35, length.out = 50) est_model <- PYregression(y = y_toy, x = x_toy, mcmc = list(niter = 200, nburn = 100), output = list(grid_x = grid_x, grid_y = grid_y)) summary(est_model) plot(est_model) # DDPdensity example data_toy <- c(rnorm(50, -4, 1), rnorm(100, 0, 1), rnorm(50, 4, 1)) group_toy <- c(rep(1,100), rep(2,100)) grid <- seq(-7, 7, length.out = 50) est_model <- DDPdensity(y = data_toy, group = group_toy, mcmc = list(niter = 200, nburn = 100, napprox_unif = 50), output = list(grid = grid)) summary(est_model) plot(est_model)

[Package *BNPmix* version 0.2.8 Index]