simulate_mfd {funcharts} | R Documentation |
Simulate a data set for funcharts
Description
Function used to simulate a data set to illustrate
the use of funcharts
.
By default, it creates a data set with three functional covariates,
a functional response generated as a function of the
three functional covariates
through a function-on-function linear model,
and a scalar response generated as a function of the
three functional covariates
through a scalar-on-function linear model.
This function covers the simulation study in Centofanti et al. (2021)
for the function-on-function case and also simulates data in a similar way
for the scalar response case.
It is possible to select the number of functional covariates,
the correlation function type for each functional covariate
and the functional response, moreover
it is possible to provide manually the mean and variance functions
for both functional covariates and the response.
In the default case, the function generates in-control data.
Additional arguments can be used to generate additional
data that are out of control,
with mean shifts according to the scenarios proposed
by Centofanti et al. (2021).
Each simulated observation of a functional variable consists of
a vector of discrete points equally spaced between 0 and 1 (by default
150 points),
generated with noise.
Usage
simulate_mfd(
nobs = 1000,
p = 3,
R2 = 0.97,
shift_type_y = "0",
shift_type_x = c("0", "0", "0"),
correlation_type_y = "Bessel",
correlation_type_x = c("Bessel", "Gaussian", "Exponential"),
d_y = 0,
d_y_scalar = 0,
d_x = c(0, 0, 0),
n_comp_y = 10,
n_comp_x = 50,
P = 500,
ngrid = 150,
save_beta = FALSE,
mean_y = NULL,
mean_x = NULL,
variance_y = NULL,
variance_x = NULL,
sd_y = 0.3,
sd_x = c(0.3, 0.05, 0.3),
seed
)
Arguments
nobs |
The number of observation to simulate |
p |
The number of functional covariates to simulate. Default value is 3. |
R2 |
The desired coefficient of determination in the regression in both the scalar and functional response cases, Default is 0.97. |
shift_type_y |
The shift type for the functional response. There are five possibilities: "0" if there is no shift, "A", "B", "C" or "D" for the corresponding shift types shown in Centofanti et al. (2021). Default is "0". |
shift_type_x |
A list of length |
correlation_type_y |
A character vector indicating the type of correlation function for
the functional response.
See Centofanti et al. (2021)
for more details. Three possible values are available,
namely |
correlation_type_x |
A list of |
d_y |
A number indicating the severity of the shift type for the functional response. Default is 0. |
d_y_scalar |
A number indicating the severity of the shift type for the scalar response. Default is 0. |
d_x |
A list of |
n_comp_y |
A positive integer number indicating how many principal components obtained after the eigendecomposiiton of the covariance function of the functional response variable to retain. Default value is 10. |
n_comp_x |
A positive integer number indicating how many principal components obtained after the eigendecomposiiton of the covariance function of the multivariate functional covariates variable to retain. Default value is 50. |
P |
A positive integer number indicating the number of equally spaced grid points over which the covariance functions are discretized. Default value is 500. |
ngrid |
A positive integer number indicating the number of equally spaced grid points between zero and one over which all functional observations are discretized before adding noise. Default value is 150. |
save_beta |
If TRUE, the true regression coefficients of both the function-on-function and the scalar-on-function models are saved. Default is FALSE. |
mean_y |
The mean function of the functional response can be set manually
through this argument. If not NULL, it must be a vector of length
equal to |
mean_x |
The mean function of the functional covariates can be set manually
through this argument. If not NULL, it must be a list of vectors,
each with length equal to |
variance_y |
The variance function of the functional response can be set manually
through this argument. If not NULL, it must be a vector of length
equal to |
variance_x |
The variance function of the functional covariates can be set manually
through this argument. If not NULL, it must be a list of vectors,
each with length equal to |
sd_y |
A positive number indicating the standard deviation of the generated noise with which the functional response discretized values are observed. Default value is 0.3 |
sd_x |
A vector of |
seed |
Deprecated: use |
Value
A list with the following elements:
-
X_list
is a list ofp
matrices, each with dimensionnobs
xngrid
, containing the simulated observations of the multivariate functional covariate -
Y
is anobs
xngrid
matrix with the simulated observations of the functional response -
y_scalar
is a vector of lengthnobs
with the simulated observations of the scalar response -
beta_fof
, ifsave_beta = TRUE
, is a list ofp
matrices, each with dimensionP
xP
with the discretized functional coefficients of the function-on-function regression -
beta_sof
, ifsave_beta = TRUE
, is a list ofp
vectors, each with lengthP
, with the discretized functional coefficients of the scalar-on-function regression
References
Centofanti F, Lepore A, Menafoglio A, Palumbo B, Vantini S. (2021) Functional Regression Control Chart. Technometrics, 63(3), 281–294. doi:10.1080/00401706.2020.1753581