| fit_earth | R Documentation |
Wrapper around earth::earth() with parameter validation and automatic
cross-validation when interaction terms are enabled.
fit_earth(
df,
target,
predictors,
categoricals = NULL,
linpreds = NULL,
type_map = NULL,
degree = 1L,
allowed_func = NULL,
allowed_matrix = NULL,
nfold = NULL,
nprune = NULL,
thresh = NULL,
penalty = NULL,
minspan = NULL,
endspan = NULL,
fast.k = NULL,
pmethod = NULL,
glm = NULL,
trace = NULL,
nk = NULL,
newvar.penalty = NULL,
fast.beta = NULL,
ncross = NULL,
stratify = NULL,
varmod.method = NULL,
varmod.exponent = NULL,
varmod.conv = NULL,
varmod.clamp = NULL,
varmod.minspan = NULL,
keepxy = NULL,
Scale.y = NULL,
Adjust.endspan = NULL,
Auto.linpreds = NULL,
Force.weights = NULL,
Use.beta.cache = NULL,
Force.xtx.prune = NULL,
Get.leverages = NULL,
Exhaustive.tol = NULL,
wp = NULL,
weights = NULL,
...,
.capture_trace = TRUE
)
df |
A data frame containing the modeling data. |
target |
Character string. Name of the response variable. |
predictors |
Character vector. Names of predictor variables. |
categoricals |
Character vector. Names of predictors to treat as
categorical (converted to factors before fitting). Default is |
linpreds |
Character vector. Names of predictors constrained to enter
the model linearly (no hinge functions). Default is |
type_map |
Named list or character vector. Maps column names to
declared types (e.g., |
degree |
Integer. Maximum degree of interaction. Default is 1 (no interactions). When >= 2, cross-validation is automatically enabled. |
allowed_func |
Function or |
allowed_matrix |
Logical matrix or |
nfold |
Integer. Number of cross-validation folds. Automatically set
to 10 when |
nprune |
Integer or |
thresh |
Numeric. Forward stepping threshold. Default is earth's default (0.001). |
penalty |
Numeric. Generalized cross-validation penalty per knot.
Default is earth's default (if |
minspan |
Integer or |
endspan |
Integer or |
fast.k |
Integer. Maximum number of parent terms considered at each step of the forward pass. Default is earth's default (20). |
pmethod |
Character. Pruning method. One of |
glm |
List or |
trace |
Numeric. Trace earth's execution. 0 (default) = none, 0.3 = variance model, 0.5 = cross validation, 1-5 = increasing detail. |
nk |
Integer or |
newvar.penalty |
Numeric or |
fast.beta |
Numeric or |
ncross |
Integer or |
stratify |
Logical or |
varmod.method |
Character or |
varmod.exponent |
Numeric or |
varmod.conv |
Numeric or |
varmod.clamp |
Numeric or |
varmod.minspan |
Integer or |
keepxy |
Logical or |
Scale.y |
Logical or |
Adjust.endspan |
Numeric or |
Auto.linpreds |
Logical or |
Force.weights |
Logical or |
Use.beta.cache |
Logical or |
Force.xtx.prune |
Logical or |
Get.leverages |
Logical or |
Exhaustive.tol |
Numeric or |
wp |
Numeric vector or |
weights |
Numeric vector or |
... |
Additional arguments passed to |
.capture_trace |
Logical. If |
A list with class "earthUI_result" containing:
The fitted earth model object.
Name of the response variable.
Names of predictor variables used.
Names of categorical predictors.
Degree of interaction used.
Logical; whether cross-validation was used.
The data frame used for fitting.
# Using the included demo appraisal dataset
demo_file <- system.file("extdata", "Appraisal_1.csv", package = "earthUI")
df <- import_data(demo_file)
result <- fit_earth(df, target = "sale_price",
predictors = c("living_sqft", "lot_size", "age"))
format_summary(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.