ttestClust | R Documentation |
Performs one and two sample tests of marginal means in clustered data, reweighted to correct for potential cluster- or group-size informativeness.
ttestClust(x, ...) ## Default S3 method: ttestClust( x, y = NULL, idx, idy = NULL, alternative = c("two.sided", "less", "greater"), mu = 0, paired = FALSE, conf.level = 0.95, ... ) ## S3 method for class 'formula' ttestClust(formula, id, data, subset, na.action, ...)
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. |
paired |
a logical indicating whether |
conf.level |
confidence level of the interval. |
formula |
a formula of the form |
id |
a vector or factor giving the corresponding 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 |
The formula interface is only applicable for the 2-sample tests.
If paired
is TRUE
then x
, y
, and idx
must be given and be of the same length.
idy
is ignored.
A list with class "htest
" containing the following components:
statistic |
the value of the test statistic. |
p.value |
the p-value of the test. |
conf.int |
a confidence interval for the mean appropriate to the specified alternative hypothesis |
estimate |
the estimated mean or difference in means, depending on whether it was a one-sample or two-sample test. |
null.value |
the specified hypothesized value of the mean or mean difference. |
alternative |
a character string describing the alternative hypothesis. |
method |
a character string indicating what type of reweighted test of means was performed. |
data.name |
a character string giving the name of the data and the total number of clusters. |
M |
the number of clusters. |
Gregg, M., Marginal methods and software for clustered data with cluster- and group-size informativeness. PhD dissertation, University of Louisville, 2020.
data(screen8) ## One sample test ## Test if marginal math scores are equal to 70 ttestClust(x=screen8$math, idx=screen8$sch.id, mu = 70) ## paired test ## Test equality of marginal means in math and reading scores ttestClust(x=screen8$math, y=screen8$read, idx=screen8$sch.id, paired=TRUE) ## unpaired test ## Test if boys and girls have equal marginal math scores boys <- subset(screen8, gender=='M') girls <- subset(screen8, gender=='F') ttestClust(x=boys$math, y=girls$math, idx=boys$sch.id, idy=girls$sch.id) ## unpaired test using formula method ttestClust(math~gender, id=sch.id, data=screen8)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.