ancova.random.data: Generate random data for an ANCOVA model

View source: R/ancova.random.data.R

ancova.random.dataR Documentation

Generate random data for an ANCOVA model

Description

Generate random data for a simple (one-response-one-covariate) ANCOVA model considering the covariate as random. Data can be generated in the contexts of both randomized design (same population covariate mean across groups) and non-randomized design (different population covariate means across groups).

Usage

ancova.random.data(mu.y, mu.x, sigma.y, sigma.x, rho, J, n, randomized = TRUE)

Arguments

mu.y

a vector of the population group means of the response variable

mu.x

the population mean of the covariate (in the randomized design context), or a vector of the population group means of the covariate (in the non-randomized design context)

sigma.y

the population standard deviation of the response (outcome) variable

sigma.x

the population standard deviation of the covariate

rho

the population correlation coefficient between the response and the covariate

J

the number of groups

n

the number of sample size per group

randomized

a logical statement of whether randomized design is used

Details

This function uses a multivariate normal distribution to generate the random data; the covariate is considered as a random variable in the model. This function uses mvrnorm in the MASS package in an internal function, and thus it requires the MASS package be installed.

This function assumes homogeneous covariance matrix among groups, in both the randomized design and non-randomized design contexts.

Value

This function returns an n by J2 matrix, where n and J are as defined in the argument. The first J columns of the matrix contains the random data for the response, and the second J columns of the matrix contains the random data for the covariate.

Author(s)

Keke Lai (University of California-Merced) and Ken Kelley (University of Notre Dame) <kkelley@nd.edu>

See Also

mvrnorm in the MASS package

Examples

random.data <- ancova.random.data(mu.y=c(3,5), mu.x=10, sigma.y=1, 
sigma.x=2, rho=.8, J=2, n=20)

MBESS documentation built on Oct. 26, 2023, 9:07 a.m.