Main Content


Multiple comparison of marginal means for multiple analysis of variance (MANOVA)

Since R2023b



    m = multcompare(maov) returns a table of results m from a multiple comparison of marginal means for a one-way manova object.

    m = multcompare(maov,factor) performs the multiple comparison of marginal means over the values of the factor in factor. This syntax is valid for a one-, two-, or N-way MANOVA.


    m = multcompare(___,Name=Value) specifies options using one or more name-value arguments in addition to any of the input argument combinations in the previous syntaxes. For example, you can specify the confidence level and the type of critical value used to determine if the means are significantly different.


    collapse all

    Load the patients data set.

    load patients

    The variable Smoker contains data for patient smoking status, and the variables Systolic and Diastolic contain data for patient systolic and diastolic blood pressure.

    Perform a one-way MANOVA using Smoker as the factor and Systolic and Diastolic as the response variables.

    maov = manova(Smoker,[Systolic Diastolic],FactorNames="Smoker")
    maov = 
    1-way manova
    Y1,Y2 ~ 1 + Smoker
        Source    DF    TestStatistic    Value       F       DFNumerator    DFDenominator      pValue  
        ______    __    _____________    ______    ______    ___________    _____________    __________
        Smoker     1       pillai        0.6763    101.33          2              97         1.7465e-24
        Error     98                                                                                   
        Total     99                                                                                   
      Properties, Methods

    maov is a manova object containing the results of the one-way MANOVA. The small p-value for Smoker indicates that smoking status has a statistically significant effect on the mean response vector.

    Perform a multiple comparison of marginal means for the one-way MANOVA.

    m = multcompare(maov)
    m=1×6 table
        Group1    Group2    MeanDifference     Lower      Upper       pValue  
        ______    ______    ______________    _______    _______    __________
        false     true         -10.246        -11.667    -8.8247    1.0596e-10

    The MeanDifference column in the table output indicates that the marginal mean for smokers is larger than the marginal mean for non-smokers. The small p-value in the pValue column indicates that this difference is statistically significant, which is consistent with the small p-value for the Smoker term in the MANOVA model.

    Load the carsmall data set.

    load carsmall

    The variable Model_Year contains data for the year a car was manufactured, and the variable Cylinders contains data for the number of engine cylinders in the car. The Acceleration and Displacement variables contain data for car acceleration and displacement.

    Use the table function to create a table from the data in Model_Year, Cylinders, Acceleration, and Displacement.

    tbl = table(Model_Year,Cylinders,Acceleration,Displacement,VariableNames=["Year" "Cylinders" "Acceleration" "Displacement"]);

    Perform a two-way MANOVA using the table variables Year and Cylinders as factors, and the Acceleration and Displacement variables as response variables.

    maov = manova(tbl,"Acceleration,Displacement ~ Cylinders + Year")
    maov = 
    2-way manova
    Acceleration,Displacement ~ 1 + Year + Cylinders
         Source      DF    TestStatistic     Value        F       DFNumerator    DFDenominator      pValue  
        _________    __    _____________    ________    ______    ___________    _____________    __________
        Year          2       pillai        0.084893    2.1056          4             190           0.081708
        Cylinders     2       pillai         0.94174     42.27          4             190         2.5049e-25
        Error        95                                                                                     
        Total        99                                                                                     
      Properties, Methods

    maov is a manova object that contains the results of the two-way MANOVA. The table output shows that the p-value for the MANOVA model term Year is too large to conclude that Year has a statistically significant effect on the mean response vector. However, the small p-value for Cylinders indicates that enough evidence exists to conclude that Cylinders has a statistically significant effect on the mean response vector.

    Perform Scheffe's test to determine which values of the factor Cylinders correspond to statistically different marginal means.

    m = multcompare(maov,"Cylinders",CriticalValueType="scheffe")
    m=3×6 table
        Group1    Group2    MeanDifference     Lower      Upper       pValue  
        ______    ______    ______________    _______    _______    __________
          4         6          -53.756        -66.044    -41.467    2.0412e-17
          4         8          -117.35        -129.12    -105.58    3.3198e-42
          6         8          -63.594        -77.001    -50.188    2.4573e-19

    The small p-values in the pValue column indicate that each marginal mean is statistically different from the other two.

    Input Arguments

    collapse all

    MANOVA results, specified as a manova object. The properties of maov contain the factor values and response data used by multcompare to calculate the difference in means.

    Factor used to group the response data, specified as a string scalar or character array. factor must be a name in maov.FactorNames.

    Example: "Factor2"

    Data Types: char | string

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: multcompare(maov,Alpha=0.01,CriticalValueType="dunnett") sets the significance level of the confidence intervals to 0.01 and uses Dunnett's critical value to calculate the p-values.

    Significance level for the estimates, specified as a scalar value in the range (0,1). The confidence level of the confidence intervals is 100(1α)%. The default value for Alpha is 0.05, which returns 95% confidence intervals for the estimates.

    Example: Alpha=0.01

    Data Types: single | double

    Critical value type used by the multcompare function to calculate p-values, specified as one of the options in the following table. Each option specifies the statistical test that multcompare uses to calculate the critical value.

    OptionStatistical Test
    "tukey-kramer" (default)Tukey-Kramer test
    "hsd"Honestly Significant Difference test (same as "tukey-kramer")
    "dunn-sidak"Dunn-Sidak correction
    "bonferroni"Bonferroni correction
    "scheffe"Scheffe test
    "dunnett"Dunnett's test — The control group is selected in the generated plot and cannot be changed.
    "lsd"Stands for Least Significant Difference and uses the critical value for a plain t-test. This option does not protect against the multiple comparisons problem. In other words, the probability of two marginal means being incorrectly flagged as significantly different increases with the number of factor values.

    Example: CriticalValueType="dunn-sidak"

    Data Types: char | string

    Output Arguments

    collapse all

    Multiple comparison procedure results, returned as a table with the following variables:

    • Group1 — Values of the factors in the first comparison group

    • Group2 — Values of the factors in the second comparison group

    • MeanDifference — Difference in the marginal mean response between the observations in Group1 and the observations in Group2

    • Lower — 95% lower confidence bound on the marginal mean difference

    • Upper — 95% upper confidence bound on the marginal mean difference

    • pValuep-value corresponding to the null hypothesis that the marginal mean of Group1 is not statistically different from the mean of Group2

    Version History

    Introduced in R2023b