sim: sim

View source: R/Simulate_Data.R

simR Documentation

sim

Description

Simulate a dataset for the Function Linear Regression model.

Usage

sim(param, verbose = FALSE)

Arguments

param

a list containing:

beta_shapes

a character vector. The qth item indicates the shape of the coefficient function associated to the qth functional covariate.

n

an integer, the sample size.

p

a vector of integers, the qth component is the number of times for the qth covariate.

Q

an integer, the number of functional covariates.

autocorr_diag

a list of numerical vectors (optional), the qth vector is the diagonal of the autocorrelation matrix of the qth functional covariate.

autocorr_spread

a vector of numerical values (optional) which are related to the autocorrelation of the functional covariates.

grids

a list of numerical vectors (optional), the qth vector is the grid of time points for the qth functional covariate.

grids_lim

a list of numerical vectors (optional), the qth item is the lower and upper boundaries of the domain for the qth functional covariate.

link

a function (optional) to simulate data from the Generalized Functional Linear Regression model.

mu

a numerical value (optional), the 'true' intercept of the model.

r

a nonnegative value (optional), the signal to noise ratio.

x_shapes

a character vector (optional). The qth item indicates the shape of the functional covariate observations.

verbose

write stuff if TRUE.

Value

a list containing:

Q

an integer, the number of functional covariates.

y

a numerical vector, the outcome observations.

x

a list of matrices, the qth matrix contains the observations of the qth functional covariate at time points given by grids.

grids

a list of numerical vectors, the qth vector is the grid of time points for the qth functional covariate.

betas

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.

Examples

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
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")

bliss documentation built on March 18, 2022, 5:46 p.m.