gen_xs_corr: Generate correlated covariates X

Description Usage Arguments Value Examples

View source: R/simulation-lib.R

Description

Generate the X_i independently, but with each component of X_i distributed Multivariate Normal with mean 0 and covariance matrix with 1 on the diagonal and covar on the off-diagonal. Exported to the user.

Usage

1
gen_xs_corr(n, p, covar = 0.5)

Arguments

n

Number of observations to generate

p

Number of dimensions for each observation (includes the intercept)

covar

Off-diagonal element of covariance matrix.

Value

An n * (p-1) matrix of generated covariates

Examples

1
2
3
4
5
6
7
8
9
gen_xs_corr(10, 2)
gen_xs_corr(10, 2, 0.5)

set.seed(1)
# these should be equivalent
x1 <- gen_xs_corr(10, 2, 0)
set.seed(1)
x2 <- gen_xs_default(10, 2)
all(x1 == x2)

shiandy/methods1proj documentation built on Dec. 31, 2020, 5:15 a.m.