Fit Multivariate Adaptive Regression Splines to klassets_xy
object
Arguments
- df
A object from
sim_xy
.- ...
Options for
earth ::earth
.
Examples
df <- sim_xy()
df
#> # A tibble: 500 × 2
#> x y
#> <dbl> <dbl>
#> 1 2.45 4.75
#> 2 2.49 4.56
#> 3 2.62 4.53
#> 4 2.80 4.59
#> 5 2.83 5.06
#> 6 2.84 3.92
#> 7 2.89 3.89
#> 8 2.96 4.78
#> 9 2.98 4.43
#> 10 2.99 4.53
#> # … with 490 more rows
dfmars <- fit_mars(df)
dfmars
#> # A tibble: 500 × 3
#> x y prediction
#> <dbl> <dbl> <dbl>
#> 1 2.45 4.75 4.75
#> 2 2.49 4.56 4.75
#> 3 2.62 4.53 4.75
#> 4 2.80 4.59 4.75
#> 5 2.83 5.06 4.75
#> 6 2.84 3.92 4.75
#> 7 2.89 3.89 4.75
#> 8 2.96 4.78 4.75
#> 9 2.98 4.43 4.75
#> 10 2.99 4.53 4.75
#> # … with 490 more rows
plot(dfmars)
df <- sim_xy(n = 1000, x_dist = runif)
df <- dplyr::mutate(df, y = y + 2*sin(5 * x))
plot(df)
plot(fit_mars(df))