dda.indep: Direction Dependence Analysis: Independence Properties

View source: R/dda_indep.r

dda.indepR Documentation

Direction Dependence Analysis: Independence Properties

Description

dda.indep computes DDA test statistics to evaluate asymmetries of predictor-error independence of causally competing models (y ~ x vs. x ~ y).

print returns DDA test statistics associated with dda.indep objects.

Usage

dda.indep(
  formula,
  pred = NULL,
  data = list(),
  nlfun = NULL,
  hetero = FALSE,
  hsic.method = "gamma",
  diff = FALSE,
  B = 200,
  boot.type = "perc",
  conf.level = 0.95,
  parallelize = FALSE,
  cores = 1
)

## S3 method for class 'dda.indep'
print(x, ...)

Arguments

formula

Symbolic formula of the model to be tested or a lm object.

pred

A character indicating the variable name of the predictor which serves as the outcome in the alternative model.

data

An optional data frame containing the variables in the model (by default variables are taken from the environment which dda.indep is called from).

nlfun

Either a numeric value or a function of .Primitive type used for non-linear correlation tests. When nlfun is numeric the value is used in a power transformation.

hetero

A logical value indicating whether separate homoscedasticity tests (i.e., standard and robust Breusch-Pagan tests) should be computed.

hsic.method

A character indicating the inference method for the Hilbert-Schmidt Independence Criterion (HSIC). Must be one of the four specifications c("gamma", "eigenvalue", "boot", "permutation"). hsic.method = "gamma"is the default.

diff

A logical value indicating whether differences in HSIC, Distance Correlation (dCor), and MI values should be computed. Bootstrap confidence intervals are computed using B bootstrap samples.

B

Number of permutations for separate dCor tests and number of resamples if hsic.method = c("boot", "permutation") or diff = TRUE.

boot.type

A vector of character strings representing the type of bootstrap confidence intervals. Must be one of the two specifications c("perc", "bca").boot.type = "perc" is the default.

conf.level

Confidence level for bootstrap confidence intervals.

parallelize

A logical value indicating whether bootstrapping is performed on multiple cores. Only used if diff = TRUE.

cores

A numeric value indicating the number of cores. Only used if parallelize = TRUE.

x

An object of class dda.indep when using print.

...

Additional arguments to be passed to the function.

Value

An object of class dda.indep containing the results of DDA independence tests.

References

Wiedermann, W., & von Eye, A. (2025). Direction Dependence Analysis: Foundations and Statistical Methods. Cambridge, UK: Cambridge University Press.

See Also

cdda.indep for a conditional version.

Examples


set.seed(123)
n <- 500
x <- rchisq(n, df = 4) - 4
e <- rchisq(n, df = 3) - 3
y <- 0.5 * x + e
d <- data.frame(x, y)

result <- dda.indep(y ~ x, pred = "x", data = d, parallelize = TRUE, cores = 2,
          nlfun = 2, B = 50, hetero = TRUE, diff = TRUE)


print(result)


dda documentation built on April 4, 2025, 12:18 a.m.