ctDiscretePars: ctDiscretePars

View source: R/ctDiscretePars.R

ctDiscreteParsR Documentation

ctDiscretePars

Description

Calculate model implied regressions for a sequence of time intervals (if ct) or steps (if dt) based on a ctStanFit object, for specified subjects. Wrap with print() when used inside for loops!

Usage

ctDiscretePars(
  fit,
  subjects = "popmean",
  times = seq(from = 0, to = 10, by = 0.1),
  nsamples = 200,
  observational = FALSE,
  standardise = FALSE,
  cov = FALSE,
  plot = FALSE,
  cores = 2,
  ...,
  ctstanfitobj
)

ctStanDiscretePars(
  fit,
  subjects = "popmean",
  times = seq(from = 0, to = 10, by = 0.1),
  nsamples = 200,
  observational = FALSE,
  standardise = FALSE,
  cov = FALSE,
  plot = FALSE,
  cores = 2,
  ...,
  ctstanfitobj
)

Arguments

fit

model fit from ctFit

subjects

Either 'popmean', to use the population mean parameter, or a vector of integers denoting which subjects.

times

Numeric vector of positive values, discrete time parameters will be calculated for each. If the fit object is a discrete time model, these should be positive integers.

nsamples

Number of samples from the stanfit to use for plotting. Higher values will increase smoothness / accuracy, at cost of plotting speed. Values greater than the total number of samples will be set to total samples.

observational

Logical. If TRUE, outputs expected change in processes *conditional on observing* a 1 unit change in each – this change is correlated according to the DIFFUSION matrix. If FALSE, outputs expected regression values – also interpretable as an independent 1 unit change on each process, giving the expected response under a 1 unit experimental impulse.

standardise

Logical. If TRUE, output is standardised according to expected total within subject variance, given by the asymDIFFUSIONcov matrix.

cov

Logical. If TRUE, covariances are returned instead of regression coefficients.

plot

Logical. If TRUE, ggplots output using ctDiscreteParsPlot instead of returning output.

cores

Number of cpu cores to use for computing subject matrices. If subject matrices were saved during fiting, not used.

...

additional plotting arguments to control ctDiscreteParsPlot

ctstanfitobj

Deprecated. Use fit.

Details

If plot=TRUE, the function will return a ggplot2 object (and hence needs to be printed if intended to display within a loop). This can be modified by the various ggplot2 functions, or displayed using print(x).

Examples

data.table::setDTthreads(1) #ignore this line
ctDiscretePars(ctstantestfit,times=seq(.5,4,.1),
 plot=TRUE,indices='CR')

#modify plot
require(ggplot2)
g=ctDiscretePars(ctstantestfit,times=seq(.5,4,.1),
 plot=TRUE,indices='CR')
g= g+ labs(title='Cross effects')
print(g)

ctsem documentation built on June 30, 2026, 5:07 p.m.