Learn R Programming

CatReg (version 2.0.4)

CorrelatedDesignMatrix: Create a design matrix of categorical variables with correlated columns.

Description

Function for use in simulations. Created design matrix of categorical variables with correlated columns

Usage

CorrelatedDesignMatrix(n, cov_mat, c)

Value

A data frame of categorical (factor) variables.

Arguments

n

Number of observations

cov_mat

p x p covariance matrix. Controls correlations of pairs of marginally U[0,1] random variables that are subsequently binned to assign categories for each variable

c

Number of categories within each variable

Examples

Run this code
# Generate matrix of marginal U[0,1] variables, 0.5 pairwise correlation, that are
# discretised into factor variables
cov_mat = 0.5 * diag(10) + 0.5 * matrix(1, 10, 10)
x = CorrelatedDesignMatrix(100, cov_mat, 8)

Run the code above in your browser using DataLab