Description Usage Arguments Examples
genDat function is the simulation function of the package timsync. genDat generates any variable for the time series data with synchrony.
1 |
x |
Independent variable. Vector or matrix. |
beta |
Coefficients of x. |
n_time |
Length of the time series |
n_grp |
Number of groups. |
z |
Random variables. Vector or matrix. |
OmegaMat |
List of Variance-Covariance Matrix (Omega matrix) for the random effects. |
sig |
Vector of the standard deviation of the random variables or error term. The last element should be that of the error term. |
rho |
Parameter of serial correlation of the error term. |
omega |
Parameter of synchronization of the error term. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## Generate independent variable.
y0 <- genDat(x = 0, beta = 0, n_time = 20, n_grp = 3, rho = 0.3, omega = 0.8)
grp <- makeGrp(n_time = 20, n_grp = 3)
dat <- data.frame(y0 = y0$objVar, time = rep(1:20, 3), grp = grp)
ggplot(dat, aes(x = time, y = y0, color = grp)) + geom_line()
## Generate independent variable with random group means.
Omega <- makeOmega(n_time = 20, n_grp = 3, rho = 1, omega = 0)
y0 <- genDat(x = 0, beta = 0, n_time = 20, n_grp = 3,
z = 1, OmegaMat = list(Omega), sig = c(1, 1),
rho = 0.3, omega = 0.8)
grp <- makeGrp(n_time = 20, n_grp = 3)
dat <- data.frame(y0 = y0$objVar, time = rep(1:20, 3), grp = grp)
ggplot(dat, aes(x = time, y = y0, color = grp)) + geom_line()
## Generate dependent variable with random effects.
x1 <- rnorm(20 * 3, 0, 1)
Omega_0 <- makeOmega(n_time = 20, n_grp = 3, rho = 0.5, omega = 0.5)
Omega_1 <- makeOmega(n_time = 20, n_grp = 3, rho = 0.5, omega = 0.5)
Z <- cbind(rep(1, 20 * 3), x1)
y0 <- genDat(x = x1, beta = 5, n_time = 20, n_grp = 3,
z = Z, OmegaMat = list(Omega_0, Omega_1), sig = c(1, 1, 1),
rho = 0.3, omega = 0.8)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.