ctFitAutoGroupModel: ctFitAutoGroupModel

View source: R/ctFitAuto.R

ctFitAutoGroupModelR Documentation

ctFitAutoGroupModel

Description

Fit a ctStan model with automatic parameter selection for multiple subjects

Usage

ctFitAutoGroupModel(
  m,
  dat,
  cores,
  DRIFT = TRUE,
  DIFFUSION = TRUE,
  groupFreeThreshold = 0.5,
  ...
)

Arguments

m

ctStan model object without time independent predictors.

dat

Data in long format

cores

Number of CPU cores to use

DRIFT

Logical, if TRUE, off diagonal drift parameters in the model are tested for inclusion

DIFFUSION

Logical, if TRUE, off diagonal diffusion parameters in the model are tested for inclusion

groupFreeThreshold

Numeric, threshold for group free parameter selection. Default is .5

...

Additional arguments passed to ctStanFit

Details

This function is used to automatically select parameters in a ctStan model. Any specified DRIFT / DIFFUSION matrix off diagonals are only included if they significantly improve the likelihood, based on an estimated likelihood ratio test (relying on the Hessian). Subjects are fit one by one, and a group model is determined based on the groupFreeThreshold parameter – when the proportion of subjects with a parameter free is above this threshold, the parameter is freed in the group model.

Value

A list containing a list of ctStan fit objects for each subject, and a group model

Examples

## Not run: 
testmodel <- ctstantestfit$ctstanmodelbase
testmodel$pars$TI1_effect <- NULL
testmodel$n.TIpred <- 0
testmodel$TIpredNames <- NULL
testfit <- ctFitAutoGroupModel(testmodel, 
dat = ctstantestdat, cores=2, DRIFT = TRUE, DIFFUSION = TRUE)
ctModelLatex(testfit$groupModel)
lapply(testfit$fits,function(x) print(ctStanContinuousPars(x)$DRIFT))

## End(Not run)

ctsem documentation built on June 21, 2025, 5:08 p.m.