knitr::opts_chunk$set( tidy = TRUE, tidy.opts = list(width.cutoff = 80), collapse = TRUE, comment = "#>", fig.path = "README-" )
You can install the release version of SimCorMultRes
:
install.packages("SimCorMultRes")
The source code for the release version of SimCorMultRes
is available on CRAN at:
Or you can install the development version of SimCorMultRes
:
# install.packages("devtools") devtools::install_github("AnestisTouloumis/SimCorMultRes")
The source code for the development version of SimCorMultRes
is available on github at:
To use SimCorMultRes
, you should load the package as follows:
library("SimCorMultRes")
This package provides five core functions to simulate correlated binary (rbin
), nominal (rmult.bcl
) and ordinal (rmult.acl
, rmult.clm
and rmult.crm
) responses, which are drawn as realizations of a latent regression model for continuous random vectors as proposed by @Touloumis2016:
rbin
to simulate correlated binary responses under a marginal model with logit, probit, cloglog and cauchit link function,rmult.bcl
to simulate correlated nominal multinomial responses under a marginal baseline-category logit model,rmult.acl
to simulate correlated ordinal responses under a marginal adjacent-category logit model,rmult.clm
to simulate correlated ordinal responses under a marginal cumulative link model,rmult.crm
to simulate correlated ordinal responses under a marginal continuation-ratio link model.All five functions, assume that you provide either the correlation matrix of the multivariate normal distribution in NORTA (via cor.matrix
) or the values of the latent responses (via the rlatent
). Based on a simulation study (see Section 3.5 of the vignette and dataset simulation
), it is indicated that the correlation matrix of the multivariate normal distribution used in the NORTA method (via cor.matrix
) can be considered a reliable approximation of the actual correlation matrix of the latent responses generated by the NORTA method. This appears to be the case irrespective of the marginal distributions of the latent responses for all the threshold approaches implemented in SimCorMultRes
.
There are also two utility functions:
rnorta
for simulating continuous or discrete random vectors with prescribed marginal distributions using the NORTA method,rsmvnorm
for simulating continuous random vectors from a multivariate normal distribution.The following R code illustrates how to use the core function rbin
:
## See Example 3.5 in the Vignette. set.seed(123) ## define number of random vectors sample_size <- 100 ## define size of each random vector cluster_size <- 4 ## define intercept of the binary probit regression model beta_intercepts <- 0 ## define coefficients of the explanatory variables beta_coefficients <- 0.2 ## provide explanatory variables x <- rep(rnorm(sample_size), each = cluster_size) ## define correlation matrix for the multivariate normal distribution in NORTA latent_correlation_matrix <- toeplitz(c(1, 0.9, 0.9, 0.9)) ## use rbin function to create the desired dataset simulated_binary_responses <- rbin(clsize = cluster_size, intercepts = beta_intercepts, betas = beta_coefficients, xformula = ~ x, cor.matrix = latent_correlation_matrix, link = "probit") library("gee") binary_gee_model <- gee(y ~ x, family = binomial("probit"), id = id, data = simulated_binary_responses$simdata) summary(binary_gee_model)$coefficients
Additional examples can be found in @Touloumis2016 and in the vignette of SimCorMultRes
. To access these two documents, run the following command:
browseVignettes("SimCorMultRes")
citation("SimCorMultRes")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.