Learn R Programming

earth (version 2.5-1)

format.earth: Format "earth" objects

Description

Return a string representing an earth expression.

Usage

## S3 method for class 'earth':
format(x = stop("no 'x' arg"),
       digits = getOption("digits"), use.names = TRUE,
       decomp = "anova",  style = "h", colon.char = ":", ...)

Arguments

x
An earth object. This is the only required argument.
digits
Number of significant digits. The default is getOption(digits).
use.names
If TRUE (default), use variable names. Else use names of the form x[,1].
decomp
One of "anova" (default) order the terms using the "anova decomposition", i.e., in increasing order of interaction "none" order the terms as created during the earth forward pass.
style
Formatting style. One of "h" (default) more compact "pmax" for those who prefer it and for compatibility with old versions of earth "max" is the same as "pmax" but prints max rather than
colon.char
Change colons in the returned string to colon.char. Default is ":", i.e., no change. Specifying colon.char="*" can be useful in some contexts to change names of the form x1:x2 to x1*x2.
...
Unused, but provided for generic/method consistency.

Value

  • A character representation of the earth object.

    If there are multiple responses, format.earth will return multiple strings.

    If there are embedded GLM model(s), the strings for the GLM model(s) come after the strings for the standard earth model(s).

See Also

earth, pmax,

Examples

Run this code
a <- earth(Volume ~ ., data = trees)
cat(format(a))

# yields:
#    27.2
#    +  6.18 * h(Girth-14)
#    -  3.27 * h(14-Girth)
#    + 0.491 * h(Height-72)

cat(format(a, style="pmax")) # default formatting style prior to earth version 1.4

# yields:
#    27.2
#    +  6.18 * pmax(0,  Girth -     14)
#    -  3.27 * pmax(0,     14 -  Girth)
#    + 0.491 * pmax(0, Height -     72)

cat(format(a, style="bf"))

# yields:
#    27.2
#    +  6.18 * bf1
#    -  3.27 * bf2
#    + 0.491 * bf3
#
#     bf1  h(Girth-14)
#     bf2  h(14-Girth)
#     bf3  h(Height-72)

Run the code above in your browser using DataLab