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

ancova.random.data | R Documentation |

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).

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

`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 |

`randomized` |
a logical statement of whether randomized design is used |

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.

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.

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

`mvrnorm`

in the `MASS`

package

```
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)
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.