Learn R Programming

ctsem (version 1.1.6)

ctMultigroupFit: Fits a multiple group continuous time model.

Description

Fits a single continuous time structural equation models to multiple groups (where each group contains 1 or more subjects), by default, all parameters are free across groups. Can also be used to easily estimate seperate models for each group.

Usage

ctMultigroupFit(datawide, groupings, ctmodelobj, fixedmodel = NA, freemodel = NA, carefulFit = FALSE, omxStartValues = NULL, retryattempts = 5, showInits = FALSE, ...)

Arguments

datawide
Wide format data, as used in ctFit. See ctLongToWide to easily convert long format data.
groupings
Vector of character labels designating group membership for each row of datawide. These will be prefixed on relevant parameter estimates in the summary.
ctmodelobj
Continuous time model to fit, specified via ctModel function.
fixedmodel
Modified version of ctmodelobj, wherein any parameters you wish to keep fixed over groups should be given the value 'groupfixed'. If specified, all other parameters will be free across groups.
freemodel
Modified version of ctmodelobj, wherein any parameters you wish to free across groups should be given the label 'groupfree'. If specified, all other parameters will be fixed across groups. If left NULL, the default, all parameters are free across groups.
carefulFit
if TRUE, first fits the specified model with a penalised likelihood function to encourage parameters to remain closer to 0, then fits the specified model normally, using these estimates as starting values. Can help with optimization in some cases, though results in user specified inits being ignored for the final fit.
omxStartValues
A named vector containing the raw (potentially log transformed) OpenMx starting values for free parameters, as captured by OpenMx function omxGetParameters(ctmodelobj$mxobj). These values will take precedence over any starting values already specified using ctModel.
retryattempts
Number of fit retries to make.
showInits
Displays start values prior to optimization
...
additional arguments to pass to ctFit.

Value

Returns an OpenMx fit object.

Details

Additional ctFit parameters may be specified as required. Confidence intervals for any matrices and or parameters may be estimated afer fitting using ctCI.

See Also

ctFit and ctModel

Examples

Run this code
## Not run: 
# 
# #Two group model, all parameters except LAMBDA[3,1] constrained across groups.
# data(ctExample4)
# basemodel<-ctModel(n.latent=1, n.manifest=3, Tpoints=20,
#                    LAMBDA=matrix(c(1, 'lambda2', 'lambda3'), nrow=3, ncol=1),
#                    MANIFESTMEANS=matrix(c(0, 'manifestmean2', 'manifestmean3'), 
#                    nrow=3, ncol=1), TRAITVAR = 'auto')
# 
# freemodel<-basemodel
# freemodel$LAMBDA[3,1]<-'groupfree'
# groups<-paste0('g',rep(1:2, each=10),'_')
# 
# multif<-ctMultigroupFit(datawide=ctExample4, groupings=groups,
#                        ctmodelobj=basemodel, freemodel=freemodel)
# summary(multif)
# 
# 
# 
# #fixed model approach
# fixedmodel<-basemodel
# fixedmodel$LAMBDA[2,1]<-'groupfixed'
# groups<-paste0('g',rep(1:2, each=10),'_')
# 
# multif<-ctMultigroupFit(datawide=ctExample4, groupings=groups,
#                        ctmodelobj=basemodel, fixedmodel=fixedmodel)
# summary(multif) 
# ## End(Not run)


Run the code above in your browser using DataLab