Learn R Programming

holodeck (version 0.2.2)

sim_discr: 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)

Value

a tibble

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.

See Also

sim_cat, sim_covar

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

Examples

Run this code
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")

Run the code above in your browser using DataLab