dynr.ggplot | R Documentation |
The ggplot of the smoothed state estimates and the most likely regimes
dynr.ggplot(res, dynrModel, style = 1, numSubjDemo = 2, idtoPlot = c(),
names.state, names.observed, names.regime, shape.values, title, ylab,
is.bw = FALSE, colorPalette = "Set2", fillPalette = "Set2",
mancolorPalette, manfillPalette, ...)
## S3 method for class 'dynrCook'
autoplot(object, dynrModel, style = 1, numSubjDemo = 2,
idtoPlot = c(), names.state, names.observed, names.regime, shape.values,
title, ylab, is.bw = FALSE, colorPalette = "Set2", fillPalette = "Set2",
mancolorPalette, manfillPalette, ...)
res |
The dynr object returned by |
dynrModel |
The model object to plot. |
style |
The style of the plot. If style is 1 (default), user-selected smoothed state variables are plotted. If style is 2, user-selected observed-versus-predicted values are plotted. |
numSubjDemo |
The number of subjects to be randomly selected for plotting. |
idtoPlot |
Values of the ID variable to plot. |
names.state |
(optional) The names of the states to be plotted, which should be a subset of the state.names slot of the measurement slot of dynrModel. |
names.observed |
(optional) The names of the observed variables to be plotted, which should be a subset of the obs.names slot of the measurement slot of dynrModel. |
names.regime |
(optional) The names of the regimes to be plotted, which can be missing. |
shape.values |
(optional) A vector of values that correspond to the shapes of the points, which can be missing. See the R documentation on pch for details on possible shapes. |
title |
(optional) A title of the plot. |
ylab |
(optional) The label of the y axis. |
is.bw |
Is plot in black and white? The default is FALSE. |
colorPalette |
A color palette for lines and dots. It is a value passed to the palette argument of the |
fillPalette |
A color palette for blocks. It is a value passed to the palette argument of the |
mancolorPalette |
(optional) A color palette for manually scaling the colors of lines and dots. It is a vector passed to the values argument of the |
manfillPalette |
(optional) A color palette for manually scaling the colors of filled blocks. It is a vector passed to the values argument of the |
... |
A list of elements that modify the existing ggplot theme. Consult the |
object |
The same as res. The dynr object returned by dynr.cook(). |
This function outputs a ggplot layer that can be modified using functions in the package ggplot2. That is, one can add layers, scales, coords and facets with the "+" sign. In an example below, the ggplot2::ylim()
function is used to modify the limits of the y axis of the graph. More details can be found on https://ggplot2.tidyverse.org/ and https://ggplot2.tidyverse.org/reference/.
The two functions dynr.ggplot()
and autoplot()
as identical aliases of one another. The autoplot()
function is an S3 method from the package ggplot2 that allows many objects to be plotted and works like the base plot()
function.
ggplot object
ggplot object
# The following code is part of a demo example in dynr
## Not run:
demo(RSLinearDiscreteYang, package='dynr')
p <- dynr.ggplot(yum, dynrModel = rsmod, style = 1,
names.regime = c("Deactivated", "Activated"),
title = "(B) Results from RS-AR model", numSubjDemo = 1,
shape.values = c(1),
text = element_text(size = 16),
is.bw = TRUE)
# One can modify the limits on the y axis by using '+'
p + ggplot2::ylim(-2, 4)
autoplot(yum, dynrModel = rsmod, style = 1,
names.regime = c("Deactivated", "Activated"),
title = "(B) Results from RS-AR model", numSubjDemo = 1,
shape.values = c(1),
text = element_text(size = 16),
is.bw = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.