Title: | Generation of Bivariate Uniform Data and Its Relation to Bivariate Binary Data |
---|---|
Description: | Simulation of bivariate uniform data with a full range of correlations based on two beta densities and computation of the tetrachoric correlation (correlation of bivariate uniform data) from the phi coefficient (correlation of bivariate binary data) and vice versa. |
Authors: | Hakan Demirtas, Rawan Allozi, Ran Gao |
Maintainer: | Ran Gao <[email protected]> |
License: | GPL-2 | GPL-3 |
Version: | 1.3.3 |
Built: | 2025-02-10 03:28:19 UTC |
Source: | https://github.com/cran/BivUnifBin |
This package implements the algorithms described in Demirtas (2014) for generation of bivariate uniform data with coverage on the whole feasible correlation range and its relationship to bivariate binary data. Two functions for simulation of bivariate uniform data are provided: genbivunif.a
simulates bivariate uniform data via g(u)~Beta(a,1) and a specified correlation (the tetrachoric correlation, which is referred to as rho), and genbivunif.t
simulates bivariate uniform data via g(u)~Beta(1-t,1+t) and a specified correlation rho.
The computations based on the relationship between bivariate uniform data and binary data are implemented in rho2delta
and delta2rho
. In rho2delta
, bivariate uniform data are simulated given a sample size and correlation rho. The data are then dichotomized based on the given expected values for binary data, and an empirical and algorithmic correlation of the binary data (the phi coefficient, which is referred to as delta) are provided. In delta2rho
, algorithmic rho is calculated given a specified delta. Bivariate uniform data are simulated based on the calculated algorithmic rho. The uniform data are dichotomized based on the given expected values for binary data, and an empirical and algorithmic correlation of the binary data are provided. Before any computations, the specified delta is compared to the lower and upper correlation bounds for the two binary variables using the generate, sort and correlate (GSC) algorithm in Demirtas and Hedeker (2011).
Package: | BivUnifBin |
Type: | Package |
Version: | 1.3.3 |
Date: | 2021-03-05 |
License: | GPL-2 | GPL-3 |
Hakan Demirtas, Rawan Allozi, Ran Gao
Maintainer: Ran Gao <[email protected]>
Demirtas, H. and Hedeker, D. (2011). A practical way for computing approximate lower and upper correlation bounds. The American Statistician, 65(2), 104-109.
Demirtas, H. (2014). Generating bivariate uniform data with a full range of correlations and connections to bivariate binary data. Communications in Statistics-Theory and Methods, 43(17), 3574-3579.
This function calculates algorithmic rho given delta, simulates bivariate uniform data with the calculated rho using genbivunif.a
, dichotomizes the data based on p1 and p2 to generate bivariate binary data, and calculates the algorithmic and empirical correlation (delta) of the bivariate binary data as described in Demirtas (2014).
delta2rho(N=10000, p1, p2, delta, print.cor=TRUE)
delta2rho(N=10000, p1, p2, delta, print.cor=TRUE)
N |
The sample size for the data to be simulated. Default is 10,000. |
p1 |
The expected value of the first binary variable w1. |
p2 |
The expected value of the second binary variable w2. |
delta |
Theoretical correlation for the bivariate binary data to be simulated. |
print.cor |
Option to print correlation results. Default is TRUE. |
A list of length 5 containing simulated bivariate uniform data, binary data derived from dichotomizing the uniform data, correlation of the binary data specified by the user, empirical correlation of the binary data, and algorithmic correlation of the uniform data, titled unif.dat, bin.dat, specified.delta, empirical.delta, and algorithmic.rho, respectively.
set.seed(147) res.d2r<-delta2rho(N=10000, p1=0.4, p2=0.7, delta=0.5) #"Specified delta is 0.5, empirical delta is 0.488197, and algorithmic rho is 0.909093."
set.seed(147) res.d2r<-delta2rho(N=10000, p1=0.4, p2=0.7, delta=0.5) #"Specified delta is 0.5, empirical delta is 0.488197, and algorithmic rho is 0.909093."
This function simulates bivariate uniform data via Beta(a,1) and a specified correlation (rho) as described in Demirtas (2014).
genbivunif.a(N=10000, rho, print.cor=TRUE)
genbivunif.a(N=10000, rho, print.cor=TRUE)
N |
The sample size for the bivariate uniform data to be simulated. Default is 10,000. |
rho |
Theoretical correlation for the uniform data to be simulated. |
print.cor |
Option to print correlation results. Default is TRUE. |
A list of length 3 containing the simulated bivariate uniform data, the theoretical correlation specified by the user, and the empirical correlation of the simulated data titled unif.dat, specified.rho, and empirical.rho, respectively.
set.seed(98732) res.gena<-genbivunif.a(N=10000, rho=0.9) #"Specified rho is 0.9 and empirical rho is 0.898361."
set.seed(98732) res.gena<-genbivunif.a(N=10000, rho=0.9) #"Specified rho is 0.9 and empirical rho is 0.898361."
This function simulates bivariate uniform data via Beta(1-t,1+t) and a specified correlation (rho) as described in Demirtas (2014).
genbivunif.t(N=10000, rho, print.cor=TRUE)
genbivunif.t(N=10000, rho, print.cor=TRUE)
N |
The sample size for the bivariate uniform data to be simulated. Default is 10,000. |
rho |
Theoretical correlation for the uniform data to be simulated. |
print.cor |
Option to print correlation results. Default is TRUE. |
A list of length 3 containing the simulated bivariate uniform data, the theoretical correlation specified by the user, and the empirical correlation of the simulated data titled unif.dat, specified.rho, and empirical.rho, respectively.
set.seed(567) res.gent<-genbivunif.t(N=10000, rho=0.9) #"Specified rho is 0.9 and empirical rho is 0.897883."
set.seed(567) res.gent<-genbivunif.t(N=10000, rho=0.9) #"Specified rho is 0.9 and empirical rho is 0.897883."
This function simulates bivariate uniform data with the given correlation (rho) using genbivunif.a
, dichotomizes the data based on p1 and p2 to generate bivariate binary data, and calculates the algorithmic and empirical correlation (delta) of the bivariate binary data as described in Demirtas (2014).
rho2delta(N=10000, p1, p2, rho, print.cor=TRUE)
rho2delta(N=10000, p1, p2, rho, print.cor=TRUE)
N |
The sample size for the data to be simulated. Default is 10,000. |
p1 |
The expected value of the first variable w1 to be dichotomized. |
p2 |
The expected value of the second variable w2 to be dichotomized. |
rho |
Theoretical correlation for the bivariate uniform data to be simulated. |
print.cor |
Option to print correlation results. Default is TRUE. |
A list of length 5 containing simulated bivariate uniform data, binary data derived from dichotomizing the uniform data, theoretical correlation specified by the user, algorithmic correlation of the binary data, and the empirical correlation of the binary data, titled unif.dat, bin.dat, specified.rho, algorithmic.delta, and empirical.delta, respectively.
set.seed(234) res.r2d<-rho2delta(N=10000, p1=0.4, p2=0.7, rho=0.7) #"Algorithmic delta is 0.393887 and empirical delta is 0.395547."
set.seed(234) res.r2d<-rho2delta(N=10000, p1=0.4, p2=0.7, rho=0.7) #"Algorithmic delta is 0.393887 and empirical delta is 0.395547."