The VDPO package provides, among other tools, methods for analyzing
variable domain functional data. This vignette demonstrates how to fit
variable domain functional regression models using the
vd_fit
function, which is designed to handle various types
of functional and non-functional covariates in a flexible framework.
We’ll start by generating sample data using the
data_generator_vd
function. This function creates simulated
data with variable domain functional covariates and additional
non-functional covariates if specified.
The vd_fit
function is the main tool for fitting
variable domain functional regression models. It supports various model
specifications through a formula interface.
Let’s start with a basic model using only the functional covariate:
If your data contains multiple functional covariates, you can include them in the model:
The vd_fit
function also supports including
non-functional covariates, both linear and smooth terms:
data <- data_generator_vd(beta_index = 1, use_x = TRUE, use_f = TRUE)
formula <- y ~ ffvd(X_se, nbasis = c(10, 10, 10)) + f(x2, nseg = 30, pord = 2, degree = 3) + x1
res_complex <- vd_fit(formula = formula, data = data)
In this model:
ffvd(X_se, nbasis = c(10, 10, 10))
specifies the
functional covariatef(x2, nseg = 30, pord = 2, degree = 3)
adds a smooth
effect for x2
x1
is included as a linear termYou can obtain a summary of the fitted model using the
summary
function:
summary(res_complex)
#>
#> Family: gaussian
#> Link function: identity
#>
#>
#> Formula:
#> NULL
#>
#>
#> Fixed terms:
#> x2
#> 1.4678062 0.9742174 -0.1430355 -3.5265899 5.2136636 -10.5801911
#>
#> 6.0838833
#>
#>
#> Estimated degrees of freedom:
#> Total edf Total <NA> <NA> <NA>
#> 4.9380 4.5461 0.0001 9.4842 16.4842
#>
#> R-sq.(adj) = 0.958 Deviance explained = 97.5% n = 100
#>
#> Number of iterations: 1
The vd_fit
function can handle both aligned and
non-aligned functional data. Here’s an example with non-aligned
data:
If you need to include an offset in your model, you can use the
offset
argument:
The vd_fit
function in the VDPO package provides a
flexible and powerful tool for fitting variable domain functional
regression models. It supports a wide range of model specifications,
including multiple functional covariates, non-functional covariates, and
various distribution families. By leveraging the formula interface,
users can easily specify complex models tailored to their specific
analysis needs.