| 1 |
\name{wrapFormula} |
| 2 |
\alias{wrapFormula} |
| 3 |
\title{Enhance Formula by Wrapping each Term, e.g., by "s(.)"} |
| 4 |
\description{ |
| 5 |
The main motivation for this function has been the easy construction |
| 6 |
of a \dQuote{full GAM formula} from something as simple as |
| 7 |
\code{Y ~ .}. \cr |
| 8 |
The potential use is slightly more general. |
| 9 |
} |
| 10 |
\usage{ |
| 11 |
wrapFormula(f, data, wrapString = "s(*)") |
| 12 |
} |
| 13 |
\arguments{ |
| 14 |
\item{f}{the initial \code{\link{formula}}; typically something like |
| 15 |
\code{Y ~ .}.} |
| 16 |
\item{data}{\code{\link{data.frame}} to which the formula applies; |
| 17 |
see, \code{\link{formula}} or also \code{\link[mgcv]{gam}} or |
| 18 |
\code{\link{lm}}.} |
| 19 |
\item{wrapString}{\code{\link{character}} string, containing |
| 20 |
\code{"*"}, specifying the wrapping expression to use.} |
| 21 |
} |
| 22 |
\value{ |
| 23 |
a \code{\link{formula}} very similar to \code{f}; just replacing each |
| 24 |
\emph{additive} term by its wrapped version. |
| 25 |
} |
| 26 |
\note{ |
| 27 |
There are limits for this to work correctly; notably the right hand |
| 28 |
side of the formula \code{f} should not be nested or otherwise |
| 29 |
complicated, rather typically just \code{ . } as in the examples. |
| 30 |
} |
| 31 |
\author{Martin Maechler, May 2007.} |
| 32 |
\seealso{\code{\link{formula}}; |
| 33 |
\code{\link[mgcv]{gam}} from package \CRANpkg{mgcv} (or also from |
| 34 |
package \CRANpkg{gam}). |
| 35 |
} |
| 36 |
\examples{ |
| 37 |
myF <- wrapFormula(Fertility ~ . , data = swiss) |
| 38 |
myF # Fertility ~ s(Agriculture) + s(....) + ... |
| 39 |
|
| 40 |
if(require("mgcv")) { |
| 41 |
m1 <- gam(myF, data = swiss) |
| 42 |
print( summary(m1) ) |
| 43 |
plot(m1, pages = 1) ; title(format(m1$call), line= 2.5) |
| 44 |
} |
| 45 |
|
| 46 |
## other wrappers: |
| 47 |
wrapFormula(Fertility ~ . , data = swiss, wrap = "lo(*)") |
| 48 |
wrapFormula(Fertility ~ . , data = swiss, wrap = "poly(*, 4)") |
| 49 |
} |
| 50 |
\keyword{models} |