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

2007-08-06 Thread G. Jay Kerns
Hello,

This is in response to a post from a couple of years back regarding
Kaiser-Meyer-Olkin Measures of Sampling Adequacy.
(http://tolstoy.newcastle.edu.au/R/help/05/12/17233.html)

As it turns out, last year Trujillo-Ortiz et al. at the Universidad
Autonoma de Baja California wrote and posted a script for MATLAB that
does the job.  You can see it (with a discussion of KMO statistics) at

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=12736

Please see their post for documentation/citations/references, etc.

I translated the code into R-speak and added a little to the output;
the function and an example are copied below. You can just copy/paste
to the console to try it out, provided you have the MASS package.

Cheers,
Jay


***
G. Jay Kerns, Ph.D.
Assistant Professor / Statistics Coordinator
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
E-mail: [EMAIL PROTECTED]
http://www.cc.ysu.edu/~gjkerns/





# KMO Kaiser-Meyer-Olkin Measure of Sampling Adequacy
kmo = function( data ){

  library(MASS)
  X - cor(as.matrix(data))
  iX - ginv(X)
  S2 - diag(diag((iX^-1)))
  AIS - S2%*%iX%*%S2  # anti-image covariance matrix
  IS - X+AIS-2*S2 # image covariance matrix
  Dai - sqrt(diag(diag(AIS)))
  IR - ginv(Dai)%*%IS%*%ginv(Dai) # image correlation matrix
  AIR - ginv(Dai)%*%AIS%*%ginv(Dai)   # anti-image correlation matrix
  a - apply((AIR - diag(diag(AIR)))^2, 2, sum)
  AA - sum(a)
  b - apply((X - diag(nrow(X)))^2, 2, sum)
  BB - sum(b)
  MSA - b/(b+a)# indiv. measures of sampling adequacy

  AIR - AIR-diag(nrow(AIR))+diag(MSA)  # Examine the anti-image of the
# correlation matrix. That is the
# negative of the partial correlations,
# partialling out all other variables.

  kmo - BB/(AA+BB) # overall KMO statistic

  # Reporting the conclusion
if (kmo = 0.00  kmo  0.50){
  test - 'The KMO test yields a degree of common variance
unacceptable for FA.'
} else if (kmo = 0.50  kmo  0.60){
  test - 'The KMO test yields a degree of common variance miserable.'
} else if (kmo = 0.60  kmo  0.70){
  test - 'The KMO test yields a degree of common variance mediocre.'
} else if (kmo = 0.70  kmo  0.80){
  test - 'The KMO test yields a degree of common variance middling.'
} else if (kmo = 0.80  kmo  0.90){
  test - 'The KMO test yields a degree of common variance meritorious.'
} else {
  test - 'The KMO test yields a degree of common variance marvelous.'
}

ans - list(  overall = kmo,
  report = test,
  individual = MSA,
  AIS = AIS,
  AIR = AIR )
return(ans)

}# end of kmo()



#  Try Trujillo-Ortiz et al. example
X = scan()
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

dim(X)=c(8,12)
X=t(X)
kmo(X)

__
R-help@stat.math.ethz.ch 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.


[R] [R-pkgs] the IPSUR package

2006-09-26 Thread G. Jay Kerns
Dear useRs,

We are pleased to announce the preliminary release of the IPSUR package.

The primary audience was originally envisioned to be upper division
undergraduate mathematics/statistics/engineering majors, but other useRs may
find this material useful.

In a nutshell, this package slightly modifies and adds selected
functionality to the R Commander by John Fox.  The changes were meant to
customize Rcmdr for our Statistics classes, populated for the most part by
the audience above.  Some clever functions written by John Verzani were
translated to IPSUR from UsingR.

Downloads for the package (while the CRAN submission is pending) are at

http://www.cc.ysu.edu/~gjkerns/IPSUR/package/index.htm

Check out the Features page to see what the package offers.

http://www.cc.ysu.edu/~gjkerns/IPSUR/package/features.htm

Full credit must be given to John Fox, together with his diverse team of
dedicated contributors.  Indeed, without all of their countless hours of
effort the IPSUR package would not be possible.  Kudos to them for providing
excellent software to the R community.

Cheers,
Jay




***
G. Jay Kerns, Ph.D.
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
E-mail: [EMAIL PROTECTED]
http://www.cc.ysu.edu/~gjkerns/

[[alternative HTML version deleted]]

___
R-packages mailing list
R-packages@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-packages

__
R-help@stat.math.ethz.ch 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.