Learn R Programming

smsets (version 2.0.0)

ttests2s.mv: Multiple two-sample t-tests for multivariate data

Description

Performs multiple two-sample t-tests on more than one response vector with corrected significance levels using any of the adjustment methods for multiple comparisons offered by p.adjust. Effects sizes are also computed.

Usage

ttests2s.mv(
  x,
  group,
  level1,
  alternative = "two.sided",
  var.equal = FALSE,
  P.adjust = "none",
  unit = "units"
)

Value

Returns an object of class "ttests2s.mv", a list containing the following components:

nameA character string describing the functiont.listA list containing p vectors of length 5, each vector having the computed t-statistic, the degrees of freedom for the t-statistic, the adjusted p-value for the test, the raw effect size estimator: \(\bar{x}_1 - \bar{x}_2\), and the post hoc effect size estimator recommended by Hedges (1981), analogous to Cohen's d, given by \(|\bar{x}_1 - \bar{x}_2| / \hat{\sigma}\). Here \(\hat{\sigma} = \sqrt{MSE}\) where \(MSE\) is mean squared error, the estimator of the variance for the difference of means \(\bar{x}_1 - \bar{x}_2\).alternativeA character string specifying the alternative hypothesis chosen.var.equalA logical variable indicating whether the two variances were treated as being equal TRUE or not FALSE.P.adjustA character string indicating the correction method chosenraw.ESThe raw effect size (scalar) expressed in the pre-specified units
unitA character string indicating the units chosenHedges.dThe post hoc effect size Hedges' estimator (scalar)groupA character string specifying the name of the two-level factor defining groups.levels.groupA vector of length two showing the two levels in factor group.data.nameA character string giving the name of the data.datathe data frame analyzed.

The extractor function print.ttests2s.mv returns an annotated output of each t-test and effect size estimation.

Arguments

x

A data frame with one two-level factor and p response variables.

group

Two-level factor defining groups. It must be one of the columns in x.

level1

A character string identifying Sample 1. The string must be one of the factor levels in group.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less". You can specify just the initial letter.

var.equal

a logical variable indicating whether to treat the two variances as being equal. If TRUE then the pooled variance is used to estimate the variance otherwise the Welch (or Satterthwaite) approximation to the degrees of freedom is used.

P.adjust

p-value correction method, a character string. Can be abbreviated.

unit

A character string in cases in which all response variables are measured using the same physical units. Useful to fully characterize raw effect sizes. The default value is the character string "units".

Author

Jorge Navarro Alberto, ganava4@gmail.com

Details

This function extends the univariate t.test for the comparison of mean values for two samples, when more than one variable is involved in the data analysis, so that type one error rates ("false significances") in a series of univariate t-tests are adjusted according to the number of response variables analyzed. The pairwise comparisons between the two levels in group with corrections for multiple testing are made over more than one response vector thus, the function is a variation of pairwise.t.test.

The methods implemented are the same as those contained in the p.adjust.methods for p.adjust: "bonferroni", "holm", "hochberg", "hommel", "BH" (Benjamini-Hochberg) or its alias "fdr" (False Discovery Rate), and "BY" (Benjamini & Yekutieli). The default pass-through option ("none") is also included.

References

Hedges, L. V. 1981. Distribution theory for Glass’s estimator of effect size and related estimators. Journal of Educational Statistics 6(2): 107–128.

Examples

Run this code
data(sparrows)
ttests.sparrows <- ttests2s.mv(sparrows, group = Survivorship, level1 = "S",
                              var.equal = TRUE, P.adjust = "bonferroni",
                              unit = "mm")
ttests.sparrows

Run the code above in your browser using DataLab