Learn R Programming

MRCV (version 0.1-0)

SPMI.test: Test for Marginal Independence Between Two MRCVs

Description

The SPMI.test function offers three approaches for testing for simultaneous pairwise marginal independence (SPMI) between two MRCVs.

Usage

SPMI.test(data, I, J, type = "all", B = 1999, B.max = B, summary.data = FALSE, 
    add.constant = 0.5, plot.hist = FALSE, print.status = TRUE)

SPMI.stat(data, I, J, summary.data = FALSE, add.constant = 0.5)

Arguments

data
For summary.data = FALSE: a data frame containing the raw data where rows correspond to the individual item response vectors, and columns correspond to the binary items, W1, ..., WI and Y1, ..., YJ (in this order). For summary.data =
I
The number of items corresponding to row variable W.
J
The number of items corresponding to column variable Y.
type
A character string specifying one of the following approaches for testing for SPMI: "boot" specifies a nonparametric bootstrap procedure; "rs2" specifies a Rao-Scott second-order adjustment; "bon" specifies a Bonferr
B
The desired number of bootstrap resamples.
B.max
The maximum number of bootstrap resamples. Resamples for which at least one item has all positive or negative responses are thrown out; SPMI.test uses the first B valid resamples or all valid resamples if that number is less tha
summary.data
A logical value indicating whether data is a summary file containing the item response data instead of the raw data. Only type = "bon" is available for summary.data = TRUE.
add.constant
A positive constant to be added to all zero marginal cell counts.
plot.hist
A logical value indicating whether plots of the emprical bootstrap sampling distributions should be provided.
print.status
A logical value indicating whether bootstrap progress updates should be provided.

Value

  • --- For SPMI.test, a list containing at least general, a list containing the following objects:
    • data:
    {The original data frame supplied to the data argument.}
  • I:
  • {The original value supplied to the I argument.}
  • J:
  • {The original value supplied to the J argument.}
  • summary.data:
  • {The original value supplied to the summary.data argument.}
  • X.sq.S:
  • {The modified Pearson statistic; NA if not all Wi and Yj have at least one positive and one negative response.}
  • X.sq.S.ij:
  • {A matrix containing the IxJ Pearson statistics.}

code

SPMI.stat

itemize

  • X.sq.S:

item

  • B.discard:
  • p.value.boot:
  • p.combo.min.boot:
  • p.combo.prod.boot:
  • X.sq.S.star:
  • X.sq.S.ij.star:
  • p.combo.min.star:
  • p.combo.prod.star:
  • df.rs2:
  • p.value.rs2:
  • X.sq.S.ij.p.bon:
  • X.sq.S.ij:
  • valid.margins:

Details

The SPMI.test function calls SPMI.stat, which in turn calculates a modified Pearson statistic defined in Bilder and Loughin (2004). The modified statistic is the sum of the IxJ Pearson statistics used to test for independence of each (Wi,Yj) pair. The asymptotic distribution of the modified statistic is a linear combination of independent chi-square(1) random variables, so traditional methods for analyzing the association between categorical variables W and Y are inappropriate. For this reason, the SPMI.stat function is not normally called directly. The SPMI.test function offers three testing methods. The nonparametric bootstrap method empirically estimates the sampling distribution of the modified statistic. Resampling under the null hypothesis is done by independently sampling the W and Y vectors with replacement for s = 1, ..., n where n is the sample size. In addition to bootstrapping the Pearson statistic, bootstrap p-value combination methods are available in which the minimum or the product of the IxJ p-values (each using a chi-square(1) approximation for the corresponding Pearson statistic) is calculated for each resample. The Rao-Scott approach applies a second-order adjustment to the modified Pearson statistic and its sampling distribution. Formulas are provided in Appendix A of Bilder and Loughin (2004). Using the Bonferroni adjustment, SPMI is rejected if at least one of the IxJ p-values is less than alpha/(IxJ). The SPMI.test function provides the adjusted p-values so SPMI is rejected if at least one of the p-values is less than alpha. An overall Bonferroni adjusted p-value is given as the minimum of the IxJ p-values multiplied by IxJ, where SPMI is rejected if this value is less than alpha. Note that the Bonferroni adjustment tends to produce an overly conservative test when I and J are large.

References

Bilder, C. and Loughin, T. (2004) Testing for marginal independence between two categorical variables with multiple responses. Biometrics, 36, 433--451.

See Also

The genloglin function offers a generalized loglinear modeling approach for testing the relationship among two or three MRCVs.

Examples

Run this code
# Test for SPMI using the second-order Rao-Scott adjustment
test.stat.rs2 <- SPMI.test(data = farmer2, I = 3, J = 4, type = "rs2")
test.stat.rs2

# Test for SPMI using all three approaches
# A small B is used for demonstration purposes; normally, a larger B should be used
test.stat.all <- SPMI.test(data = farmer2, I = 3, J = 4, type = "all", B = 99, 
    plot.hist = TRUE)
test.stat.all

# Use SPMI.test() with summary data
# Convert raw data file to summary file for this example 
farmer.irdframe <- item.response.table(data = farmer2, I = 3, J = 4, create.dataframe = 
    TRUE)

# Test for SPMI using the Bonferroni adjustment
test.stat.bon <- SPMI.test(data = farmer.irdframe, I = 3, J = 4, type = "bon", 
    summary.data = TRUE)
test.stat.bon

Run the code above in your browser using DataLab