Learn R Programming

R2MLwiN (version 0.8-1)

Formula.translate.compat: An internal function, allowing back-compatibility, which translates a model formula from a formula object or character string into an R list object.

Description

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.

Usage

Formula.translate.compat(Formula, levID, D = "Normal", indata)

Arguments

Formula
A formula object (or a character string) specifying a multilevel model. See Value for details.
levID
A character (vector) specifying the level ID(s).
D
A character string/vector specifying the distribution to be modelled, which can include 'Normal' (the default), 'Binomial', 'Poisson', 'Negbinom', 'Unordered Multinomial', 'Ordered
indata
A data.frame object containing the data to be modelled.

Value

Details

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.
  • 0When 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.
  • 1When 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 for2for level 2,3for level 3, etc.)
  • 0s/0cWhen placed to the left of|within()indicates that separate (hences) / common (hencec) coefficients for the variables to the right of|within the same()are to be added to the fixed part (hence0) of multivariate normal, multinomial and mixed responses models.
  • 2s/2cWhen placed to the left of|within()indicates that separate (hences) / common (hencec) 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.

See Also

runMLwiN, write.IGLS, write.MCMC, Formula.translate