Main Content

coeftest

Linear hypothesis test on MANOVA model coefficients

Since R2023b

    Description

    example

    tbl = coeftest(maov) performs an F-test to determine if the coefficient estimates for the manova object maov are statistically different from zero, and returns the results in a table tbl.

    example

    tbl = coeftest(maov,A) tests the null hypothesis that A*B = 0, where B is the matrix of coefficients in maov.Coefficients. A is an a-by-p transform matrix with rank ap, and p is the number of terms in the MANOVA model for maov. Use this syntax to test for statistically significant differences in model coefficients between factor values.

    example

    tbl = coeftest(maov,A,C) tests the null hypothesis that A*B*C = 0. C is an r-by-c contrast matrix, where r is the number of response variables in the MANOVA model for maov. Use this syntax to test for statistically significant differences in model coefficients between response variables.

    tbl = coeftest(maov,A,C,D) tests the null hypothesis that A*B*C = D. D is a scalar or an a-by-c matrix of numeric values. Use this syntax to determine whether linear combinations of the coefficients estimated for maov are statistically equal to certain values.

    tbl = coeftest(___,TestStatistic=testStat) specifies the test statistic to use in the hypothesis test, using any of the input argument combinations in the previous syntaxes.

    [tbl,H,E] = coeftest(___) also returns the hypothesis matrix H and the error matrix E.

    Examples

    collapse all

    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.

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

    Perform a two-way MANOVA, using Model_Year and Cylinders as factors, and Acceleration and Displacement as response variables. Display the test statistic used to perform the MANOVA.

    maov = manova(data,["Acceleration" "Displacement"]);
    maov.TestStatistic
    ans = 
    "pillai"
    

    The output shows that the function uses Pillai's to compute the MANOVA statistics for maov.

    Test the null hypothesis that the model coefficients for maov are not statistically different from zero. By default, coeftest uses the statistic in maov.TestStatistic to perform the test.

    tbl = coeftest(maov)
    tbl=1×6 table
        TestStatistic    Value       F       DFNumerator    DFDenominator      pValue   
        _____________    ______    ______    ___________    _____________    ___________
    
          "pillai"       1.8636    259.68        10              190         4.4695e-105
    
    

    The p-value in the table output is very small, indicating that enough evidence exists to conclude that at least one of the model coefficients is statistically significant.

    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.

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

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

    maov = manova(data,["Acceleration" "Displacement"]);

    maov is a manova object that contains the results of the two-way MANOVA.

    Display the fitted MANOVA model coefficients for maov.

    coefs = maov.Coefficients
    coefs = 5×2
    
       14.9360  228.5164
       -0.8342    4.5054
        0.6874  -10.0817
        1.5827 -115.6528
        1.3065   -7.8655
    
    

    The first and second columns of the matrix coefs correspond to the car acceleration and car displacement response variables, respectively. Each row corresponds to a term in the MANOVA model, with the first row containing intercept terms.

    Display the names of the terms for the fitted coefficients.

    maov.ExpandedFactorNames
    ans = 1x5 string
        "(Intercept)"    "Year_70"    "Year_76"    "Cylinders_4"    "Cylinders_6"
    
    

    The output shows that the last two rows of coefs correspond to the terms for number of engine cylinders.

    Test the null hypothesis that, for both response variables, the sum of the coefficients corresponding to the number of engine cylinders is zero.

    A = [0 0 0 1 1];
    tbl = coeftest(maov,A)
    tbl=1×6 table
        TestStatistic     Value       F       DFNumerator    DFDenominator      pValue  
        _____________    _______    ______    ___________    _____________    __________
    
          "pillai"       0.81715    210.04         2              94          2.0833e-35
    
    

    The small p-value in the table output indicates that enough evidence exists to conclude that the sum of the engine cylinders coefficients is statistically different from zero.

    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.

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

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

    maov = manova(data,["Acceleration" "Displacement"]);

    maov is a manova object that contains the results of the two-way MANOVA.

    Display the fitted MANOVA model coefficients for maov.

    coefs = maov.Coefficients
    coefs = 5×2
    
       14.9360  228.5164
       -0.8342    4.5054
        0.6874  -10.0817
        1.5827 -115.6528
        1.3065   -7.8655
    
    

    The first and second columns of the matrix coefs correspond to the car acceleration and car displacement response variables, respectively. Each row corresponds to a term in the MANOVA model, with the first row containing intercept terms.

    Test the null hypothesis that the coefficients corresponding to the car acceleration sum to zero for each response variable.

    A = [0 0 0 1 1];
    C = [1;0];
    tbl = coeftest(maov,A,C)
    tbl=1×6 table
        TestStatistic     Value       F       DFNumerator    DFDenominator      pValue  
        _____________    _______    ______    ___________    _____________    __________
    
          "pillai"       0.33182    47.176         1              95          6.6905e-10
    
    

    The small p-value in the table output indicates that enough evidence exists to conclude that at least one of the sums is statistically different from zero.

    Input Arguments

    collapse all

    MANOVA results, specified as a manova object. The properties of maov contain the coefficient estimates and MANOVA statistics used by coeftest to perform the F-test.

    Transform matrix, specified as a p-by-p identity matrix or an a-by-p numeric matrix, where p is the number of terms in the MANOVA model for maov. A has rank ap.

    coeftest uses A to perform an F-test with the null hypothesis A*B*C = D. B is the matrix of coefficients in maov.Coefficients, C is a contrast matrix, and D is a matrix of hypothesized values. Specify A to test for statistically significant differences in model coefficients between factor values. For more information, see Multivariate Analysis of Variance for Repeated Measures.

    Example: [1 1 3 0;0 0 2 1]

    Data Types: single | double

    Contrast matrix, specified as an r-by-r identity matrix or an r-by-c numeric matrix, where r is the number of response variables in the MANOVA model for maov.

    coeftest uses C to perform an F-test with the null hypothesis A*B*C = D. B is the matrix of coefficients in maov.Coefficients, A is a transform matrix, and D is a matrix of hypothesized values. Specify C to test for statistically significant differences in model coefficients between response variables. For more information, see Multivariate Analysis of Variance for Repeated Measures.

    Example: [0.25 0.4]

    Data Types: single | double

    Hypothesized values, specified as 0, a numeric scalar, or an a-by-c numeric matrix. a is the number of rows in the transform matrix A, and c is the number of columns in the contrast matrix C. If D is a scalar, the function expands it to be an a-by-c matrix.

    coeftest uses D to perform an F-test with the null hypothesis A*B*C = D. B is the matrix of coefficients in maov.Coefficients, A is a transform matrix, and C is a contrast matrix. Specify D to determine whether linear combinations of the coefficients estimated for maov are statistically equal to certain values. For more information, see Multivariate Analysis of Variance for Repeated Measures.

    Example: [0 0 0 0;1 1 1 1;2 2 2 2]

    Data Types: single | double

    MANOVA test statistics, specified as maov.TestStatistic, "all", or one or more of the following values.

    ValueTest NameEquation
    "pillai" (default)Pillai's trace

    V=trace(Qh(Qh+Qe)1)=θi,

    where θi values are the solutions of the characteristic equation Qhθ(Qh + Qe) = 0. Qh and Qe are, respectively, the hypotheses and the residual sum of squares product matrices.

    "hotelling"Hotelling-Lawley trace

    U=trace(QhQe1)=λi,

    where λi are the solutions of the characteristic equation |QhλQe| = 0.

    "wilks"Wilk's lambda

    Λ=|Qe||Qh+Qe|=11+λi.

    "roy"Roy's maximum root statistic

    Θ=max(eig(QhQe1)).

    If you specify testStat as "all", coeftest calculates all the test statistics in the table above.

    Example: TestStatistic="hotelling"

    Data Types: char | string | cell

    Output Arguments

    collapse all

    Hypothesis test results, returned as a table with the following variables:

    • TestStatistic — Test statistic used by coeftest to perform the F-test.

    • Value — Value of the test statistic.

    • FF-statistic value. To calculate the F-statistic, coeftest transforms Value so that it follows an F-distribution under the null hypothesis.

    • DFNumerator — Degrees of freedom for the numerator of the F-statistic.

    • DFDenominator — Degrees of freedom for the denominator of the F-statistic.

    • pValuep-value for the F-statistic.

    Hypothesis matrix, returned as a numeric matrix. coeftest uses H to calculate the test statistic. For more information about H, see Qh in Multivariate Analysis of Variance for Repeated Measures.

    Data Types: single | double

    Error matrix, returned as a numeric matrix. coeftest uses E to calculate the test statistic. For more information about E, see Qe in Multivariate Analysis of Variance for Repeated Measures.

    Data Types: single | double

    Version History

    Introduced in R2023b