onewaytestClust {htestClust} | R Documentation |
Test for Equal Marginal Means in Clustered Data
Description
Test whether two or more intra-cluster groups have the same marginal means in clustered data. Reweighted to correct for potential cluster- or group size informativeness.
Usage
onewaytestClust(x, ...)
## Default S3 method:
onewaytestClust(x, ...)
## S3 method for class 'formula'
onewaytestClust(formula, id, data, subset, ...)
Arguments
x |
a two-dimensional matrix or data frame containing the within-cluster group means, where rows are the clusters and columns are the group means. |
... |
further arguments to be passed to or from methods. |
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. |
Details
The null hypothesis is that all levels of group
have equal marginal means.
If x
is a matrix or data frame, the dimension of x
should be MxK, where M is the
number of clusters and K is the number of groups. Each row of x
corresponds to a cluster, where
the column values contain the respective group means from that cluster. Clusters which do not contain
observations in a particular group should have NA
in the corresponding column.
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 marginal group means. |
parameter |
the degrees of freedom of the chi square distribution. |
method |
a character string indicating the test performed. |
data.name |
a character string giving the name of the data and the total number of clusters. |
M |
the number of clusters. |
References
Gregg, M., Marginal methods and software for clustered data with cluster- and group-size informativeness. PhD dissertation, University of Louisville, 2020.
Examples
data(screen8)
## do average reading scores differ across after-school activities?
## test using a table
read.tab <- tapply(screen8$read, list(screen8$sch.id, screen8$activity), mean)
onewaytestClust(read.tab)
## test using formula method
onewaytestClust(read~activity, id=sch.id, data=screen8)