Learn R Programming

miscor (version 0.1-0)

sim.cor: Simulate bivariate distribution with a specified correlation

Description

This function simulates bivariate distribution with correaltion equal to rho, mean equal to mean, standard deviation equal to sd, skewness equal to skewness, and kurtosis equal to kurtosis by Fleishman polynomials.

Usage

sim.cor(n, rho, mean = c(0, 0), sd = c(1, 1), skewness = c(0, 0), kurtosis = c(0, 0))

Arguments

n
number of observations.
rho
correlation.
mean
mean vector.
sd
standard deviation vector.
skewness
skewness vector.
kurtosis
kurtosis vector.

Value

Returns a data.frame with variables x and y.

References

Rasch, D., Kubinger, K. D., & Yanagida, T. (2011). Statistics in psychology - Using R and SPSS. New York: John Wiley & Sons.

See Also

test.cor, seqtest.cor, comptest.cor,

Examples

Run this code
#------------------------------------------------
# Bivariate  distribution with rho = 0.3, n = 200
# x: skewness = 0, kurtosis = 0
# y: skewness = 0, kurtosis = 0

sim.cor(200, rho = 0.3)

#-----------------------------------------------
# Bivariate distribution with rho = 0.4, n = 500
# x: skewness = 0, kurtosis = 1.5
# y: skewness = 2, kurtosis = 7

sim.cor(500, rho = 0.4, skewness = c(0, 1.5), kurtosis = c(2, 7))

Run the code above in your browser using DataLab