vcrpart-formula {vcrpart}R Documentation

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)
ge(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. Note that operators like factor(x) are not allowed.

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.

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. Note that you can put multiple terms within fe, ge and ce terms (e.g., fe(ce(x1 + x2 + ge(x3 + x4))).

At present, the term ".", which is often use to extract all variables of the data, is ignored. As an alternative, vc interprets character vectors, assigned as unnamed arguments, as lists of variables of moderators to be extracted from data. See the examples below.

Default for intercepts in fe terms is intercept = TRUE, or intercept = "ce" for models fitted with olmm. This means that an intercept is automatically attached. Alternatives are intercept = FALSE, which is equal to intercept = "none", and intercept = "ge", which yields a global-effect intercept for models fitted with olmm.

Default for intercepts in vc is to introduce an intercept if the by argument is ignored, otherwise no intercept is introduced. Specifically, if input is specified for the by argument, then intercept = TRUE, or intercept = "ce" for models fitted by olmm. Alternatives are intercept = FALSE, which is equal to intercept = "none", and intercept = "ge", which yields a global-effect varying intercept.

Default for intercepts in re is intercept = TRUE, which is equal to intercept = "ge". intercept = FALSE is equal to intercept = "none". For category-specific random intercepts, use intercept = "ge". See olmm.

Value

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

Author(s)

Reto Burgin

See Also

tvcm, fvcm, olmm

Examples

## 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)

## As an alternative to '.' you can define variables in a vector
vars <- c("x1", "x2", "x3")
formula <- y ~ x1 + vc(vars, by = x2) + vc(vars, by = x3)

[Package vcrpart version 1.0-5 Index]