knitr::opts_chunk$set(
  tidy = TRUE,
  tidy.opts = list(width.cutoff = 80),
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)

SimCorMultRes: Simulates Correlated Multinomial Responses

Github version R-CMD-check Project Status: Active The project has reached a stable, usable state and is being actively developed. Codecov test coverage

CRAN Version CRAN Downloads CRAN Downloads

Installation

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

Usage and functions

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:

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:

Example

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

How to cite

citation("SimCorMultRes")

References



AnestisTouloumis/SimCorMultRes documentation built on March 19, 2024, 9:55 p.m.