Learn R Programming

ctsem (version 1.1.5.2)

plotSingle: singlePlot

Description

Plots mean trajectories, autoregression, and crossregression plots, for ctsemFit objects. More customizeable than basic plot.ctsemFit function.

Usage

plotSingle(x, resolution = 50, plotType, impulseIndex = NULL, xlim,
  colVector = "auto", ltyVector = "auto", ...)

Arguments

x
ctsemFit object as generated by ctFit.
resolution
Numeric. Plot points between each unit of time. Default of 'auto' adapts to xlim and results in 500 points in total.
plotType
string. "AR" for autoregressions, "CR" for cross regressions, "standardiseCR" for standardised cross regressions (standardised based on estimated within subject variance), "withinVar" for within variance and covariance, "randomImpulse" for expected c
impulseIndex
Numeric. Only required for impulse plot types, specifies which column of the DRIFT matrix the impulse relates to.
xlim
vector. As per usual for plot(), but xlim may not be negative.
colVector
vector of colours to use for plotting.
ltyVector
Vector of line types to use for plotting.
...
Other options passed to plot(). ylim is required.

Value

  • Character vector of labels from the DRIFT matrix in order plotted - useful for legends. Side-effect: plots graphs.

Examples

Run this code
## Examples set to 'dontrun' because they take longer than 5s.

### example from Driver, Oud, Voelkle (2016), 
### simulated happiness and leisure time with unobserved heterogeneity.
data(ctExample1)
traitmodel <- ctModel(n.manifest=2, n.latent=2, Tpoints=6, LAMBDA=diag(2), 
  manifestNames=c('LeisureTime', 'Happiness'), 
  latentNames=c('LeisureTime', 'Happiness'), TRAITVAR="auto")
traitfit <- ctFit(datawide=ctExample1, ctmodelobj=traitmodel)
plotSingle(traitfit, type='CR', xlim=c(0,5),ylim=c(-1,1))

Run the code above in your browser using DataLab