sim-frmfr {goffda} | R Documentation |
Sampling functional regression models with functional responses
Description
Simulation of a Functional Regression Model with Functional Response (FRMFR) comprised of an additive mix of a linear and nonlinear terms:
Y(t) = \int_a^b X(s) \beta(s,t) ds + \Delta(X)(t) + \varepsilon(t),
where X
is a random variable in the Hilbert space of
square-integrable functions in [a, b]
, L^2([a, b])
,
\beta
is the bivariate kernel of the FRMFR,
\varepsilon
is a random variable in L^2([c, d])
,
and \Delta(X)
is a nonlinear term.
In particular, the scenarios considered in García-Portugués et al. (2021) can be easily simulated.
Usage
r_frm_fr(n, scenario = 3, X_fdata = NULL, error_fdata = NULL,
beta = NULL, s = seq(0, 1, l = 101), t = seq(0, 1, l = 101),
std_error = 0.15, nonlinear = NULL, concurrent = FALSE,
int_rule = "trapezoid", n_fpc = 50, verbose = FALSE, ...)
nl_dev(X_fdata, t = seq(0, 1, l = 101), nonlinear = NULL,
int_rule = "trapezoid", equispaced = equispaced, verbose = FALSE)
Arguments
n |
sample size, only required when |
scenario |
an index from |
X_fdata |
sample of functional covariates |
error_fdata |
sample of functional errors |
beta |
matrix containing the values |
s , t |
grid points. If |
std_error |
standard deviation of the random variables
involved in the generation of the functional error |
nonlinear |
nonlinear term. Either a character string ( |
concurrent |
flag to consider a concurrent FLRFR (degenerate case).
Defaults to |
int_rule |
quadrature rule for approximating the definite
unidimensional integral: trapezoidal rule ( |
n_fpc |
number of components to be considered for the generation of
functional variables. Defaults to |
verbose |
flag to display information about the sampling procedure.
Defaults to |
... |
further parameters passed to
|
equispaced |
flag to indicate if |
Details
r_frm_fr
samples the above regression model, where the nonlinear term\Delta(X)
is computed bynl_dev
. Functional covariates, errors, and\beta
are generated automatically from the scenarios in García-Portugués et al. (2021) whenscenario != NULL
(see the documentation ofr_gof2021_flmfr
). Ifscenario = NULL
, covariates, errors and\beta
must be provided.When
concurrent = TRUE
, the concurrent FRMFRY(t) = X(t) \beta(t) + \Delta(X)(t) + \varepsilon(t)
is considered.
nl_dev
computes a nonlinear deviation\Delta(X)
:\exp(\sqrt{X(a + (t - c) ((b - a) / (d - c)))})
(for"exp"
),(X^2 (a + (t - c) ((b - a) / (d - c))) - 1)
("quadratic"
) or(\sin(2\pi t) - \cos(2 \pi t)) \| X \|^2
("sin"
). Also,\Delta(X)
can be manually set as anfdata
object of lengthn
and valued in the same grid aserror_fdata
.
Value
A list with the following elements:
X_fdata |
functional covariates, an
|
Y_fdata |
functional responses, an
|
error_fdata |
functional errors, an
|
beta |
either the matrix with |
nl_dev |
nonlinear term, an |
Author(s)
Javier Álvarez-Liébana.
References
García-Portugués, E., Álvarez-Liébana, J., Álvarez-Pérez, G. and Gonzalez-Manteiga, W. (2021). A goodness-of-fit test for the functional linear model with functional response. Scandinavian Journal of Statistics, 48(2):502–528. doi:10.1111/sjos.12486
Examples
## Generate samples for the three scenarios
# Equispaced grids and Simpson's rule
s <- seq(0, 1, l = 101)
samp <- list()
old_par <- par(mfrow = c(3, 5))
for (i in 1:3) {
samp[[i]] <- r_frm_fr(n = 100, scenario = i, s = s, t = s,
int_rule = "Simpson")
plot(samp[[i]]$X_fdata)
plot(samp[[i]]$error_fdata)
plot(samp[[i]]$Y_fdata)
plot(samp[[i]]$nl_dev)
image(x = s, y = s, z = samp[[i]]$beta, col = viridisLite::viridis(20))
}
par(old_par)
## Linear term as a concurrent model
# The grids must be have the same number of grid points for a given
# nonlinear term and a given beta function
s <- seq(1, 2, l = 101)
t <- seq(0, 1, l = 101)
samp_c_1 <- r_frm_fr(n = 100, scenario = 3, beta = sin(t) - exp(t),
s = s, t = t, nonlinear = fda.usc::fdata(mdata =
t(matrix(rep(sin(t), 100), nrow = length(t))),
argvals = t),
concurrent = TRUE)
old_par <- par(mfrow = c(3, 2))
plot(samp_c_1$X_fdata)
plot(samp_c_1$error_fdata)
plot(samp_c_1$Y_fdata)
plot(samp_c_1$nl_dev)
plot(samp_c_1$beta)
par(old_par)
## Sample for given X_fdata, error_fdata, and beta
# Non equispaced grids with sinusoidal nonlinear term and intensity 0.5
s <- c(seq(0, 0.5, l = 50), seq(0.51, 1, l = 101))
t <- seq(2, 4, len = 151)
X_fdata <- r_ou(n = 100, t = s, alpha = 2, sigma = 4, x0 = 1:100)
error_fdata <- r_ou(n = 100, t = t, alpha = 1, sigma = 1, x0 = 1:100)
beta <- r_gof2021_flmfr(n = 100, s = s, t = t)$beta
samp_Xeps <- r_frm_fr(scenario = NULL, X_fdata = X_fdata,
error_fdata = error_fdata, beta = beta,
nonlinear = "exp", int_rule = "trapezoid")
old_par <- par(mfrow = c(3, 2))
plot(samp_Xeps$X_fdata)
plot(samp_Xeps$error_fdata)
plot(samp_Xeps$Y_fdata)
plot(samp_Xeps$nl_dev)
image(x = s, y = t, z = beta, col = viridisLite::viridis(20))
par(old_par)