MARS models via the `earth` package

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(tidypredict)
library(earth)
library(dplyr)

| Function |Works| |---------------------------------------------------------------|-----| |tidypredict_fit(), tidypredict_sql(), parse_model() | ✔ | |tidypredict_to_column() | ✔ | |tidypredict_test() | ✔ | |tidypredict_interval(), tidypredict_sql_interval() | ✗ | |parsnip | ✔ |

tidypredict_ functions

library(earth)
data("etitanic", package = "earth")

model <- earth(age ~ sibsp + parch, data = etitanic, degree = 3)

GLM models

tidypredict supports the glm argument as well:

model <- earth(survived ~ .,
               data = etitanic,
               glm = list(family = binomial), degree = 2)

tidypredict_fit(model)

The spec sets the is_glm entry to 1, as well as the family and link entries.

str(parse_model(model), 2)

parsnip

parsnip fitted models are also supported by tidypredict:

library(parsnip)

p_model <- mars(mode = "regression", prod_degree = 3) %>%
  set_engine("earth") %>%
  fit(age ~ sibsp + parch, data = etitanic)

tidypredict_fit(p_model)

Parse model spec

Here is an example of the model spec:

pm <- parse_model(model)
str(pm, 2)
str(pm$terms[1:2])


Try the tidypredict package in your browser

Any scripts or data that you put into this service are public.

tidypredict documentation built on Oct. 28, 2020, 9:07 a.m.