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(input_data, model, terms)
Arguments
input_data |
the data used to create the GAM model in |
model |
a GAM model with smooths created using the |
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 |
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)
input_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 = input_data)
terms = c("Intercept", "unemp", "pubC")
svcs = calculate_vcs(input_data, gam.svc.mod, terms)
head(svcs)
[Package stgam version 0.0.1.1 Index]