ctPostPredict: Posterior predictive type check for ctsemFit.

View source: R/ctPostPredict.R

ctPostPredictR Documentation

Posterior predictive type check for ctsemFit.

Description

Samples data according to the ctsemFit object, computes quantiles over time based on model fit, plots these against original data.

Usage

ctPostPredict(
  fit,
  timestep = 0.1,
  n.subjects = 100,
  probs = c(0.025, 0.5, 0.975),
  plot = TRUE,
  ctPlotArrayArgs = list(grid = FALSE, legend = FALSE),
  indPlotArgs = list(colourby = "subject", lwd = 2, new = FALSE, type = "p", opacity =
    0.3),
  mfrow = "auto"
)

Arguments

fit

object of class ctsemFit as returned from ctFit

timestep

positive value denoting the time interval to use for sampling.

n.subjects

Number of subjects worth of data to sample.

probs

Vector of values between 0 and 1 denoting quantiles to generate. For plotting, vector should be of length 3 and values should be rising.

plot

Whether to plot or return the generated data.

ctPlotArrayArgs

additional arguments to pass to ctPlotArray function, for plotting generated distributions.

indPlotArgs

list of parameters to pass to ctIndplot, for plotting original data. Only used if plot=TRUE.

mfrow

2 dimensional integer vector defining number of rows and columns of plots, as per the mfrow argument to par. 'auto' determines automatically, to a maximum of 4 by 4, while NULL uses the current system setting.

Value

Either nothing (if plot=TRUE) or an array containing generated data over quantiles.

Examples


data("AnomAuth")
AnomAuthmodel <- ctModel(LAMBDA = matrix(c(1, 0, 0, 1), nrow = 2, ncol = 2), 
  Tpoints = 5, n.latent = 2, n.manifest = 2, MANIFESTVAR=diag(0, 2), TRAITVAR = 'auto') 
AnomAuthFit <- ctFit(AnomAuth, AnomAuthmodel)
ctPostPredict(AnomAuthFit,timestep=.5,n.subjects=100)


ctsemOMX documentation built on Oct. 5, 2023, 5:06 p.m.