Builds the |-separated cell specification ctsem's model matrices use,
from named arguments rather than positional fields.
Arguments
- name
Parameter name. Two cells given the same name are the same parameter, which is how equality constraints are written.
- transform
Transform expression in terms of
param, e.g.'exp(param)'. Omitted leaves the default for that matrix, which depends on the cell – a variance, a drift diagonal and a mean all differ.- indvarying
Where the parameter varies:
TRUEat every level of the model'sidhierarchy,FALSEat none, or the names of the levels it varies at. Withid = c('person', 'couple')inctModel,indvarying = 'couple'gives a parameter that differs between couples but not between the persons within one, andTRUEis the same asc('person', 'couple'). With a single id the two forms mean the same thing. The model'spars$indvaryingcolumn holds the same values and may be edited directly.- sdscale
Multiplier on the population standard deviation's prior, at every level where the parameter varies. Only meaningful when it varies.
- tipreds
Time-independent predictors acting on this parameter: a character vector of names for effects to estimate, e.g.
'age'orc('age', 'sex'). Naming any predictor switches the rest off for this cell, so the list is the whole set of effects on it. A name must be one of the model'sTIpredNames; anything else is an error when the model is built.character(0)(ortipreds=with nothing after it, in a cell) means no predictor acts on this cell, which is not the same as leaving the argument out – that keeps the model's default.- mean
A population mean stated rather than estimated, for a parameter that varies (
indvarying): a number on the scalesummary()reports population means on. Only the random effects about it are then fitted, as for a person-level intercept with mean zero. Written into the cell as'name=value|...', and held by the model infixedpopmeans, a named vector that may also be set directly. Fits withbackend = 'julia'.
Details
The output is the same string the | syntax produces, so this
is a way of writing one rather than an alternative to it. Fields left at
their default are emitted empty, which is what the parser reads as
"unspecified".
The same named fields can also be written directly into a model matrix
cell, in which case nothing needs to be called. A cell containing
| is read as a |-separated specification; otherwise a cell
with a field of the form name=value is read as a named
specification, and anything else as a plain parameter name. All three of
these specify the same parameter:
MANIFESTMEANS = matrix('mm||TRUE|0.5')
MANIFESTMEANS = matrix(ctPar('mm', indvarying = TRUE, sdscale = 0.5))
MANIFESTMEANS = matrix('mm, indvarying=TRUE, sdscale=0.5')
In the named form, fields are separated by commas (commas inside brackets
belong to the value, so transform=pnorm(param, 0, 1) is one field),
the parameter name comes first, and several predictors or levels are given
as tipreds=c(age, sex) or indvarying=c(person, couple); in
the | form they are separated by commas, as in
'cross||person,couple'. A field name that is not one of the above is
an error naming the nearest valid field, so a misspelling such as
topreds=age is refused rather than becoming part of a parameter
name. Comparisons are unaffected: a state-dependent cell may contain
==, >=, <= or !=, and a named argument
inside a call belongs to the value it appears in.
See also
ctModel for the matrices these cells go in.
Examples
ctPar('mm', indvarying = TRUE)
ctPar('drift11', transform = '-exp(param)')
ctPar('mm', indvarying = TRUE, tipreds = c('age', 'sex'))
# varying between couples only, in a model with id = c('person', 'couple')
ctPar('cross', indvarying = 'couple')
# a person-level intercept whose population mean is zero
ctPar('lev', indvarying = TRUE, mean = 0)
if (FALSE) { # \dontrun{
# These two models are identical.
model <- ctModel(type = 'ct', n.latent = 1, n.manifest = 1,
LAMBDA = matrix(1),
MANIFESTMEANS = matrix(ctPar('mm', indvarying = TRUE, sdscale = 0.5)))
model <- ctModel(type = 'ct', n.latent = 1, n.manifest = 1,
LAMBDA = matrix(1),
MANIFESTMEANS = matrix('mm, indvarying=TRUE, sdscale=0.5'))
} # }