earth (version 0.1-2)

reorder.earth: Order the terms in an 'earth' model

Description

Given an earth object, return an index vector ordered using the specified decomp. The index vector is suitable for indexing into object$selected.terms and object$coefficients.

Usage

## S3 method for class 'earth':
reorder(x = stop("no 'x' arg"),
             which.terms = x$selected.terms, decomp = c("anova", "none"),
             degree = 99, min.degree  = 0, ...)

Arguments

x
An earth object. This is the only required argument.
which.terms
Which terms to use. Default is x$which.terms.
decomp
One of "none" order the terms as created during the earth forward pass i.e. no reordering. "anova" (default) order the terms using the anova decomposition i.e. in increasi
degree
Maximum order of interaction. Terms of order greater than degree will be dropped. Default is 99 which is effectively all. Set degree=0 to return just the intercept.
min.degree
Minimum order of interaction. Terms of order less than min.degree will be dropped. Default is 0, meaning all.
...
Unused, but provided for generic/method consistency.

Value

  • An index vector suitable for indexing into object$selected.terms and object$coefficients, and ordered using the specified decomp.

See Also

earth

Examples

Run this code
data(ozone1)
a <- earth(O3 ~ ., data = ozone1, degree = 2)
reorder(a, decomp = "none")

# yields:
# [1]  1  2  3  4  5  6  7  8  9 10 11

reorder(a)   # defaults to decomp = "anova"

# yields:
# [1]  1  2 11  8  3  4  9  5  6  7 10

a$selected.terms[reorder(a)]

# yields:
# [1]  1  2 19 13  6  7 14  9 10 11 17

Run the code above in your browser using DataCamp Workspace