Learn R Programming

vcrpart (version 0.4-1)

vcrpart-formula: Special terms for formulas.

Description

Special terms for formulas assigned to tvcm, fvcm and olmm.

Usage

fe(formula, intercept = TRUE) re(formula, intercept = TRUE) vc(..., by, intercept = missing(by), nuisance = character()) ce(formula) ce(formula)

Arguments

formula
a symbolic description for the corresponding component of the formula component. See examples.
intercept
logical or character vector. intercept = TRUE (default) indicates that an intercept is incorporated. intercept = FALSE removes the random intercept from the formula. Note that the sometimes allowed -1 term is ignored. The character strings "ce" (category-specific random intercepts) and "ge" (category-global random intercepts) may be used in connection with olmm. Intercepts have specific interpretations for fe, re and vc, see the details.
...
the names of variables that moderate (i.e. modify) the effects of the variables specified in by, separated by commas. It is also possibly to assign a vector that contains the variable names as characters.
by
a formula of predictors the effects of which are moderated by the variables in .... See tvcm and the examples below. Note that the by variable must be numeric and factor variables must be recoded to dummy variables by hand.
nuisance
character vector of variables in by which have to be estimated separately for each partition but the algorithm should not focus on this variable when searching for splits.

Value

a list used by tvcm, fvcm and olmm for constructing the model matrices.

Details

Special formula terms to define fixed effects fe, varying coefficients vc and random effects re. The use of these formula terms ensures that the functions fvcm, tvcm and olmm fit the intended model. Some examples are given below and on the documentation pages of the fitting functions. For all of fvcm, tvcm and olmm, Variables which are not defined with one of fe, vc and re are treated as fixed effects. Intercepts can be dropped from the model by the intercept argument. The terms ce (category-specific effects) and ge (global effect or proportional odds effect) are designed for the function olmm. Notice that tvcm may changes, for internal reasons, the order of the terms in the specified formula. At present, the term ".", which is generally use to extract all variables of the data, is ignored. On the other hand, vc interprets character vectors, assigned as unnamed arguments, as lists of variables of moderators to be extracted from data.

See Also

tvcm, fvcm, olmm

Examples

Run this code
## Formula for a model with 2 fixed effects (x1 and x2) and a random
## intercept. The 're' terms indicates that an intercept is fitted for
## each level of 'id'.

formula <- y ~ fe(x1 + x2) + re(1|id)

## Formula for a model with one fixed effect and one varying coefficient
## term with 2 moderators and 2 varying coefficient predictors. 'tvcm'
## will fit one partition to model the effects of 'x2' and 'x3' as
## functions of 'z1' and 'z2'.

formula <- y ~ x1 + vc(z1, z2, by = x2 + x3, intercept = TRUE)

## Similar formula as above, but the predictors 'x2' and 'x3' have
## separate 'vc' terms. 'tvcm' will fit a separate partition for each of
## 'x2' and 'x3' to model their effects as functions of 'z1' and 'z2'.

formula <- y ~ x1 + vc(z1, z2, by = x2) + vc(z1, z2, by = x3)

Run the code above in your browser using DataLab