Dear Moumita,
On Wed, Sep 30, 2009 at 10:03 AM, Moumita Das <das.moumita.onl...@gmail.com> wrote: > Hi All, > How do i calculate KMO for a dataset? > > *Dataset:---------------------* > > m1 m2 m3 m4 m5 m6 m7 m8 > 1 2 20 20 2 1 4 14 12 > 2 9 16 3 5 2 5 5 15 > 3 18 18 18 13 17 9 2 4 > 4 7 7 2 12 2 11 11 11 > 5 7 8 5 19 5 2 20 18 > 6 7 4 7 4 7 9 3 3 > 7 5 5 5 12 5 13 13 12 > 8 6 6 4 3 5 17 17 16 > 9 12 12 4 2 4 4 14 14 > 10 5 14 6 19 6 2 20 20 > 11 13 13 13 20 10 10 10 9 > 12 3 3 3 11 6 15 15 12 > 13 2 2 2 7 5 5 6 16 > 14 11 11 10 4 10 10 10 10 > 15 1 1 1 8 4 16 16 17 > 16 23 23 3 4 3 3 3 3 > 17 4 4 6 9 8 17 8 18 > 18 8 8 5 9 7 7 7 9 > 19 6 7 8 3 8 4 4 7 > 20 8 11 9 3 2 2 2 3 > > ** > *SPSS results for the above dataset:--------* > > Kaiser-Meyer-Olkin Measure of Sampling Adequacy.(KMO) > 0.350911931549742 > > *Got a R-function:-----* ( > http://www.opensubscriber.com/message/r-h...@stat.math.ethz.ch/2776549.html) > 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><http://www2.chass.ncsu.edu/garson/pa765/hutcheson.htm%3E> > ### > 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 = sus.cor.ss/(sus.cor.ss+sus.pcor.ss) > return(kmo) > } > > What is this object "*sus.cor.ss*"?I get errors >> sus.cor.ss > Error: object "sus.cor.ss" not found > > > Thanks in advance > Moumita > I gave the solution to this in the next message in the thread: http://www.opensubscriber.com/message/r-h...@stat.math.ethz.ch/7315408.html If you simply copy-paste the function I wrote there into your R session it gives the same answer as SPSS; I just checked it myself. This may save you some time: D <- structure(list(m1 = c(2L, 9L, 18L, 7L, 7L, 7L, 5L, 6L, 12L, 5L, 13L, 3L, 2L, 11L, 1L, 23L, 4L, 8L, 6L, 8L), m2 = c(20L, 16L, 18L, 7L, 8L, 4L, 5L, 6L, 12L, 14L, 13L, 3L, 2L, 11L, 1L, 23L, 4L, 8L, 7L, 11L), m3 = c(20L, 3L, 18L, 2L, 5L, 7L, 5L, 4L, 4L, 6L, 13L, 3L, 2L, 10L, 1L, 3L, 6L, 5L, 8L, 9L), m4 = c(2L, 5L, 13L, 12L, 19L, 4L, 12L, 3L, 2L, 19L, 20L, 11L, 7L, 4L, 8L, 4L, 9L, 9L, 3L, 3L), m5 = c(1L, 2L, 17L, 2L, 5L, 7L, 5L, 5L, 4L, 6L, 10L, 6L, 5L, 10L, 4L, 3L, 8L, 7L, 8L, 2L), m6 = c(4L, 5L, 9L, 11L, 2L, 9L, 13L, 17L, 4L, 2L, 10L, 15L, 5L, 10L, 16L, 3L, 17L, 7L, 4L, 2L), m7 = c(14L, 5L, 2L, 11L, 20L, 3L, 13L, 17L, 14L, 20L, 10L, 15L, 6L, 10L, 16L, 3L, 8L, 7L, 4L, 2L), m8 = c(12L, 15L, 4L, 11L, 18L, 3L, 12L, 16L, 14L, 20L, 9L, 12L, 16L, 10L, 17L, 3L, 18L, 9L, 7L, 3L)), .Names = c("m1", "m2", "m3", "m4", "m5", "m6", "m7", "m8"), class = "data.frame", row.names = c(NA, -20L)) kmo(D) HTH, Jay *************************************************** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics & Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX VoIP: gjke...@ekiga.net E-mail: gke...@ysu.edu http://people.ysu.edu/~gkerns/ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.