simdata: Simulate multivariate data for testing

View source: R/simdata.R

simdataR Documentation

Simulate multivariate data for testing

Description

Creates multivariate normal or normal and binary data, as used in the simulation study.

Usage

simdata(n = 2000, mymean = rep(0, 4), mysigma = matrix(
	c( 1,   0.2, 0.1, -0.7,
	   0.2, 1,   0.3,  0.1,
	   0.1, 0.3, 1,    0.2,
	  -0.7, 0.1, 0.2,  1), byrow = TRUE, nrow = 4, ncol = 4),
	residsd = 1, x2binary = FALSE)

Arguments

n

number of observations to create.

mymean

vector of length 4, giving the mean of each variable.

mysigma

variance-covariance matrix of multivariate normal distribution from which x1-x4 are to be drawn.

residsd

residual standard deviation.

x2binary

if TRUE, x2 is converted to a binary factor variable (1, 2) with probability equal to the logistic of the underlying normally distributed variable.

Value

Data frame with 5 columns:

y

continuous, generated by y = x1 + x2 + x3 + normal error if x2 is continuous, or y = x1 + x2 + x3 - 1 + normal error if x2 is a factor with values 1 or 2

x1

continuous

x2

continuous or binary (factor) with value 1 or 2

x3

continuous

x4

continuous

See Also

makemar

Examples

set.seed(1)
simdata(n=4, x2binary=TRUE)
#             y          x1 x2         x3        x4
# 1 -0.06399616 -1.23307320  2 -0.6521442 1.6141842
# 2  1.00822173 -0.05167026  1  0.4659907 0.5421826
# 3  2.87886825  0.43816687  1  1.5217240 0.2808691
# 4  0.79129101 -0.72510640  1  0.7342611 0.1820001

CALIBERrfimpute documentation built on Dec. 5, 2022, 1:07 a.m.