localDepTest: Tests for conditional independence between two variables...

localDepTestR Documentation

Tests for conditional independence between two variables given a third

Description

The function ciTest takes a 3-way contingency table and tests for the conditional independence of the first two variables given the third. The function localDepTest is a wrapper which builds the table from factor variables. In psychometrics, when the third variable represents a latent proficiency and the first two item responses, this is sometimes called local independence.

Usage

localDepTest(obs1, obs2, prof)
ciTest(tab)

Arguments

obs1

A factor variable representing the first observable outcome.

obs2

A factor variable representing the second observable outcome.

prof

A factor variable representing the proficiency level, or any variable that is thought to render obs1 and obs2 independent.

tab

A three-way table (see table) where the first two dimensions represent the observable variables and the third the proficiency variable.

Details

Let 1 and 2 represent obs1 and obs2 respectively and let 3 represent prof. In the case of ciTest, 1, 2 and 3 represent the first second and 3rd dimensions of tab. These function then compare the undirected model [13][23] (1 and 2 are conditionally independent given 3) to the unrestricted model [123]. The result is a chi-square statistic comparing the two models, high values of the chi-square statistic indicate a better fit of the unrestricted model compared to the conditional independence model.

Note that the Cochran-Mantel-Haenszel statistic (see mantelhaen.test) is similar, but it assumes that there is no three-way interaction, so it essentially tests [13][23] versus [12][13][23].

Value

A list with three elements:

G2

The chi-square comparison between the two models.

df

The degrees of freedom for the test.

p

The percentage point for G2 in a central chi-square distribution with df degrees of freedom, i.e., the p-value.

Author(s)

Russell Almond

References

Bishop, Feinberg and Holland (1975). Discrete Multivariate Analysis: Theory and Practice. MIT Press.

See Also

buildFactorTab, mantelhaen.test, UCBAdmissions

Examples


data(UCBAdmissions)
ciTest(UCBAdmissions)

data(ACED)
ACED.items$Correct <- rowSums(ACED.items[,-(1:3)],na.rm=TRUE)
table(ACED.items$tCommonRatio1a,ACED.items$tCommonRatio2a,
      cut(ACED.items$Correct,3))
localDepTest(ACED.items$tCommonRatio1a,ACED.items$tCommonRatio2a,
      cut(ACED.items$Correct,3))



ralmond/CPTtools documentation built on Dec. 27, 2024, 7:15 a.m.