Learn R Programming

bnlearn (version 1.1)

ci.test: Independence and Conditional Independence Tests

Description

Perform an independence or a conditional independence test.

Usage

## S3 method for class 'character':
ci.test(x, y = NULL, z = NULL, data, test = NULL,
    debug = FALSE, ...)
  ## S3 method for class 'data.frame':
ci.test(x, test = NULL, debug = FALSE, ...)
  ## S3 method for class 'numeric':
ci.test(x, y = NULL, z = NULL, test = NULL,
    debug = FALSE, ...)
  ## S3 method for class 'factor':
ci.test(x, y = NULL, z = NULL, test = NULL,
    debug = FALSE, ...)
  ## S3 method for class 'default':
ci.test(x, ...)

Arguments

x
a character string (the name of a variable), a data frame, a numeric vector or a factor object.
y
a character string (the name of another variable), a numeric vector or a factor object.
z
a vector of character strings (the names of the conditioning variables), a numeric vector, a factor object or a data frame. If NULL an independence test will be executed.
data
a data frame, containing the variables to be tested.
test
a character string, the label of the conditional independence test to be used in the algorithm. Possible values are mi (mutual information for discrete data), fmi (fast mutual information),
debug
a boolean value. If TRUE a lot of debugging output is printed; otherwise the function is completely silent.
...
extra arguments from the generic method (currently ignored).

Value

  • An object of class htest containing the following components:
  • statisticthe value the conditional independence test statistic.
  • parameterthe degrees of freedom of the approximate chi-squared or t distribution of the test statistic, NA if the p-value is computed by Monte Carlo simulation.
  • p.valuethe p-value for the test.
  • methoda character string indicating the type of test performed, and whether Monte Carlo simulation or continuity correction was used.
  • data.namea character string giving the name(s) of the data.
  • null.valuethe value of the test statistic under the null hypothesis, always 0.
  • alternativea character string describing the alternative hypothesis

See Also

choose.direction, arc.strength.

Examples

Run this code
data(gaussian.test)
data(learning.test)

# using a data frame and column labels.
ci.test(x = "F" , y = "B", z = c("C", "D"), data = gaussian.test)
#
#	 linear correlation
#
# data:  F ~ B | C + D
# cor = -0.1275, df = 4996, p-value < 2.2e-16
# alternative hypothesis: true value is not equal to 0

# using a data frame.
ci.test(gaussian.test)
#
#	 linear correlation
#
# data:  A ~ B | C + D + E + F + G
# cor = -0.5654, df = 4993, p-value < 2.2e-16
# alternative hypothesis: true value is not equal to 0

# using factor objects.
ci.test(x = learning.test[, "F"] , y = learning.test[, "B"],
  z = learning.test[, c("C", "D")] )
#
#	 mutual information
#
# data:  learning.test[, "F"] ~ learning.test[, "B"] | learning.test[, c("C", "D")]
# mi = 25.2664, df = 18, p-value = 0.1178
# alternative hypothesis: true value is greater than 0

Run the code above in your browser using DataLab