# Plot beta posterior distribution

Source: `R/src_summaries.R`
`plot_beta.Rd`

Plot the posterior distribution of the linear parameters beta for each context

    plot_beta(
      samples,
      X = NULL,
      context.id = NULL,
      true.beta = NULL,
      title = NULL,
      subtitle = NULL,
      plot.mean = FALSE,
      plot.grid = FALSE,
      showKhat = FALSE,
      col = NULL,
      xlab.size = NULL,
      ylab.size = NULL,
      title.size = NULL,
      legend.size = NULL,
      xtick.distance = NULL,
      left.margin = 0,
      ytick.distance = NULL,
      col.border = "white"
    )

## Arguments

samples

  an output of the function `hdpGLM`

X

  a string vector with the name of the first-level covariates whose associated tau should be displayed

context.id

  string with the name of the column containing the labels identifying the contexts. This variable should have been specified when the estimation was conducted using the function `hdpGLM`.

true.beta

  a `data.frame` with the true values of the linear coefficients `beta` if they are known. The `data.frame` must contain a column named `j` with the index of the context associated with that particular linear coefficient `beta`. It must match the indexes used in the data set for each context. Another column named `k` must be provided, indicating the cluster of `beta`, and a column named `Parameter` with the name of the linear coefficients (`beta1`, `beta2`, ..., `beta_dx`, where `dx` is the number of covariates at the individual level, and beta1 is the coefficient of the intercept term). It must contain a column named `True` with the true value of the `betas`. Finally, the `data.frame` must contain columns with the context-level covariates as used in the estimation of the hdpGLM function (see Details below).

title

  string, title of the plot

subtitle

  string, the subtitle of the plot

plot.mean

  boolean, if `TRUE` the posterior mean of every cluster is displayed

plot.grid

  boolean, if `TRUE` a grid is displayed in the background

showKhat

  boolean, if `TRUE` a message with the number of estimated clusters by context is displayed

col

  string, color of the densities

xlab.size

  numeric, size of the breaks in the x-axis

ylab.size

  numeric, size of the breaks in the y-axis

title.size

  numeric, size of the title

legend.size

  numeric, size of the legend

xtick.distance

  numeric, distance between x-axis marks and bottom of the figure

left.margin

  numeric, distance between left margin and left side of the figure

ytick.distance

  numeric, distance between y-axis marks and bottom of the figure

col.border

  string, color of the border of the densities