View source: R/ctMultigroupFit.R
ctMultigroupFit | R Documentation |
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.
ctMultigroupFit(
dat,
groupings,
ctmodelobj,
dataform = "wide",
fixedmodel = NA,
freemodel = NA,
carefulFit = TRUE,
omxStartValues = NULL,
retryattempts = 5,
showInits = FALSE,
...
)
dat |
Wide format data, as used in |
groupings |
For wide format: Vector of character labels designating group membership for each row of dat. For long format: Named list of groups, with each list element containing a vector of subject id's for the group. In both cases, group names will be prefixed on relevant parameter estimates in the summary. |
ctmodelobj |
Continuous time model to fit, specified via |
dataform |
either "wide" or "long" depending on which input format you wish to use for the data.
See details of |
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 discourage parameters from boundary conditions, then fits the specified model normally, using these estimates as starting values. Can help / speed optimization, 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 |
retryattempts |
Number of fit retries to make. |
showInits |
Displays start values prior to optimization |
... |
additional arguments to pass to |
Additional ctFit
parameters may be specified as required. Confidence intervals for any matrices and or parameters
may be estimated afer fitting using ctCI
.
Returns an OpenMx fit object.
ctFit
and ctModel
#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(dat=ctExample4, groupings=groups,
ctmodelobj=basemodel, freemodel=freemodel)
summary(multif,group=1)
#fixed model approach
fixedmodel<-basemodel
fixedmodel$LAMBDA[2,1]<-'groupfixed'
groups<-paste0('g',rep(1:2, each=10),'_')
multif<-ctMultigroupFit(dat=ctExample4, groupings=groups,
ctmodelobj=basemodel, fixedmodel=fixedmodel)
summary(multif,group=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.