Description Usage Arguments Value Examples
A function that simulates correlated multivariate data based on a set of fixed and random effects.
1 2 |
n |
total sample size (number of clusters) |
fixed_effects |
list of fixed effect vectors for each outcome |
rand_effects |
list of random effect vectors for each outcome |
error_var |
vector of error variances for each outcome |
error_structure |
structure for the random error term, either |
rho |
correlation between outcomes |
times |
times for each repeated measure |
X |
fixed effect design matrix |
Z |
random effect design matrix |
A dataframe included simulated outcomes and the design matrices
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | set.seed(2112)
NN = 80
n_times = 1:3
## Simulating some data
simdat <- simDat(n = NN,
fixed_effects = list(c(1, 1, 2), c(1.5, 1, 3)),
rand_effects = list(1, 1),
error_var = c(4, 4),
error_structure = 'normal',
rho = .35,
times = n_times,
X = cbind(rep(1, NN * length(n_times)),
rnorm(NN * length(n_times), 0, 2),
rbinom(NN * length(n_times), 1, .5)),
Z = cbind(rep(1, NN * length(n_times))))
## Adding random missing values
aa <- sample(1:nrow(simdat), 10, replace = TRUE)
bb <- sample(1:7, 10, replace = TRUE)
for (i in 1:length(aa)) {
simdat[aa[i], bb[i]] <- NA
}
|
Loading required package: gee
Loading required package: lme4
Loading required package: Matrix
Loading required package: MASS
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.