View source: R/Formula.translate.compat.R
Formula.translate.compat | R Documentation |
Supports Formula syntax as used in earlier (<0.8-0) versions of R2MLwiN. A model
formula, as a formula object (or a character string) is translated into
an R list object. Called by runMLwiN
if oldsyntax = TRUE
(when user specifies levID
not NULL
in runMLwiN
function
call). For corresponding function supporting new syntax, see
Formula.translate
.
Formula.translate.compat(Formula, levID, D = "Normal", indata)
Formula |
A formula object (or a character string) specifying a
multilevel model. See |
levID |
A character (vector) specifying the level ID(s). |
D |
A character string/vector specifying the distribution to be
modelled, which can include |
indata |
A data.frame object containing the data to be modelled. |
If Formula
is a character string, then the following
syntax applies:
~
A tilde is used to separate response variable(s) and
explanatory variable(s).
()
Round brackets are used to specify each random
variable in the model together with its fixed/random part information.
|
Separates explanatory variable(s) (placed to the right of
|
) from the fixed/random part information (placed to the left of
|
) when placed within ()
.
[]
When placed
immediately after an explanatory variable, indicates that the variable is
categorical. The string in the []
represents the reference category;
if empty, no reference category is used; See note.
:
Indicates an interaction term: i.e. the variables adjacent to :
, and
separated by it, are interacted with each other.
0
When placed to the left of |
within ()
indicates that the variables
to the right of |
within the same ()
are to be added to the
fixed part of the model.
1
When placed to the left of
|
within ()
indicates that the coefficients of the variables
placed to the right of |
within the same ()
are to be allowed
to randomly vary at level 1 (and so on for 2
for level 2, 3
for level 3, etc.)
0s/0c
When placed to the left of |
within ()
indicates that separate (hence s
) / common (hence c
)
coefficients for the variables to the right of |
within the same
()
are to be added to the fixed part (hence 0
) of multivariate
normal, multinomial and mixed responses models.
2s/2c
When
placed to the left of |
within ()
indicates that separate
(hence s
) / common (hence c
) coefficients for the variables to
the right of |
within the same ()
are to be added to the
random part of the model, and allowed to vary at level 2; applies to
multivariate normal, multinomial and mixed responses models only.
{}
gives a vector of binary indicators specifying a
common coefficient. 1 is to include the component at the corresponding
positions; zero otherwise. These digits are separated by commas; applies to
multivariate normal, multinomial and mixed responses models only.
.
Used for adding a separate coefficient for a particular
component at a specific level; applies to multivariate normal, multinomial
and mixed responses models only
If Formula
is a formula object, 0s/0c
, 2s/2c
, .... and
{}
have to be replaced by `0s`/`0c`
, `2s`/`2c`
, ....
and ()
respectively. Other syntax remains the same.
Outputs an R list object, which is then used as the input for
write.IGLS
and/or write.MCMC
.
Note that some characters listed above have special meanings in the
formula, so avoid using them when you name the random variable. Alphanumeric
characters (i.e. [:alnum:]
) are recommended for naming the random
variable. They are also recommended for naming a reference category, inside
[]
. Note: use []
notation only in the fixed part when
there is no categorical variable in the random effects. If there is one in
the random part, the categorical variable has to be converted into a set of
binary variables (e.g., using Untoggle
).
Zhang, Z., Charlton, C.M.J., Parker, R.M.A., Leckie, G., and Browne, W.J. (2016) Centre for Multilevel Modelling, University of Bristol.
runMLwiN
, write.IGLS
, write.MCMC
, Formula.translate
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.