ctFitAuto: ctFitAuto

View source: R/ctFitAuto.R

ctFitAutoR Documentation

ctFitAuto

Description

Fit a ctStan model with automatic parameter selection

Usage

ctFitAuto(
  m,
  dat,
  DRIFT = TRUE,
  DIFFUSION = TRUE,
  fast = FALSE,
  initialRestrictions = NA,
  individuals = FALSE,
  groupFreeThreshold = 0.5,
  cores = 2,
  ...
)

Arguments

m

ctStan model object without time independent predictors.

dat

Data in long format

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

fast

Logical, if TRUE, do not compute uncertainty hessian / samples in individual level models.

initialRestrictions

Alternative to the DRIFT / DIFFUSION arguments – specify explicitly which parameters should be fixed initially, vector of integers based on the $setup$matsetup element of the ctStanFit object, which gives the parameter numbers. Primarily for internal use.

individuals

Logical, if TRUE, fit individual level models and determine a group model based on the groupFreeThreshold argument.

groupFreeThreshold

Numeric, threshold for group model structure – if a parameter improves fit in this proportion of individuals or greater, it is freed for all individuals.

cores

Number of CPU cores to use

...

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).

Value

A ctStan fit object

Examples

## Not run: 
testmodel <- ctstantestfit$ctstanmodelbase
testmodel$pars$TI1_effect <- NULL
testmodel$n.TIpred <- 0
testmodel$TIpredNames <- NULL
testfit <- ctFitAuto(testmodel, dat = ctstantestdat, DRIFT = TRUE, DIFFUSION = TRUE)
summary(testfit)

## End(Not run)

ctsem documentation built on June 30, 2025, 5:06 p.m.