evaluate_models {stgam} | R Documentation |
Evaluates multiple models with each predictor variable specified in different ways in order to determining model form
Description
Evaluates multiple models with each predictor variable specified in different ways in order to determining model form
Usage
evaluate_models(
input_data,
target_var,
vars,
coords_x,
coords_y,
VC_type = "SVC",
time_var = NULL,
ncores = 2
)
Arguments
input_data |
he data to be used used to create the GAM model in ( |
target_var |
the name of the target variable. |
vars |
a vector of the predictor variable names (without the Intercept). |
coords_x |
the name of the X, Easting or Longitude variable in |
coords_y |
the name of the Y, Northing or Latitude variable in |
VC_type |
the type of varying coefficient model: options are "TVC" for temporally varying, "SVC" for spatially varying and "STVC" for space-time . |
time_var |
the name of the time variable if undertaking STVC model evaluations. |
ncores |
the number of cores to use in parallelised approaches (default is 2 to overcome CRAN package checks). This can be determined for your computer by running parallel::detectCores()-1. Parallel approaches are only undertaken if the number of models to evaluate is greater than 30. |
Value
a data.frame
with indices for each predictor variable, a GCV score (gcv
) for each model and the associated formula (f
), which should be passed to the gam_model_rank
function.
Examples
require(dplyr)
require(doParallel)
# define input data
data("hp_data")
input_data <-
hp_data |>
# create Intercept as an addressable term
mutate(Intercept = 1)
# evaluate different model forms
svc_mods <-
evaluate_models(
input_data = input_data,
target_var = "priceper",
vars = c("pef"),
coords_x = "X",
coords_y = "Y",
VC_type = "SVC",
time_var = NULL,
ncores = 2
)
head(svc_mods)