Skip to content

Commit

Permalink
Adding copula links to vignette
Browse files Browse the repository at this point in the history
  • Loading branch information
kgoldfeld committed Oct 21, 2020
1 parent b31941a commit 75b5d8d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions vignettes/correlated.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ggtheme <- function(panelback = "white") {

## Correlated data

Sometimes it is desirable to simulate correlated data from a correlation matrix directly. For example, a simulation might require two random effects (e.g. a random intercept and a random slope). Correlated data like this could be generated using the `defData` functionality, but it may be more natural to do this with `genCorData` or `addCorData`. Currently, simstudy can only generate multivariate normal using these functions. (In the future, additional distributions will be available.)
Sometimes it is desirable to simulate correlated data from a correlation matrix directly. For example, a simulation might require two random effects (e.g. a random intercept and a random slope). Correlated data like this could be generated using the `defData` functionality, but it may be more natural to do this with `genCorData` or `addCorData`. Currently, simstudy can only generate multivariate normal using these functions.

`genCorData` requires the user to specify a mean vector `mu`, a single standard deviation or a vector of standard deviations `sigma`, and either a correlation matrix `corMatrix` or a correlation coefficient `rho` and a correlation structure `corsrt`. Here are a few examples:

Expand Down Expand Up @@ -103,7 +103,7 @@ dt[,round(sqrt(diag(var(cbind(a0, a1)))),1)]

Two additional functions facilitate the generation of correlated data from *binomial*, *poisson*, *gamma*, and *uniform* distributions: `genCorGen` and `addCorGen`.

`genCorGen` is an extension of `genCorData`. In the first example, we are generating data from a multivariate Poisson distribution. We start by specifying the mean of the Poisson distribution for each new variable, and then we specify the correlation structure, just as we did with the normal distribution.
`genCorGen` is an extension of `genCorData`. These functions draw on copula-based methods to generate the data. (This [Wikipedia page](https://bit.ly/31vAxFf) provides a general introduction and copula-based modeling can be conducted in `R` using package [copula](https://cran.r-project.org/web/packages/copula/index.html).) In the first example, we are generating data from a multivariate Poisson distribution. We start by specifying the mean of the Poisson distribution for each new variable, and then we specify the correlation structure, just as we did with the normal distribution.

```{r}
l <- c(8, 10, 12) # lambda for each new variable
Expand Down

0 comments on commit 75b5d8d

Please sign in to comment.