wrapFormula {sfsmisc} | R Documentation |
Enhance Formula by Wrapping each Term, e.g., by "s(.)"
Description
The main motivation for this function has been the easy construction
of a “full GAM formula” from something as simple as
Y ~ .
.
The potential use is slightly more general.
Usage
wrapFormula(f, data, wrapString = "s(*)")
Arguments
f |
the initial |
data |
|
wrapString |
|
Value
a formula
very similar to f
; just replacing each
additive term by its wrapped version.
Note
There are limits for this to work correctly; notably the right hand
side of the formula f
should not be nested or otherwise
complicated, rather typically just .
as in the examples.
Author(s)
Martin Maechler, May 2007.
See Also
formula
;
gam
from package mgcv (or also from
package gam).
Examples
myF <- wrapFormula(Fertility ~ . , data = swiss)
myF # Fertility ~ s(Agriculture) + s(....) + ...
if(require("mgcv")) {
m1 <- gam(myF, data = swiss)
print( summary(m1) )
plot(m1, pages = 1) ; title(format(m1$call), line= 2.5)
}
## other wrappers:
wrapFormula(Fertility ~ . , data = swiss, wrap = "lo(*)")
wrapFormula(Fertility ~ . , data = swiss, wrap = "poly(*, 4)")
[Package sfsmisc version 1.1-18 Index]