vd_fit | R Documentation |
The vd_fit
function fits generalized additive functional regression models
for variable domain functional data.
vd_fit(formula, data, family = stats::gaussian(), offset = NULL)
formula |
a formula object with at least one |
data |
a |
family |
a |
offset |
An offset vector. The default value is |
An object of class vd_fit
. It is a list
containing the following items:
An item named fit
of class sop
. See sop.fit.
An item named Beta
which is the estimated functional coefficient.
An item named theta
which is the basis coefficient of Beta
.
An item named covar_theta
which is the covariance matrix of theta
.
An item named M
which is the number of observations points for each curve.
An item named ffvd_evals
which is the result of the evaluations of the ffvd
terms in the formula.
ffvd
# VARIABLE DOMAIN FUNCTIONAL DATA EXAMPLE
# set seed for reproducibility
set.seed(42)
# generate example data
data <- data_generator_vd(
N = 100,
J = 100,
beta_index = 1,
use_x = TRUE,
use_f = TRUE,
)
# Define a formula object that specifies the model behavior.
# The formula includes a functional form of the variable 'X_se' using 'ffvd'
# with a non-default number of basis functions ('nbasis' is set to c(10, 10, 10)).
# Additionally, it includes a smooth function 'f' applied to 'x2' with 10 segments ('nseg = 10'),
# a second-order penalty ('pord = 2'), and cubic splines ('degree = 3').
# The model also contains the linear term 'x1'.
formula <- y ~ ffvd(X_se, nbasis = c(10, 10, 10)) + f(x2, nseg = 10, pord = 2, degree = 3) + x1
# We can fit the model using the data and the formula
res <- vd_fit(formula = formula, data = data)
# Some important parameters of the model can be accesed as follows
res$Beta # variable domain functional coefficient
res$fit$fitted.values # estimated response variable
# Also, a summary of the fit can be accesed using the summary function
summary(res)
# And a heatmap for an specific beta can be obtained using the plot function
plot(res, beta_index = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.