[R] KMO sampling adequacy and SPSS -- partial solution

Ashish Ranpura buddhahead at ranpura.com
Thu Dec 8 00:19:37 CET 2005


Sorry, there was an error in that function, a hangover from a  
previous session. The corrected function is:


kmo.test <- function(df){
###
## Calculate the Kaiser-Meyer-Olkin Measure of Sampling Adequacy.
## Input should be a data frame or matrix, output is the KMO statistic.
## Formula derived from Hutcheson et al, 1999,
## "The multivariate social scientist," page 224, ISBN 0761952012
## see <http://www2.chass.ncsu.edu/garson/pa765/hutcheson.htm>
###
	cor.sq = cor(df)^2
	cor.sumsq = (sum(cor.sq)-dim(cor.sq)[1])/2
	library(corpcor)
	pcor.sq = cor2pcor(cor(df))^2
	pcor.sumsq = (sum(pcor.sq)-dim(pcor.sq)[1])/2
	kmo = cor.sumsq/(cor.sumsq+pcor.sumsq)
	return(kmo)
}


--Ashish.




More information about the R-help mailing list