generateData {geeVerse} | R Documentation |
Generate Data for Simulation
Description
This function generates simulated data including the predictor matrix 'X' and the response vector 'y', based on the specified parameters. The function allows for the simulation of data under different settings of correlation, distribution, and the number of observations and subjects.
Usage
generateData(
nsub,
nobs,
p,
beta0,
rho,
correlation = "AR1",
dis = "normal",
ka = 0,
SNPs = NULL
)
Arguments
nsub |
Integer, the number of subjects. |
nobs |
Integer or numeric vector, the number of observations per subject. |
p |
Integer, the number of predictors. |
beta0 |
Numeric vector, initial coefficients for the first few predictors. |
rho |
Numeric, the correlation coefficient used in generating correlated errors. |
correlation |
Character, the correlation of correlation structure (default is autoregressive). |
dis |
Character, the distribution of errors ("normal" or "t"). |
ka |
1 for heterogeneous errors and 0 for homogeneous errors. |
SNPs |
User can provide simulated or real SNPs for genetic data simulation. |
Value
A list containing two elements: 'X', the matrix of predictors, and 'y', the response vector.
Examples
sim_data <- generateData(nsub = 100, nobs = rep(10, 100), p = 200,
beta0 = c(rep(1,7),rep(0,193)), rho = 0.6, correlation = "AR1",
dis = "normal", ka = 1)