## 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)
Run the code above in your browser using DataLab