plot_predict.circGLM: Create a prediction plot from a circGLM object

View source: R/circGLMClassPlotFunctions.R

plot_predict.circGLMR Documentation

Create a prediction plot from a circGLM object

Description

Plot the predictions made by a circGLM analysis.

Usage

plot_predict.circGLM(
  m,
  x,
  d,
  th,
  linkfun = function(x) m$r * atan(x),
  xlab = NA,
  ylab = expression(theta),
  colorPalette = c("#E69F00", "#56B4E9")
)

Arguments

m

A circGLM object.

x

Optional; Either a numeric vector with a continuous predictor or string naming the desired variable to plot on the x-axis. If missing, we just use the first continuous predictor in the circGLM object.

d

Optional; Either a numeric vector with a categorical predictor or string naming the desired variable to plot on the x-axis. If missing, we just use the first categorical predictor in the circGLM object.

th

Optional; Can be a new numeric vector containing outcome angles corresponding to predictors x and potentially d.

linkfun

The link function to be used. Should be the same as was used for the creation of the circGLM object.

xlab

A character string with the x-label.

ylab

A character string with the y-label.

colorPalette

The colors to use in plotting, max 2.

Details

Creates a ggplot showing a prediction plot showing linear predictor against the circular outcome, with an optional grouping variable. One or more regression lines show the predicted values for different values of the linear and categorical predictors.

Predictors x and d and outcome th can be provided as numeric vectors of the same length as the outcome in the circGLM object m. This allows plotting the regression line from an earlier dataset on a new dataset.

Alternatively, x and d can be strings containing names of corresponding predictors in the original model. In that case, th should not be provided.

The function makes an effort to find predictors to plot if none are given, where it will simply take the first predictor in the dataset. If a plot without grouping is required, d can be set to NA.

Value

A ggplot, to which further ggplot elements can be added.

See Also

plot_trace.circGLM, plot_tracestack.circGLM, plot_meancompare.circGLM, plot_meanboxplot.circGLM, plot.circGLM.

Examples

dat <- generateCircGLMData()
m   <- circGLM(th ~ ., dat, Q = 100, burnin = 0)
plot(m, type = "predict")


keesmulder/CircGLMBayes documentation built on July 21, 2022, 3:43 a.m.