wilcoxtestClust {htestClust} | R Documentation |
Rank Sum and Signed Rank Tests for Clustered Data
Description
Performs a one-sample or paired cluster-weighted signed rank test, or a cluster- or group-weighted rank sum test. These tests are appropriate for clustered data with potentially informative cluster size.
Usage
wilcoxtestClust(x, ...)
## Default S3 method:
wilcoxtestClust(
x,
y = NULL,
idx,
idy = NULL,
alternative = c("two.sided", "less", "greater"),
mu = 0,
paired = FALSE,
method = c("cluster", "group"),
...
)
## S3 method for class 'formula'
wilcoxtestClust(formula, id, data, subset, na.action, ...)
Arguments
x , y |
numeric vectors of data values. |
... |
further arguments to be passed to or from methods. |
idx |
vector or factor object denoting cluster membership for |
idy |
vector or factor object denoting cluster membership for |
alternative |
indicates the alternative hypothesis and must be one of " |
mu |
a number specifying an optional parameter used to form the null hypothesis. Ignored when performing a rank-sum test. See 'Details'. |
paired |
a logical indicating whether |
method |
a character string specifying the method of rank sum test to be performed. See 'Details'. |
formula |
a formula of the form |
id |
a vector or factor object denoting cluster membership. |
data |
an optional matrix or data frame containing variables in the 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 |
Details
The formula interface is only applicable for the 2-sample rank-sum tests.
If only x
and idx
are given, a cluster-weighted signed rank test of the null that
the distribution of x
is symmetric about mu
is performed.
If x
and y
are given and paired
is TRUE
, only idx
is necessary (idy
is ignored). In this case, a cluster-weighted signed-rank test of the null that the distribution of x - y
is symmetric about mu
is performed.
When method
is cluster
, the cluster-weighted rank sum test of Datta and Satten (2005) is performed.
The data must have complete intra-cluster group distribution (i.e., all clusters must contain observations
belonging to both groups) for this test to be performed.
When method
is group
, the group-weighted rank-sum test of Dutta and Datta (2015) is performed.
This test is appropriate for clustered data with potentially informative intra-cluster group size. Incomplete
intra-cluster group distribution is permitted.
For the rank sum tests, the null is that the two groups follow the same marginal distribution. mu
is
ignored when performing these tests.
The tests performed by this function involve computation of reweighted empirical CDFs. This is computationally intensive and can result in lengthy execution time for large data sets.
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. |
null.value |
the location parameter |
data.name |
a character string giving the name(s) of the data and the total number of clusters. |
method |
a character string indicating the test performed and method of construction. |
alternative |
a character string describing the alternative hypothesis. |
M |
the number of clusters. |
References
Datta, S., Satten, G. (2005) Rank-sum tests for clustered data. J. Am. Stat. Assoc., 100, 908–915.
Datta, S., Satten, G. (2008) A signed-rank test for clustered data. Biometrics, 64, 501–507.
Dutta, S., Datta, S. (2015) A rank-sum test for clustered data when the number of subjects in a group within a cluster is informative. Biometrics, 72, 432–440.
Examples
data(screen8)
## One-sample signed rank test
wilcoxtestClust(x=screen8$math, idx=screen8$sch.id, mu=70)
## Paired signed rank test
wilcoxtestClust(x=screen8$math, y=screen8$read, idx=screen8$sch.id, paired=TRUE, mu=10)
## Cluster-weighted rank sum test
wilcoxtestClust(math~gender, id=sch.id, data=screen8)
## Group-weighted rank sum test
boys <- subset(screen8, gender=='M')
girls <- subset(screen8, gender=='F')
wilcoxtestClust(x=boys$math, y=girls$math, idx=boys$sch.id, idy=girls$sch.id, method="group")
## Group-weighted rank sum test using formula method
wilcoxtestClust(math~gender, id=sch.id, data=screen8, method="group")