evaluate_models {stgam}R Documentation

Creates and evaluates multiple varying coefficient GAM GP smooth models (SVC or STVC)

Description

Creates and evaluates multiple varying coefficient GAM GP smooth models (SVC or STVC)

Usage

evaluate_models(
  input_data,
  target_var = "privC",
  covariates = c("unemp", "pubC"),
  coords_x = "X",
  coords_y = "Y",
  STVC = FALSE,
  time_var = NULL,
  ncores = 2
)

Arguments

input_data

a data.frame, tibble sf containing the target variables, covariates and coordinate variables

target_var

the name of the target variable in data

covariates

the name of the covariates (predictor variables) in data

coords_x

the name of the X, Easting or Longitude variable in data

coords_y

the name of the Y, Northing or Latitude variable in data

STVC

a logical operator to indicate whether the models Space-Time (TRUE) or just Space (FALSE)

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 table in data.frame format of all possible model combinations with each covariate specified in all possible ways, with the BIC of the model and the model formula.

Examples

library(dplyr)
library(glue)
library(purrr)
library(doParallel)
library(mgcv)
data("productivity")
input_data = productivity |> filter(year == "1970")
svc_res_gam =
  evaluate_models(input_data = input_data,
                  target_var = "privC",
                  covariates = c("unemp", "pubC"),
                  coords_x = "X",
                  coords_y = "Y",
                  STVC = FALSE)
head(svc_res_gam)

[Package stgam version 0.0.1.1 Index]