Description Usage Arguments Value Note Examples
View source: R/helper_functions.R
Simulate data from a function-on-scalar regression model, allowing for
subject-specific random effects. The predictors are multivariate normal with
mean zero and covariance corr^abs(j1-j2)
for correlation parameter corr
between predictors j1
and j2
.
More predictors than observations (p > n) is allowed.
1 2 | simulate_fosr(n = 100, m = 50, RSNR = 5, K_true = 4, p_0 = 1000,
p_1 = 5, sparse_factors = TRUE, corr = 0, perc_missing = 0)
|
n |
number of observed curves (i.e., number of subjects) |
m |
total number of observation points (i.e., points along the curve) |
RSNR |
root signal-to-noise ratio |
K_true |
rank of the model (i.e., number of basis functions used for the functional data simulations) |
p_0 |
number of true zero regression coefficients |
p_1 |
number of true nonzero regression coefficients |
sparse_factors |
logical; if TRUE, then for each nonzero predictor j, sample a subset of k=1:K_true factors to be nonzero#' |
corr |
correlation parameter for predictors |
perc_missing |
percentage of missing data (between 0 and 1); default is zero |
a list containing the following:
Y
: the simulated n x m
functional data matrix
X
: the simulated n x p
design matrix
tau
: the m
-dimensional vector of observation points
Y_true
: the true n x m
functional data matrix (w/o noise)
alpha_tilde_true
the true m x p
matrix of regression coefficient functions
alpha_arr_true
the true K_true x p
matrix of regression coefficient factors
Beta_true
the true n x K_true
matrix of factors
F_true
the true m x K_true
matrix of basis (loading curve) functions
sigma_true
the true observation error standard deviation
The basis functions (or loading curves) are orthonormalized polynomials,
so large values of K_true
are not recommended.
1 2 3 | # Example: simulate FOSR
sim_data = simulate_fosr(n = 100, m = 20, p_0 = 100, p_1 = 5)
Y = sim_data$Y; X = sim_data$X; tau = sim_data$tau
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.