谢老师,因子分析的KMO检验我没太懂。计算公式我看的《应用多元统计分析》(李卫东 2008),但是上面写的比较模糊。

另外我从国外的网上下了一个计算KMO的函数文件,现分享出来,因为似乎有很多人需要这个代码:

function [A,B] = kmo(X)

%KMO Kaiser-Meyer-Olkin Measure of Sampling Adequacy.

% Factor analysis can be used as a guide to how coherently a set of variables

% relate to a hypothesized underlying dimension that they are all being used

% to measure. External validity analysis assesses whether the scale that has

% been constructed performs as theoretically expected in correlation with

% other variables to which it is expected to be related.

% There are some assumptions about the characteristics of factors that are

% extracted and defined that are unobserved common dimensions that may be

% listed to account for the correlations among observed variables. Sampling

% adequacy predicts if data are likely to factor well, based on correlation

% and partial correlation. Is used to assess which variables to drop from the

% model because they are too multicollinear.

% It has been suggested that inv(R) should be a near-diagonal matrix in order

% to successfully fit a factor analysis model.  To assess how close inv(R)

% is to a diagonal matrix, Kaiser (1970) proposed a measure of sampling

% adequacy, now called KMO (Kaiser-Meyer-Olkin) index. The common part, called

% the image of a variable, is defined as that part which is predictable by

% regressing each variable on all other variables.

% The anti-image is the specific part of the variable that cannot be predicted.

% Examining the anti-image of the correlation matrix. That is the negative of the

% partial correlations, partialling out all other variables.

% There is a KMO statistic for each individual variable and their sum is

% the overall statistic. If it is not > 0.6 drop the indicator variables with

% the lowest individual statistic value until the overall one rises above 0.6:

% factors which is meritorious. The diagonal elements on the Anti-image

% correlation matrix are the KMO individual statistics for each variable. A KMO

% index <= 0.5 indicates the correlation matrix is not suitable for factor

% analysis.

%

% Syntax: function kmo(X)

%

%     Input:

%          X - Input matrix can be a data matrix (size n-data x p-variables)

%     Output(s):

%            - Kaiser-Meyer-Olkin Index.

%            - Degree of Common Variance Report (shared by a set of variables

%              and thus assesses the degree to which they measure a common

%              underlying factor).

%        optional(s):

%            - Anti-image Covariance Matrix.

%            - Anti-image Correlation Matrix

%

%  Example: From the example given on the web page

%  http://www.ncl.ac.uk/iss/statistics/docs/factoranalysis.html

%  We are interested to calculate the Kaiser-Meyer-Olkin measure of sampling

%  adequacy in order to see if proceeds a satisfactory factor analysis to

%  investigate the reasons why customers buy a product such as a particular

%  brand of soft drink (e.g. coca cola). Several variables were identified

%  which influence customer to buy coca cola. Some of the variables identified

%  as being influential include availability of product (X1), cost of product

%  (X2), experience with product (X3), popularity of product (X4), prestige

%  attached to product (X5), quality of product (X6), quantity of product (X7),

%  and respectability of product (X8). From this, you designed a questionnaire

%  to solicit customers' view on a seven point scale, where 1 = not important

%  and 7 = very important. The results from your questionnaire are show on the

%  table below. Only the first twelve respondents (cases) are used in this

%  example.

%

%  Table 1: Customer survey

%  --------------------------------------------------

%     X1    X2    X3    X4    X5    X6    X7    X8

%  --------------------------------------------------

%      4     1     4     5     2     3     6     7

%      4     2     7     6     6     3     3     4

%      6     4     3     4     2     5     7     7

%      5     3     5     4     3     4     6     7

%      5     2     4     5     2     5     5     6

%      6     3     3     5     4     4     7     7

%      6     2     4     4     4     3     4     5

%      4     1     3     4     3     3     5     6

%      5     3     4     3     4     3     6     6

%      5     4     3     4     4     4     6     7

%      6     2     4     4     4     3     7     5

%      5     2     3     3     3     3     7     6

%  --------------------------------------------------

%

% Data matrix must be:

%  X=[4 1 4 5 2 3 6 7;4 2 7 6 6 3 3 4;6 4 3 4 2 5 7 7;5 3 5 4 3 4 6 7;

%  5 2 4 5 2 5 5 6;6 3 3 5 4 4 7 7;6 2 4 4 4 3 4 5;4 1 3 4 3 3 5 6;

%  5 3 4 3 4 3 6 6;5 4 3 4 4 4 6 7;6 2 4 4 4 3 7 5;5 2 3 3 3 3 7 6];

%

%  Calling on Matlab the function:

%            kmo(X)

%

%  Answer is:

%

%  Kaiser-Meyer-Olkin Measure of Sampling Adequacy: 0.4172

%  The KMO test yields a degree of common variance unacceptable (Don't Factor).

%

%

%  Created by A. Trujillo-Ortiz, R. Hernandez-Walls, A. Castro-Perez,

%             K. Barba-Rojo and A. Otero-Limon

%             Facultad de Ciencias Marinas

%             Universidad Autonoma de Baja California

%             Apdo. Postal 453

%             Ensenada, Baja California

%             Mexico.

%             atrujo@uabc.mx

%

%  Copyright. October 10, 2006.

%

% To cite this file, this would be an appropriate format:

% Trujillo-Ortiz, A., R. Hernandez-Walls, A. Castro-Perez, K. Barba-Rojo

%   and A. Otero-Limon (2006). kmo:Kaiser-Meyer-Olkin Measure of Sampling

%   Adequacy. A MATLAB file. [WWW document]. URL http://www.mathworks.com/

%   matlabcentral/fileexchange/loadFile.do?objectId=12736

%

%  References:

%  Rencher, A. C. (2002), Methods of Multivariate Analysis. 2nd. ed.

%            New-Jersey:John Wiley & Sons. Chapter 13 (pp. 408-450).

%

error(nargchk(1,1,nargin));

msg = nargoutchk(1, 2, nargout);

X = corrcoef(X);

iX = inv(X);

S2 = diag(diag((iX.^-1)));

AIS = S2*iX*S2; %anti-image covariance matrix

IS = X+AIS-2*S2; %image covariance matrix

Dai = diag(diag(sqrt(AIS)));

IR = inv(Dai)*IS*inv(Dai); %image correlation matrix

AIR = inv(Dai)*AIS*inv(Dai); %anti-image correlation matrix

a = sum((AIR - diag(diag(AIR))).^2);

AA = sum(a);

b = sum((X - eye(size(X))).^2);

BB = sum(b);

MSA = b./(b+a); %measures of sampling adequacy

AIR = AIR-eye(size(AIR))+diag(MSA);

%Examine the anti-image of the correlation matrix. That is the negative of the partial correlations,

%partialling out all other variables.

N = BB;

D = AA+BB;

kmo = N/D;

disp(' ')

fprintf('Kaiser-Meyer-Olkin Measure of Sampling Adequacy: %3.4f\n', kmo);

if (kmo >= 0.00 && kmo < 0.50);

disp('The KMO test yields a degree of common variance unacceptable (Don''t Factor).')

elseif (kmo >= 0.50 && kmo < 0.60);

disp('The KMO test yields a degree of common variance miserable.')

elseif (kmo >= 0.60 && kmo < 0.70);

disp('The KMO test yields a degree of common variance mediocre.')

elseif (kmo >= 0.70 && kmo < 0.80);

disp('The KMO test yields a degree of common variance middling.')

elseif (kmo >= 0.80 && kmo < 0.90);

disp('The KMO test yields a degree of common variance meritorious.')

else (kmo >= 0.90 && kmo <= 1.00);

disp('The KMO test yields a degree of common variance marvelous.')

end

if nargout == 1;

disp(' ')

disp('A = Anti-image covariance matrix.');

A = AIS;

elseif nargout > 1;

disp(' ')

disp('A = Anti-image covariance matrix.');

A = AIS;

disp('B = Anti-image correlation matrix.');

B = AIR;

end

return,

但是我从书上看的计算公式好像和上面的代码中的不太一致?另外还有一个MSA是什么东西呢?

[本帖最后由 songyc907 于 2011-7-21 13:37 编辑]

matlab做kmo检验的代码,KMO检验相关推荐

  1. 自再现模的迭代法matlab做图的的代码

    自再现模的迭代法的代码 垂雷大学激光工程的作业,网上找了一下百度文库有篇相关的文章,不过里面的代码写的不太规范(命名啊,空格啊),就按照自己的习惯改了改,再说百度文库也不好复制粘贴,就放在这里吧.万一 ...

  2. php俄罗斯方块代码,[原创]Matlab做的俄罗斯方块(含代码)

    以下是引用swf_2008在2007-5-17 9:36:53的发言: 能不能在方块移除的几句程序后面加些注释,不大看的懂啊.谢谢 for num = 1: length( LastBlockYDat ...

  3. matlab做kmo检验的代码,急求 KMO测度和Bartlett 的球形度检验的计算原公式

    1.关于KMO公式,您从如下matlab源程序代码中不难得出,我已经用Excel就计算出来了,跟SPSS的计算结果完全一致. iX = inv(X);     %X是原始数据的相关系数矩阵R,而inv ...

  4. python因子分析案例_Python——因子分析(KMO检验和Bartlett's球形检验)

    因子分析用Python做的一个典型例子 一.实验目的 采用合适的数据分析方法对下面的题进行解答 二.实验要求 采用因子分析方法,根据48位应聘者的15项指标得分,选出6名最优秀的应聘者. 三.代码 i ...

  5. Python——因子分析(KMO检验和Bartlett's球形检验)

    因子分析用Python做的一个典型例子 一.实验目的 采用合适的数据分析方法对下面的题进行解答 二.实验要求 采用因子分析方法,根据48位应聘者的15项指标得分,选出6名最优秀的应聘者. 三.代码 i ...

  6. R语言稀疏主成分分析、因子分析、KMO检验和Bartlett球度检验分析上市公司财务指标数据...

    全文链接:http://tecdat.cn/?p=31080 R中的主成分分析(PCA)和因子分析是统计分析技术,也称为多元分析技术(点击文末"阅读原文"获取完整代码数据). 当可 ...

  7. python因子分析 ic值 函数_Python——因子分析(KMO检验和Bartlett's球形检验)

    因子分析用Python做的一个典型例子 一.实验目的 采用合适的数据分析方法对下面的题进行解答 二.实验要求 采用因子分析方法,根据48位应聘者的15项指标得分,选出6名最优秀的应聘者. 三.代码 i ...

  8. python怎么实现检验_python实现KMO检验和Bartlett's球形检验

    1.KMO KMO(Kaiser-Meyer-Olkin)检验统计量是用于比较变量间简单相关系数和偏相关系数的指标.主要应用于多元统计的因子分析.KMO统计量是取值在0和1之间. 使用说明: Kais ...

  9. python因子分析法_Python——因子分析(KMO检验和Bartlett's球形检验)

    因子分析用Python做的一个典型例子 一.实验目的 采用合适的数据分析方法对下面的题进行解答 二.实验要求 采用因子分析方法,根据48位应聘者的15项指标得分,选出6名最优秀的应聘者. 三.代码 i ...

最新文章

  1. 从Sql server 2000 到 Oracle 10g数据库迁移数据类型转化
  2. C++基础知识点整理
  3. 信息学奥赛一本通(2024:【例4.10】末两位数)
  4. vue如何取消下拉框按回车自动下拉_如何用大白菜重装系统|大白菜怎么重装系统教程详解...
  5. 微课|玩转Python轻松过二级(3.3节):字典使用要点
  6. java 线程安全 Lock
  7. 【图像分割】基于matlab粒子群优化T熵图像分割【含Matlab源码 286期】
  8. win10计算机磁盘图标,win10系统本地磁盘图标显示异常如何恢复
  9. jdk安装好了怎么使用_安装jdk怎么打开
  10. Validation 参数校验
  11. 广东工业大学化学工程考研情况
  12. iPhone尺寸规格
  13. 《中国人工智能学会通讯》——8.44 基于用户缺陷报告挖掘软件缺陷
  14. 快消品行业S2B2C电子商务网站提升供应链效率,加速行业整合
  15. 各种效应:蝴蝶效应、青蛙现象、鳄鱼法则、鲇鱼效应、羊群效应、刺猬法则、手表定律、破窗理论、二八定律、木桶理论、马太效应
  16. 生成EXCEL(不使用模板)
  17. 图数据库(七):Neo4j中Cypher语言where关键字
  18. educoder多路选择器与应用4关卡通关2选一、4选一、8选一、MUS应用(在Logisim上演示)
  19. HTML5拖拽文件上传
  20. CSS一元素的显示与隐藏

热门文章

  1. js数组遍历的方法的一些细节
  2. 中国系统java开发面试准备
  3. 【vite+vue3.0】基于vite写一个将md文件渲染为js文件的插件
  4. 常用图像卷积核类型小结
  5. Python 复制文件到指定路径
  6. 移动运营商ipcc文件_如何在苹果官网提取IPCC文件?
  7. 抖音爆款脚本文案怎么写?写作时需要注意什么。
  8. Java多线程 发布private对象逸出的演示
  9. wpsppt加载项在哪里_《wps表格加载项在哪里》 WPS版的EXCEL中 加载宏和数据分析在哪?...
  10. python json转csv_使用Python将Json转换为CSV