Learn R Programming

simsem (version 0.4-6)

bindDist: Create a data distribution object.

Description

Create a data distribution object

Usage

bindDist(margins, ..., p = NULL, keepScale = TRUE, reverse = FALSE, copula = NULL)

Arguments

margins
A character vector specifying all the marginal distributions. The characters in argument margins are used to construct density, distribution, and quantile function names. For example, "norm" can be used to specify marginal distribution, becau
...
A list whose each component is a list of named components, giving the parameter values of the marginal distributions. See the description of paramMargins attribute of the Mvdc function for f
p
Number of variables. If only one distribution object is listed, the p will make the same distribution objects for all variables.
keepScale
A vector representing whether each variable is transformed its mean and standard deviation or not. If TRUE, transform back to retain the mean and standard deviation of a variable equal to the model implied mean and standard deviation (with sampling error)
reverse
A vector representing whether each variable is mirrored or not. If TRUE, reverse the distribution of a variable (e.g., from positive skewed to negative skewed. If one logical value is specified, it will apply to all variables.
copula
A copula class that represents the multivariate distribution, such as ellipCopula, normalCopula, or

Value

  • SimDataDist that saves analysis result from simulate data.

References

Mair, P., Satorra, A., & Bentler, P. M. (2012). Generating nonnormal multivariate data using copulas: Applications to SEM. Multivariate Behavioral Research, 47, 547-565.

See Also

  • SimResultfor the type of resulting object

Examples

Run this code
library(copula)

# Create three-dimensional distribution by gaussian copula with 
# the following marginal distributions
#   1. t-distribution with df = 2
# 	2. chi-square distribution with df = 3
#	3. normal distribution with mean = 0 and sd = 1

# Setting the attribute of each marginal distribution
d1 <- list(df=2)
d2 <- list(df=3)
d3 <- list(mean=0, sd=1)

# Create a data distribution object by setting the names of each distribution
# and their arguments
dist <- bindDist(c("t", "chisq", "norm"), d1, d2, d3)

# Create data by using Gumbel Copula as the multivariate distribution
dist <- bindDist(c("t", "chisq", "norm"), d1, d2, d3, copula = gumbelCopula(2, dim = 3))

# Reverse the direction of chi-square distribution from positively skew to negatively skew
dist <- bindDist(c("t", "chisq", "norm"), d1, d2, d3, copula = gumbelCopula(2, dim = 3),
	reverse = c(FALSE, TRUE, FALSE))

Run the code above in your browser using DataLab