# smvrnorm: Simulate from a Multivariate Normal Distribution In stevemisc: Steve's Miscellaneous Functions

 smvrnorm R Documentation

## Simulate from a Multivariate Normal Distribution

### Description

`smvrnorm()` simulates data from a multivariate normal distribution.

### Usage

```smvrnorm(
n = 1,
mu,
sigma,
tol = 1e-06,
empirical = FALSE,
eispack = FALSE,
seed
)
```

### Arguments

 `n` the number of observations to simulate `mu` a vector of means `sigma` a positive-definite symmetric matrix specifying the covariance matrix of the variables. `tol` tolerance (relative to largest variance) for numerical lack of positive-definiteness in `sigma`. `empirical` logical. If true, `mu` and `sigma` specify the empirical not population mean and covariance matrix. `eispack` logical. values other than FALSE result in an error `seed` set an optional seed

### Details

This is a simple port and rename of `mvrnorm()` from the MASS package. I elect to plagiarize/port it because the MASS package conflicts with a lot of things in my workflow, especially `select()`. This is useful for "informal Bayes" approaches to generating quantities of interest from a regression model.

### Value

The function returns simulated data from a multivariate normal distribution.

### References

B. D. Ripley (1987) Stochastic Simulation. Wiley. Page 98.

### Examples

```
M1 <- lm(mpg ~ disp + cyl, mtcars)

smvrnorm(100, coef(M1), vcov(M1))

```

stevemisc documentation built on April 12, 2022, 5:06 p.m.