generateLongData: Generate longitudinal test data

View source: R/data.R

generateLongDataR Documentation

Generate longitudinal test data

Description

Generate longitudinal test data

Usage

generateLongData(
  sizes = c(40, 60),
  fixed = Value ~ 1,
  cluster = ~1 + Time,
  random = ~1,
  id = getOption("latrend.id"),
  data = data.frame(Time = seq(0, 1, by = 0.1)),
  fixedCoefs = 0,
  clusterCoefs = cbind(c(-2, 1), c(2, -1)),
  randomScales = cbind(0.1, 0.1),
  rrandom = rnorm,
  noiseScales = c(0.1, 0.1),
  rnoise = rnorm,
  clusterNames = LETTERS[seq_along(sizes)],
  shuffle = FALSE,
  seed = NULL
)

Arguments

sizes

Number of strata per cluster.

fixed

Fixed effects formula.

cluster

Cluster effects formula.

random

Random effects formula.

id

Name of the strata.

data

Data with covariates to use for generation. Stratified data may be specified by adding a grouping column.

fixedCoefs

Coefficients matrix for the fixed effects.

clusterCoefs

Coefficients matrix for the cluster effects.

randomScales

Standard deviations matrix for the size of the variance components (random effects).

rrandom

Random sampler for generating the variance components at location 0.

noiseScales

Scale of the random noise passed to rnoise. Either scalar or defined per cluster.

rnoise

Random sampler for generating noise at location 0 with the respective scale.

clusterNames

A character vector denoting the names of the generated clusters.

shuffle

Whether to randomly reorder the strata in which they appear in the data.frame.

seed

Optional seed to set for the PRNG. The set PRNG state persists after the function completes.

See Also

latrend-data

Examples

longdata <- generateLongData(
  sizes = c(40, 70), id = "Id",
  cluster = ~poly(Time, 2, raw = TRUE),
  clusterCoefs = cbind(c(1, 2, 5), c(-3, 4, .2))
)

if (require("ggplot2")) {
  plotTrajectories(longdata, response = "Value", id = "Id", time = "Time")
}

latrend documentation built on March 31, 2023, 5:45 p.m.