sim_discr: Simulate co-varying variables with different means by group

View source: R/sim_multvar.R

sim_discrR Documentation

Simulate co-varying variables with different means by group

Description

To-do: make this work with 'dplyr::group_by()' instead of 'group ='

Usage

sim_discr(.data, n_vars, var, cov, group_means, name = NA, seed = NA)

Arguments

.data

A dataframe containing a grouping variable column.

n_vars

Number of variables to simulate.

var

Variance used to construct variance-covariance matrix.

cov

Covariance used to construct variance-covariance matrix.

group_means

A vector of the same length as the number of grouping variables.

name

An optional name to be appended to the column names in the output.

seed

An optional seed for random number generation. If 'NA' (default) a random seed will be used.

Value

a tibble

See Also

sim_cat, sim_covar

Other multivariate normal functions: sim_cat(), sim_covar()

Examples

library(dplyr)
sim_cat(n_obs = 30, n_groups = 3) %>%
group_by(group) %>%
sim_discr(n_vars = 5, var = 1, cov = 0.5, group_means = c(-1, 0, 1), name = "descr")

holodeck documentation built on Aug. 26, 2023, 1:07 a.m.