cortestClust: Test for Marginal Association Between Paired Clustered Data

View source: R/cortestClust.R

cortestClustR Documentation

Test for Marginal Association Between Paired Clustered Data

Description

Test for marginal association between paired samples in clustered data with potentially informative cluster size.

Usage

cortestClust(x, ...)

## Default S3 method:
cortestClust(
  x,
  y,
  id,
  method = c("pearson", "kendall", "spearman"),
  alternative = c("two.sided", "less", "greater"),
  conf.level = 0.95,
  ...
)

## S3 method for class 'formula'
cortestClust(formula, id, data, subset, na.action, ...)

Arguments

x, y

numeric vectors of data values.

...

further arguments to be passed to or from methods.

id

a vector or factor object which identifies the clusters. The length of id should be the same as the number of observations.

method

a character string indicating which correlation coefficient is to be used for the test. One of "pearson", "kendall", or "spearman". Can be abbreviated.

alternative

indicates the alternative hypothesis and must be one of "two.sided", "greater", or "less".You can specify just the initial letter. "greater" corresponds to positive association, "less" to negative association.

conf.level

confidence level for the returned confidence interval.

formula

a formula of the form ~ u + v, where each of u and v are numeric variables giving the data values for one sample. The samples must be of the sample length.

data

an optional matrix or data frame containing variables in the formula formula. By default the variables are taken from environment(formula).

subset

an optional vector specifying a subset of observations to be used.

na.action

a function which indicates what should happen when data contain NAs. Defaults to getOption("na.action").

Details

The three methods each estimate the marginal association between paired observations from clustered data and compute a test of the value being zero.

If method is "pearson" ("kendall"), the test statistic is based on the Pearson product-moment (Kendall concordance coefficient) analog of Lorenz et al. (2011).

If method is "spearman", the test statistic is based on the Spearman coefficient analog of Lorenz et al. (2018) modified for paired data.

Value

A list with class "htest" containing the following components:

statistic

the value of the test statistic.

p.value

the p-value of the test.

estimate

the estimated measure of marginal association, with name "cluster-weighted cor", "cluster-weighted tau", or "cluster-weighted rho" corresponding to the method employed.

null.value

the value of the association measure under the null hypothesis, always 0.

conf.int

a confidence interval for the measure of association.

alternative

a character string describing the alternative hypothesis.

method

a character string indicating how the association was measured.

data.name

a character string giving the name(s) of the data and the total number of clusters.

M

the number of clusters.

References

Lorenz, D., Datta, S., Harkema, S. (2011) Marginal association measures for clustered data. Statistics in Medicine, 30, 3181–3191.

Lorenz, D., Levy, S., Datta, S. (2018) Inferring marginal association with paired and unpaired clustered data. Stat. Methods Med. Res., 27, 1806–1817.

Examples

data(screen8)
## test if math and reading scores are marginally correlated using vectors
cortestClust(screen8$read, screen8$math, screen8$sch.id)

## formula interface
cortestClust(~ math + read, sch.id, data=screen8, method="kendall")


htestClust documentation built on May 18, 2022, 9:05 a.m.