MyNixOS website logo
Description

Constructing Joint Distributions with Control Over Statistical Properties.

Synthesizing joint distributions from marginal densities, focusing on controlling key statistical properties such as correlation for continuous data, mutual information for categorical data, and inducing Simpson's Paradox. Generate datasets with specified correlation structures for continuous variables, adjust mutual information between categorical variables, and manipulate subgroup correlations to intentionally create Simpson's Paradox. Joe (1997) <doi:10.1201/b13150> Sklar (1959) <https://en.wikipedia.org/wiki/Sklar%27s_theorem>.

covalchemy

This package provides functions for manipulating data, including techniques for:

  • Modifying correlations for continuous variables: The get_target_corr function allows you to adjust the Kendall's tau correlation between two continuous variables using copula-based methods. You can specify the target correlation, copula type (Gaussian or t), and inverse CDF transformation method.
  • Controlling entropy in categorical variables: The get_target_entropy function helps you achieve a desired level of entropy (mutual information) between two categorical variables. It works by iteratively adjusting the contingency table using simulated annealing.
  • Simulating Simpson's Paradox with continuous variables: The get_simpsons_paradox_c function allows you to explore the Simpson's Paradox phenomenon in continuous data. It transforms data using Gaussian copulas and simulated annealing to create a scenario where the overall trend contradicts subgroup trends.
  • Simulating Simpson's Paradox-like effects in categorical data: The get_simpsons_paradox_d function enables you to modify contingency tables for categorical data to create or highlight a Simpson's Paradox-like effect. It employs simulated annealing to adjust log-odds values while respecting specific constraints.

Installation

To install the package, you can use the devtools package:

# Install devtools package if not already available
if (!requireNamespace("devtools")) install.packages("devtools")
devtools::install_github("namanlab/covalchemy")  

Once installed, you can load the package and use its functions in your R scripts:

library(covalchemy)

# Example 1: Modifying correlation
x <- rnorm(100)
y <- rnorm(100)
target_corr <- 0.5
res <- get_target_corr(x, y, target_corr)
modified_x <- res$x1
modified_y <- res$x2

# Example 2: Controlling entropy
df <- data.frame(x = sample(c("A", "B", "C"), 1000, replace = TRUE),
                  y = sample(c("D", "E", "F"), 1000, replace = TRUE))
target_entropy <- 1.5
result <- get_target_entropy(df$x, df$y, target_entropy)
final_df <- result$final_df

Additional notes

This readme provides a general overview of the package's functionalities. Refer to the function documentation within the package for detailed information on arguments, return values, and specific usage examples.

Acknowledgments

This package was developed as part of the DSA42288S Final Year Project. I would like to express my gratitude to my supervisor, Dr. Vikneswaran Gopal, for his invaluable guidance, support, and mentorship throughout this project. I am also grateful to the faculty and staff at NUS for their continuous support, and to my family for their encouragement along the way.

Contact

For any questions or inquiries, please contact me at [email protected].

Metadata

Version

1.0.0

License

Unknown

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows