calculate_vcs {stgam}R Documentation

Extracts varying coefficient estimates (for SVC, TVC and STVC models).

Description

Extracts varying coefficient estimates (for SVC, TVC and STVC models).

Usage

calculate_vcs(model, terms, data)

Arguments

model

a GAM model with smooths created using the mgcv package

terms

a vector of names starting with "Intercept" plus the names of the covariates used in the GAM model (these are the names of the variables in data )

data

the data used to create the GAM model, data.frame or tibble format

Value

A data.frame of the input data and the coefficient and standard error estimates for each covariate.

Examples

library(dplyr)
library(mgcv)
# SVC
data(productivity)
data = productivity |> dplyr::filter(year == "1970") |> mutate(Intercept = 1)
gam.svc.mod = gam(privC ~ 0 + Intercept +
                  s(X, Y, bs = 'gp', by = Intercept) +
                  unemp + s(X, Y, bs = "gp", by = unemp) +
                  pubC + s(X, Y, bs = "gp", by = pubC),
                  data = data)
terms = c("Intercept", "unemp", "pubC")
svcs = calculate_vcs(gam.svc.mod, terms, data)

[Package stgam version 0.0.1.0 Index]