Fit a hierarchical GAM model with/without a single common smoother (common_trend) plus group-level smoothers with differing wiggliness (random effect). If there is less number of groups in the dataset than 2, a normal GAM model will be fitted. This function is a wrapper for complex mgcv::bam(). If use_parallel is TRUE, the number of cores is automatically detected.

fit_hgam(
  x_var = "age",
  y_var = "var",
  group_var = "dataset_id",
  error_family = "gaussian(link = 'identity')",
  weights_var = NULL,
  smooth_basis = c("tp", "cr"),
  data_source,
  sel_k = 10,
  sel_m = NULL,
  common_trend = TRUE,
  use_parallel = TRUE,
  use_discrete = FALSE,
  max_iterations = 200,
  verbose = TRUE
)

Arguments

x_var

Character. Name of the X-variable

y_var

Character. Name of the Y-variable

group_var

Character. Name of the variable used for identification of groups.

error_family

Character. Name of the error family to be used

weights_var

Character. Name of the variable to use as weights

smooth_basis

Character. Name of the Smooth basis to use

data_source

Data.frame with columns whose names are set by y_var and x_var

sel_k

Numeric. Define k (wiggliness)

sel_m

Numeric. The user specifies the order of the penalty for this term. if NULL, the function will use 1 or 2 depending on the presence of common trend.

common_trend

Logical. Should hGAM have a common shared trend?

use_parallel

Logical. Should computation use parallel?

use_discrete

Logical. Should the discrete argument be used for parallel computation?

max_iterations

Numeric. Maximum number of iterations for GAM to try.

verbose

Logical. Should additional messages be output?

Value

Fitted hGAM model

See also