vd_fit: Estimation of the generalized additive functional regression...

View source: R/vd_fit.R

vd_fitR Documentation

Estimation of the generalized additive functional regression models for variable domain functional data

Description

The vd_fit function fits generalized additive functional regression models for variable domain functional data.

Usage

vd_fit(formula, data, family = stats::gaussian(), offset = NULL)

Arguments

formula

a formula object with at least one ffvd term.

data

a list object containing the response variable and the covariates as the components of the list.

family

a family object specifying the distribution from which the data originates. The default distribution is gaussian.

offset

An offset vector. The default value is NULL.

Value

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.

See Also

ffvd

Examples

# 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)


VDPO documentation built on Oct. 21, 2024, 5:07 p.m.