simulate_gvm {varian} | R Documentation |
Simulate a Gamma Variability Model
Description
This function facilitates simulation of a Gamma Variability Model and allows the number of units and repeated measures to be varied as well as the degree of variability.
Usage
simulate_gvm(n, k, mu, mu.sigma, sigma.shape, sigma.rate, seed = 5346)
Arguments
n |
The number of repeated measures on each unit |
k |
The number of units |
mu |
The grand mean of the variable |
mu.sigma |
The standard deviation of the random mean of the variable |
sigma.shape |
the shape (alpha) parameter of the Gamma distribution controlling the residual variability |
sigma.rate |
the rate (beta) parameter of the Gamma distribution controlling the residual variability |
seed |
the random seed, used to make simulations reproductible. Defaults to 5346 (arbitrarily). |
Value
a list of the data, IDs, and the parameters used for the simulation
Author(s)
Joshua F. Wiley <josh@elkhartgroup.com>
Examples
raw.sim <- simulate_gvm(12, 140, 0, 1, 4, .1, 94367)
sim.data <- with(raw.sim, {
set.seed(265393)
x2 <- MASS::mvrnorm(k, c(0, 0), matrix(c(1, .3, .3, 1), 2))
y2 <- rnorm(k, cbind(Int = 1, x2) %*% matrix(c(3, .5, .7)) + sigma, sd = 3)
data.frame(
y = Data$y,
y2 = y2[Data$ID2],
x1 = x2[Data$ID2, 1],
x2 = x2[Data$ID2, 2],
ID = Data$ID2)
})
[Package varian version 0.2.2 Index]