barttest
Bartlett’s test
Description
Examples
Determine Dimensions Needed to Explain Nonrandom Data Variation
Generate a 20-by-6 matrix of random numbers from a multivariate normal distribution with mean mu = [0 0]
and covariance sigma = [1 0.99; 0.99 1]
.
rng default % for reproducibility mu = [0 0]; sigma = [1 0.99; 0.99 1]; X = mvnrnd(mu,sigma,20); % columns 1 and 2 X(:,3:4) = mvnrnd(mu,sigma,20); % columns 3 and 4 X(:,5:6) = mvnrnd(mu,sigma,20); % columns 5 and 6
Determine the number of dimensions necessary to explain the nonrandom variation in data matrix X
. Report the significance values for the hypothesis tests.
[ndim, prob] = barttest(X,0.05)
ndim = 3
prob = 5×1
0.0000
0.0000
0.0000
0.5148
0.3370
The returned value of ndim
indicates that three dimensions are necessary to explain the nonrandom variation in X
.
Input Arguments
x
— Input data
matrix of scalar values
Input data, specified as a matrix of scalar values.
Data Types: single
| double
alpha
— Significance level
0.05
(default) | scalar value in the range (0,1)
Significance level of the hypothesis test, specified as a scalar
value in the range (0,1)
.
Example: 0.1
Data Types: single
| double
Output Arguments
ndim
— Number of dimensions
positive integer value
Number of dimensions, returned as a positive integer value.
The dimension is determined by a series of hypothesis tests. The test
for ndim = 1
tests the hypothesis that the variances
of the data values along each principal component are equal, the test
for ndim = 2
tests the hypothesis that the variances
along the second through last components are equal, and so on. The
null hypothesis is that the number of dimensions is equal to the number
of the largest unequal eigenvalues of the covariance matrix of x
.
prob
— Significance value
vector of scalar values in the range (0,1)
Significance value for the hypothesis tests, returned as a vector
of scalar values in the range (0,1)
. Each element
in prob
corresponds to an element of chisquare
.
chisquare
— Test statistics
vector of scalar values
Test statistics for each dimension’s hypothesis test, returned as a vector of scalar values.
Version History
Introduced before R2006a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)