| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Statistics Toolbox |
| Contents | Index |
| Learn more about Statistics Toolbox |
vartestn(X)
vartestn(X,group)
p = vartestn(...)
[p,STATS] = vartestn(...)
[...] = vartestn(...,displayopt)
[...] = vartestn(...,testtype)
vartestn(X) performs Bartlett's test for equal variances for the columns of the matrix X. This is a test of the null hypothesis that the columns of X come from normal distributions with the same variance, against the alternative that they come from normal distributions with different variances. The result is a display of a box plot of the groups, and a summary table of statistics.
vartestn(X,group) requires a vector X, and a group argument that is a categorical variable, vector, string array, or cell array of strings with one row for each element of X. The X values corresponding to the same value of group are placed in the same group. (See Grouped Data.) The function tests for equal variances across groups.
vartestn treats NaNs as missing values and ignores them.
p = vartestn(...) returns the p-value, i.e., the probability of observing the given result, or one more extreme, by chance if the null hypothesis of equal variances is true. Small values of p cast doubt on the validity of the null hypothesis.
[p,STATS] = vartestn(...) returns a structure with the following fields:
'chistat' — Value of the test statistic
'df' — Degrees of freedom of the test
[...] = vartestn(...,displayopt) determines if a box plot and table are displayed. displayopt may be 'on' (the default) or 'off' .
[...] = vartestn(...,testtype) sets the test type. When testtype is 'robust', vartestn performs Levene's test in place of Bartlett's test, which is a useful alternative when the sample distributions are not normal, and especially when they are prone to outliers. For this test the STATS output structure has a field named 'fstat' containing the test statistic, and 'df1' and 'df2' containing its numerator and denominator degrees of freedom. When testtype is 'classical' vartestn performs Bartlett's test.
Does the variance of mileage measurements differ significantly from one model year to another?
load carsmall
p = vartestn(MPG,Model_Year)
p =
0.8327


![]() | vartest2 | vertcat (categorical) | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |