matlab manova,MANOVA - MATLAB & Simulink - MathWorks 中国

Fields of the stats Structure

The W, B, and T fields are matrix analogs to the within, between, and total sums of squares in ordinary one-way analysis of variance. The next three fields are the degrees of freedom for these matrices. Fields lambda, chisq, and chisqdf are the ingredients of the test for the dimensionality of the group means. (The p-values for these tests are the first output argument of manova1.)

The next three fields are used to do a canonical analysis. Recall that in Principal Component Analysis (PCA) you look for the combination of the original variables that has the largest possible variation. In multivariate analysis of variance, you instead look for the linear combination of the original variables that has the largest separation between groups. It is the single variable that would give the most significant result in a univariate one-way analysis of variance. Having found that combination, you next look for the combination with the second highest separation, and so on.

The eigenvec field is a matrix that defines the coefficients of the linear combinations of the original variables. The eigenval field is a vector measuring the ratio of the between-group variance to the within-group variance for the corresponding linear combination. The canon field is a matrix of the canonical variable values. Each column is a linear combination of the mean-centered original variables, using coefficients from the eigenvec matrix.

c1 = stats.canon(:,1);

c2 = stats.canon(:,2);

Plot the grouped scatter plot of the first two canonical variables.

figure

gscatter(c2,c1,Model_Year,[],'oxs')

4b5c78ba97af0a58f423a27c2c6f2f3d.png

A grouped scatter plot of the first two canonical variables shows more separation between groups then a grouped scatter plot of any pair of original variables. In this example, it shows three clouds of points, overlapping but with distinct centers. One point in the bottom right sits apart from the others. You can mark this point on the plot using the gname function.

Roughly speaking, the first canonical variable, c1, separates the 1982 cars (which have high values of c1) from the older cars. The second canonical variable, c2, reveals some separation between the 1970 and 1976 cars.

The final two fields of the stats structure are Mahalanobis distances. The mdist field measures the distance from each point to its group mean. Points with large values may be outliers. In this data set, the largest outlier is the one in the scatter plot, the Buick Estate station wagon. (Note that you could have supplied the model name to the gname function above if you wanted to label the point with its model name rather than its row number.)

Find the largest distance from the group mean.

max(stats.mdist)

ans = 31.5273

Find the point that has the largest distance from the group mean.

find(stats.mdist == ans)

ans = 20

Find the car model that corresponds to the largest distance from the group mean.

Model(20,:)

ans =

'buick estate wagon (sw) '

The gmdist field measures the distances between each pair of group means. Examine the group means using grpstats.

grpstats(x, Model_Year)

ans = 3×4

103 ×

0.0177 0.1489 0.2869 3.4413

0.0216 0.1011 0.1978 3.0787

0.0317 0.0815 0.1289 2.4535

Find the distances between the each pair of group means.

stats.gmdist

ans = 3×3

0 3.8277 11.1106

3.8277 0 6.1374

11.1106 6.1374 0

As might be expected, the multivariate distance between the extreme years 1970 and 1982 (11.1) is larger than the difference between more closely spaced years (3.8 and 6.1). This is consistent with the scatter plots, where the points seem to follow a progression as the year changes from 1970 through 1976 to 1982. If you had more groups, you might find it instructive to use the manovacluster function to draw a diagram that presents clusters of the groups, formed using the distances between their means.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值