makeAdditiveFormula
Construct modeling formulae programatically

### Description

Given the names of the predictor and response variables, constructs a formula suitable for use with modeling functions like lm and glm.

### Usage

    makeAdditiveFormula(predictors, responses, env = parent.frame(),
        onMultipleResponse = "cbind", emptyResponsesOutput = stop("no response"))

### Arguments

predictors | a character vector listing the names of the predictor variables or a list of expressions to use as the predictor variables.
responses | a character vector listing the names of the response variables or a list of expressions to use as the response variables.
env | the environment attribute of the returned formula is set to this environment. Names in the formula not otherwise found are sought in this environment.
onMultipleResponse | a character string: either "cbind" or "+". If there are multiple responses, they should bind them together by a call to "cbind" (the common practice in modeling functions), or by calls to "+" (uncommon, but used in ftable).
emptyResponsesOutput | if no response variables (or expressions) are listed, use this argument as a placeholder. The default action is to signal an error. You can supply NULL to mean that not having a response is acceptable.

### Details

The most common usage is just makeAdditiveFormula(predictors, responses), where predictors and responses list the names of variables.
makeAdditiveFormula calls the two helper routines .makeAdditiveExpr and .makeCbindExpr to build the formula and it is possible that one might want to use them directly to construct unusual formulae.
Value

- if there is only one response variable, returns a formula of the form Response ~ Predictor1 + Predictor2 + ....
- if there is more than one response variable, returns either cbind(Response1,Response2,...) ~ Predictor1 + Predictor2 + ... or Response1 + Response2 + ... ~ Predictor1 + Predictor2 + ..., depending on the value of onMultipleResponses.

See Also
.makeAdditiveExpr and .makeCbindExpr are used to make the default right and left sides of the formula, respectively.
Examples

    makeAdditiveFormula(predictors=c("Age", "Sex"), responses=c("Attitude"))
    makeAdditiveFormula(predictors=c("Town"), responses=c("NumCases", "Population"))

Package SpotfireUtils version 6.1.5-18
Package Index