Learn R Programming

dslice (version 1.2.2)

bfslice_c: Dependency and conditional dependency detection between a level \(k\) (\(k > 1\)) categorical variable and a continuous variable via Bayes factor.

Description

Conditional dependency detection between a level \(k_x\) (\(k_x > 1\)) categorical variable x and a continuous variable y via Bayes factor given a level \(k_z\) categorical variable z. If \(k_z = 1\), it is unconditional dependency detection method. It could be applied for non-parametric variable selecltion.

Usage

bfslice_c(z, x, zdim, xdim, lambda, alpha)

Value

Value of Bayes factor (nonnegative). Bayes factor could be treated as a statistic and one can take some threshold then calculates the corresponded Type I error rate. One can also take the value of Bayes factor for judgement.

Arguments

z

Vector: observations of given (preselected) categorical variable, \(0,1,\ldots,k_z-1\) for level \(k_z\) categorical variable, should be ranked according to values of continuous variable y with x in advanced, either ascending or descending.

x

Vector: observations of categorical variable, \(0,1,\ldots,k_x-1\) for level \(k_x\) categorical variable, should be ranked according to values of continuous variable y with z in advanced, either ascending or descending.

zdim

Level of z, equals \(k_z\).

xdim

Level of x, equals \(k_x\).

lambda

lambda corresponds to the probability that makes slice in each possible position. lambda should be greater than 0.

alpha

alpha is hyper-parameter of the prior distribution of frequency in each slice. alpha should be greater than 0 and less equal than \(k_x\).

References

Jiang, B., Ye, C. and Liu, J.S. Bayesian nonparametric tests via sliced inverse modeling. Bayesian Analysis, 12(1): 89-112, 2017.

See Also

bfslice_u, bfslice_eqp_c.

Examples

Run this code
n <- 100
mu <- 0.5

## Unconditional test
y <- c(rnorm(n, -mu, 1), rnorm(n, mu, 1))
x <- c(rep(0, n), rep(1, n))
z <- rep(0, 2*n)

## Conditional test
y <- c(rnorm(n, -mu, 1), rnorm(n, mu, 1))
x <- c(rep(0, n/5), rep(1, n), rep(0, 4*n/5))
z <- c(rep(0, n), rep(1, n))
z <- z[order(y)]

x <- x[order(y)]
zdim <- max(z) + 1
xdim <- max(x) + 1
lambda <- 1.0
alpha <- 1.0
bfval <- bfslice_c(z, x, zdim, xdim, lambda, alpha)

Run the code above in your browser using DataLab