ctmaOptimizeInit: ctmaOptimizeInit

View source: R/ctmaOptimizeInit.R

ctmaOptimizeInitR Documentation

ctmaOptimizeInit

Description

Initial fitting (i.e., applies ctmaInit) to a primary study reFit times to capitalize on chance for obtaining a hard-to-find optimal fit. This could be very helpful if a primary yields out-of-range estimates, which could happen if the fitting algorithm unfortunately used random start values that resulted in a locally but not globally optimal fit. Essentially, using ctmaOptimizeInit is like gambling, hoping that at leas one set of starting values (the number is tries is specified in the reFits argument) eneables finding the global optimal fit. On unix-like machines (e.g. MacOS), this could be done in parallel mode if coresToUse > 1.

Usage

ctmaOptimizeInit(
  primaryStudies = NULL,
  activeDirectory = NULL,
  problemStudy = NULL,
  reFits = NULL,
  finishsamples = NULL,
  n.latent = NULL,
  coresToUse = c(1),
  indVarying = FALSE,
  randomScaleTime = c(1, 1),
  activateRPB = FALSE,
  checkSingleStudyResults = FALSE,
  customPar = FALSE,
  T0means = 0,
  manifestMeans = 0,
  manifestVars = NULL,
  CoTiMAStanctArgs = NULL,
  scaleTime = NULL
)

Arguments

primaryStudies

list of primary study information created with ctmaPrep or ctmaFitToPrep

activeDirectory

activeDirectory

problemStudy

number (position in list) where the problem study in primaryStudies is found

reFits

how many reFits should be done

finishsamples

number of samples to draw (either from hessian based covariance or posterior distribution) for final results computation (default = 1000).

n.latent

number of latent variables of the model (hast to be specified)!

coresToUse

if neg., the value is subtracted from available cores, else value = cores to use

indVarying

control for unobserved heterogeneity by having randomly (inter-individually) varying manifest means

randomScaleTime

lower and upper limit of uniform distribution from which timeScale argument for ctmaInit is uniformly shuffled (integer)

activateRPB

set to TRUE to receive push messages with 'CoTiMA' notifications on your phone

checkSingleStudyResults

displays estimates from single study 'ctsem' models and waits for user input to continue. Useful to check estimates before they are saved.

customPar

logical. If set TRUE (default) leverages the first pass using priors and ensure that the drift diagonal cannot easily go too negative (helps since ctsem > 3.4)

T0means

Default 0 (assuming standardized variables). Can be assigned labels to estimate them freely.

manifestMeans

Default 0 (assuming standardized variables). Can be assigned labels to estimate them freely.

manifestVars

define the error variances of the manifests with a single time point using R-type lower triangular matrix with nrow=n.manifest & ncol=n.manifest.

CoTiMAStanctArgs

parameters that can be set to improve model fitting of the ctStanFit Function

scaleTime

scale time (interval) - sometimes desirable to improve fitting

Value

returns a list with bestFit (= the best fit achieved), all_minus2ll (= all -2ll values for all fitted models), and summary, which is printed if the summary function is applied to the returned object, and which shows the summary information of the ctsem model with the best fit.

Note

All but one of multiple cores are used on unix-type machines for parallel fitting

During fitting, not output is generated. Be patient.

Examples

## Not run: 
optimFit313 <- ctmaOptimizeInit(primaryStudies=CoTiMAstudyList_3,
                                activeDirectory="/Users/tmp/",  # adapt!
                                problemStudy=which(CoTiMAstudyList_3$studyNumbers == 313),
                                reFits=10,
                                n.latent=2)
summary(optimFit313)

## End(Not run)


CoTiMA documentation built on Nov. 10, 2022, 5:16 p.m.