ctsem (version 3.0.4)

plot.ctKalman: Plots Kalman filter output from ctKalman.

Description

Plots Kalman filter output from ctKalman.

Usage

# S3 method for ctKalman
plot(x, subjects = 1, kalmanvec = c("y", "ysmooth"),
  errorvec = "auto", errormultiply = 1.96, ltyvec = "auto",
  colvec = "auto", lwdvec = "auto", subsetindices = NULL,
  pchvec = "auto", typevec = "auto", grid = FALSE, add = FALSE,
  plotcontrol = list(ylab = "Value", xlab = "Time", xaxs = "i", lwd = 2,
  mgp = c(2, 0.8, 0)), polygoncontrol = list(steps = 20),
  polygonalpha = 0.3, legend = TRUE, legendcontrol = list(x =
  "topright", bg = "white", cex = 0.7), ...)

Arguments

x

Output from ctKalman. In general it is easier to call ctKalman directly with the plot=TRUE argument, which calls this function.

subjects

vector of integers denoting which subjects (from 1 to N) to plot predictions for.

kalmanvec

string vector of names of any elements of the output you wish to plot, the defaults of 'y' and 'yprior' plot the original data, 'y', and the prior from the Kalman filter for y. Replacing 'y' by 'eta' will plot latent variables instead (though 'eta' alone does not exist) and replacing 'prior' with 'upd' or 'smooth' respectively plotting updated (conditional on all data up to current time point) or smoothed (conditional on all data) estimates.

errorvec

vector of names of covariance elements to use for uncertainty indication around the kalmanvec items. 'auto' uses the latent covariance when plotting latent states, and total covariance when plotting expectations of observed states. Use NA to skip uncertainty plotting.

errormultiply

Numeric denoting the multiplication factor of the std deviation of errorvec objects. Defaults to 1.96, for 95% intervals.

ltyvec

vector of line types, varying over dimensions of the kalmanvec object.

colvec

color vector, varying either over subject if multiple subjects, or otherwise over the dimensions of the kalmanvec object.

lwdvec

vector of line widths, varying over the kalmanvec objects.

subsetindices

Either NULL, or vector of integers to use for subsetting the (columns) of kalmanvec objects.

pchvec

vector of symbol types, varying over the dimensions of the kalmanvec object.

typevec

vector of plot types, varying over the kalmanvec objects. 'auto' plots lines for any 'prior', 'upd', or 'smooth' objects, and points otherwise.

grid

Logical. Plot a grid?

add

Logical. Create a new plot or update existing plot?

plotcontrol

List of graphical arguments (see par), though lty,col,lwd,x,y, will all be ignored.

polygoncontrol

List of arguments to the ctPoly function for filling the uncertainty region.

polygonalpha

Numeric for the opacity of the uncertainty region.

legend

Logical, whether to include a legend if plotting.

legendcontrol

List of arguments to the legend function.

...

not used.

Value

Nothing. Generates plots.

Examples

Run this code
# NOT RUN {
### Get output from ctKalman
x<-ctKalman(ctstantestfit,subjects=2)

### Plot with plot.ctKalman
plot.ctKalman(x, subjects=2)

###Single step procedure:
ctKalman(ctstantestfit,subjects=2,plot=TRUE)
# }

Run the code above in your browser using DataCamp Workspace