build_gam_formula: Build a GAM formula with automatic smooth terms

View source: R/helper_vimpute.R

build_gam_formulaR Documentation

Build a GAM formula with automatic smooth terms

Description

Constructs a formula for mgcv::gam() by wrapping numeric predictors with sufficient unique values in s() terms and keeping factors as linear terms.

Usage

build_gam_formula(target, features, data, min_unique = 4L, default_k = 10L)

Arguments

target

Character: target variable name

features

Character vector: predictor variable names

data

Data frame used to check variable types and unique value counts

min_unique

Integer: minimum number of unique values for a numeric predictor to be wrapped in s(). Default 4 (mgcv needs at least k=3 knots).

Value

A formula object suitable for mgcv::gam()


VIM documentation built on Sept. 2, 2026, 5:07 p.m.