Convert a mars object from the mda package to an earth object

View source: R/ Documentation

Convert a mars object from the mda package to an earth object


Convert a mars object from the mda package to an earth object

Usage, trace=TRUE)



A mars object, created using mars in the mda package.


If TRUE (default) print a summary of the conversion.


The value is the same format as that returned by earth but with skeletal versions of rss.per.subset, gcv.per.subset, and prune.terms.

You can fully initialize these components by calling after, but if you do this selected.terms may change. However with pmethod="backward" a change is unlikely — selected.terms would change only if GCVs are so close that numerical errors have an effect.


Differences between mars and earth objects

Perhaps the most notable difference between mars and earth objects is that mars returns the MARS basis matrix in a field called "x" whereas earth returns "bx" with only the selected terms. Also, earth returns "dirs" rather than "factors", and in earth this matrix can have entries of value 2 for linear predictors.

For details of other differences between mars and earth objects, see the comments in the source code of


The w argument is silently ignored by mars.

mars normalizes wp to (euclidean) length 1; earth normalizes wp to length equal to the number of responses, i.e., the number of columns in y. This change was made so an all ones wp (or in fact any all constant wp) is equivalent to using no wp.

If the original call to mars used the wp argument, will run to force consistency. This could modify the model, so a warning is issued.

See Also

earth, mars


if(require(mda)) {
    mars.mod <- mars(trees[,-3], trees[,3])
    earth.mod <-
    # the standard earth functions can now be used
    # note the reconstructed call in the summary
    summary(earth.mod, digits = 2)

earth documentation built on Feb. 16, 2023, 6:07 p.m.

Related to in earth...