Skip to contents

This function plots results of a mixture model on the current graphical device.

Usage

# S3 method for class 'mixglm'
plot(
  x,
  form = NULL,
  byChains = TRUE,
  transCol = TRUE,
  addWAIC = FALSE,
  setCol = c("#1b9e77", "#d95f02", "#7570b3", "#e7298a", "#66a61e", "#e6ab02", "#a6761d",
    "#666666"),
  drawAxes = TRUE,
  SDmult = 1,
  xlab = NULL,
  ylab = NULL,
  doPlot = TRUE,
  xSamples = 100,
  ...
)

Arguments

x

an object of class "mixglm"

form

formula, such as y ~ pred, specifying variables to be plotted. By default the first predictor is plotted on x axis.

byChains

logical value indicating whether to plot mixture components for each chain

transCol

logical value indicating usage of transparent colours

addWAIC

logical value indication display of WAIC in upper right corner of the plot

setCol

vector of colours to be used for mixture components

drawAxes

logical value indicating whether values should be marked on axes

SDmult

scalar multiplying visualized standard deviation (to make lines for small standard deviation visible)

xlab

a label for the x axis, defaults to predictor name.

ylab

a label for the y axis, defaults to response name.

doPlot

logical value indicating if plotting should be done

xSamples

integer value specifying the number of values regularly distributed along x-axis at which estimates are calculated

...

additional arguments passed to plot

Value

Returns invisibly a list of lists for each chain. These lists contain a dataframe for each mixture component:

x

Values along x-axis for which estimates are calculated

prob

Probability of the component in the mixture along x-axis

yEst

Mean of the component in the mixture along x-axis

yLow

Mean minus SDmult times standard deviation of the component in the mixture along x-axis

yUpp

Mean plus SDmult times standard deviation of the component in the mixture along x-axis

Author

Adam Klimes

Examples

if (FALSE) { # \dontrun{
set.seed(10)
n <- 200
x <- rnorm(n)
group <- rbinom(n, 1, 0.5)
y <- rnorm(n, 1 + 0.5 * x * c(-1, 1)[group + 1], 0.1)
plot(y ~ x)
dat <- data.frame(x, y)

mod <- mixglm(
  stateValModels = y ~ x,
  stateProbModels = ~ x,
  statePrecModels = ~ x,
  inputData = dat,
  numStates = 2)
plot(mod)} # }