mars.to.earth {earth}R Documentation

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

Description

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

Usage

mars.to.earth(object)

Arguments

object

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

Value

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 update.earth after mars.to.earth, 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.

Note

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. The calculation of minspan in earth follows Friedman's paper more closely and is slightly different from mars.

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

Weights

Note that the w argument is is actually ignored by mars. The equivalent earth argument weights is also not yet supported, and you will get a warning.

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 1s wp (or in fact any all constant wp) is equivalent to using no wp.

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

See Also

earth, mars

Examples

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

    # yields (note the reconstructed call):
    #    Call: earth(x=trees[, -3], y=trees[, 3])
    #    
    #                  coefficients
    #    (Intercept)           26.3
    #    h(Girth-13.8)          6.1
    #    h(13.8-Girth)         -3.2
    #    h(11.4-Girth)          0.5
    #    
    #    Selected 4 of 8 terms, and 2 of 2 predictors 
    #    Importance: object has no prune.terms, call update() on the model to fix that
    #    Number of terms at each degree of interaction: 1 3 (additive model)
    #    GCV 10    RSS 190    GRSq 0.96    RSq 0.98
}

[Package earth version 3.2-7 Index]