Rev 2 | Blame | Last modification | View Log | Download | RSS feed
\name{formula}\title{Model Formulae}\usage{y ~ modelformula(object)formula.default(anything)formula.formula(formula.obj)formula.terms(terms.obj)}\alias{~}\alias{formula.default}\alias{formula.formula}\alias{formula.terms}\alias{print.formula}\description{The models fit by the \code{lm} and \code{glm} functionsare specified in a compact symbolic form.The \code{~} operator is basic in the formation of such models.An expression of the form \code{y~model} is interpretedas a specification that the response \code{y} is modelledby a linear predictor specified symbolically by \code{model}.Such a model consists of a series of terms separatedby \code{+} operators.The terms themselves consist of variable and factornames separated by \code{:} operators.Such a term is interpreted as the interaction ofall the variables and factors appearing in the term.In addition to \code{+} and \code{:}, a number of otheroperators are useful in model formulae.The \code{*} operator denotes factor crossing:\code{a*b} interpreted as \code{a+b+a:b}.The \code{^} operator indicates crossing to thespecified degree. For example \code{(a+b+c)^2}is identical to \code{(a+b+c)*(a+b+c)} which in turnexpands to a formula containing the main effectsfor \code{a}, \code{b} and \code{c} togetherwith their second-order interactions.The \code{\%in\%} operator indicates that the termson its left are nested within those on the right.For example \code{a+b\%in\%a} expands to theformula \code{a+a:b}.While formulae usually involve just variable and factornames, they can also involve arithmetic expressions.The formula \code{log(y)~a+log(x)} is quite legal.When such arithmetic expressions involveoperators which are also used symbolicallyin model formulae, there can be confusion betweenarithmetic and symbolic operator use.To avoid this confusion, the function \code{I()}can be used to bracket those portions of a modelformula where the operators are used in theirarithmetic sense. For example, in the formula\code{y~a+I(b+c)}, the term \code{b+c} is to beinterpreted as the sum of \code{b} and \code{c}.The generic function \code{formula} and its specificmethods provide a way of extracting formulaewhich have been included in other objects.}\value{All the functions above produce an objectof class \code{formula} which contains a symbolic model formula.}\seealso{\code{\link{lm}}, \code{\link{glm}}, \code{\link{terms}}.}\keyword{models}