Simulate a dataset for the Function Linear Regression model.
sim(param, verbose = FALSE)
a list containing:
a character vector. The qth item indicates the shape of the coefficient function associated to the qth functional covariate.
an integer, the sample size.
a vector of integers, the qth component is the number of times for the qth covariate.
an integer, the number of functional covariates.
a list of numerical vectors (optional), the qth vector is the diagonal of the autocorrelation matrix of the qth functional covariate.
a vector of numerical values (optional) which are related to the autocorrelation of the functional covariates.
a list of numerical vectors (optional), the qth vector is the grid of time points for the qth functional covariate.
a list of numerical vectors (optional), the qth item is the lower and upper boundaries of the domain for the qth functional covariate.
a function (optional) to simulate data from the Generalized Functional Linear Regression model.
a numerical value (optional), the 'true' intercept of the model.
a nonnegative value (optional), the signal to noise ratio.
a character vector (optional). The qth item indicates the shape of the functional covariate observations.
write stuff if TRUE.
a list containing:
an integer, the number of functional covariates.
a numerical vector, the outcome observations.
a list of matrices, the qth matrix contains the observations of the
qth functional covariate at time points given by grids
.
a list of numerical vectors, the qth vector is the grid of time points for the qth functional covariate.
a list of numerical vectors, the qth vector is the 'true' coefficient
function associated to the qth covariate on a grid of time points
given with grids
.
library(RColorBrewer)
param <- list(Q=2,n=25,p=c(50,50),grids_lim=list(c(0,1),c(-1,2)))
data <- sim(param)
data$y
#> [1] -0.07523791 1.42388599 -1.04205481 -6.17223970 -0.34377209 1.67340623
#> [7] -2.04235847 0.96166013 3.83421313 1.38729295 -1.83859996 4.62176299
#> [13] 2.04921455 -2.53716763 -2.27038049 -1.92382212 -1.89918298 -4.10873633
#> [19] -2.43523209 3.12831497 3.39156753 0.18056162 0.13227332 -1.28339913
#> [25] 1.07399183
cols <- colorRampPalette(brewer.pal(9,"YlOrRd"))(10)
q=2
matplot(data$grids[[q]],t(data$x[[q]]),type="l",lty=1,col=cols)
plot(data$grids[[q]],data$betas[[q]],type="l")
abline(h=0,lty=2,col="gray")