plot.dpGLM | R Documentation |
This function generates desity plots with the posterior distribution generated by the function hdpGLM
## S3 method for class 'dpGLM' plot( x, terms = NULL, separate = FALSE, hpd = TRUE, true.beta = NULL, title = NULL, subtitle = NULL, adjust = 1, ncols = NULL, only.occupied.clusters = TRUE, focus.hpd = FALSE, legend.position = "top", colour = "grey", alpha = 0.4, display.terms = TRUE, plot.mean = TRUE, legend.label.true.value = "True", ... )
x |
a dpGLM object with the samples from generated by |
terms |
string vector with the name of covariates to plot. If |
separate |
boolean, if |
hpd |
boolean, if |
true.beta |
either |
title |
string, the title of the plot |
subtitle |
string, the subtitle of the plot |
adjust |
the bandwidth used is actually |
ncols |
integer, the number of columns in the plot |
only.occupied.clusters |
boolean, if |
focus.hpd |
boolean, if |
legend.position |
one of four options: "bottom" (default), "top", "left", or "right". It indicates the position of the legend |
colour |
= string with color to fill the density plot |
alpha |
number between 0 and 1 indicating the degree of transparency of the density |
display.terms |
boolean, if |
plot.mean |
boolean, if |
legend.label.true.value |
a string with the value to display in the legend when the |
... |
ignored |
# Note: this example is just for illustration. MCMC iterations are very reduced set.seed(10) n = 20 data = tibble::tibble(x1 = rnorm(n, -3), x2 = rnorm(n, 3), z = sample(1:3, n, replace=TRUE), y =I(z==1) * (3 + 4*x1 - x2 + rnorm(n)) + I(z==2) * (3 + 2*x1 + x2 + rnorm(n)) + I(z==3) * (3 - 4*x1 - x2 + rnorm(n)) , ) ## estimation mcmc = list(burn.in=1, n.iter=50) samples = hdpGLM(y ~ x1 + x2, data=data, mcmc=mcmc, n.display=1) plot(samples)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.