cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
goutam
Level III

How to get Kaiser's MSA (aka KMO) in JMP's Factor analysis?

The Kaiser's MSA (also called KMO) is a metric that is frequently used along with anti-image correlation matrix to judge the suitability of a set of variables for factor analsysis. I can get these easily uisng SAS (proc factor). Anyone knwos how to get these in JMP (I am using JMP Pro version 9)?  I see there was a post in early 2010 about KMO and the answer there was to literally calculate these by exporting the partial/inverse correlation matric to Excel. I am hoping by now, JMP or soem users have come up with a script or some options that do it automatically. Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
mpb
mpb
Level VII

Re: How to get Kaiser's MSA (aka KMO) in JMP's Factor analysis?

See if this code is helpful. I only was able to check it against the socioeconomic sample data and the results were same as the SAS results shown in the SAS docs online. Use at your own risk and certainly test on as many datasets as you have MSA results for.

 

 

/* Next line if want to open a specific JMP table */
//dt = Open( "$SAMPLE_DATA/Socioeconomic.jmp" );
/* Next line if want to have user pick a JMP data table */
//dt = Open();
/* No Open statement if want to run against the current data table */

cd = Column Dialog( Col ID = ColList( "Select Columns" ) );

names = cd["Col ID"];
nsel = N Items( names );

mv = Multivariate(
    Y( Eval( names ) ),
    Estimation Method( "Row-wise" ),
    Scatterplot Matrix( Density Ellipses( 1 ), Shaded Ellipses( 0 ), Ellipse Color( 3 ) ),
    Partial Correlations( 1 )
);

rmv = Report( mv );

dtcorr = rmv["Correlations"][Matrix Box( 1 )] << make into data table;
dtpart = rmv["Partial Corr"][Matrix Box( 1 )] << make into data table;

stkcorr = dtcorr << Stack(
    columns( Eval( names ) ),
    Source Label Column( "Label" ),
    Stacked Data Column( "Data" )
);

stkpart = dtpart << Stack(
    columns( Eval( names ) ),
    Source Label Column( "Label" ),
    Stacked Data Column( "Data" )
);

Close( dtcorr, nosave );
Close( dtpart, nosave );

stkcorr << New Column( "DataSqr", formula( Data ^ 2 ) );
stkpart << New Column( "DataSqr", formula( Data ^ 2 ) );

sumsqrcorr = Col Sum( (stkcorr:"DataSqr") ) - nsel;
sumsqrpart = Col Sum( (stkpart:"DataSqr") );

MSA = sumsqrcorr / (sumsqrcorr + sumsqrpart);

//Show( MSA );

Summarize( bycorr = by( stkcorr:"Row" ), sumsqrcorrby = Sum( stkcorr:"DataSqr" ) );
Summarize( bypart = by( stkpart:"Row" ), sumsqrpartby = Sum( stkpart:"DataSqr" ) );

Close( stkcorr, nosave );
Close( stkpart, nosave );

//show(sumsqrcorrby, sumsqrpartby);
//show(bycorr, bypart);

sumsqrcorrby = sumsqrcorrby - 1;
//show(sumsqrcorrby);
MSAvar = {};
For( i = 1, i <= nsel, i++,
    MSAvar = sumsqrcorrby / (sumsqrcorrby + sumsqrpartby);
    //Show( bycorr, MSAvar );
);

sr = New Window( "Summary Results",
    V List Box(
        Table Box( String Col Box( "Variable", bycorr ), Number Col Box( "MSA", MSAvar ) ),
        Text Box( "Overall MSA = " || Char( round(MSA, 5) ) )
    )
);

 

View solution in original post

5 REPLIES 5
mpb
mpb
Level VII

Re: How to get Kaiser's MSA (aka KMO) in JMP's Factor analysis?

See if this code is helpful. I only was able to check it against the socioeconomic sample data and the results were same as the SAS results shown in the SAS docs online. Use at your own risk and certainly test on as many datasets as you have MSA results for.

 

 

/* Next line if want to open a specific JMP table */
//dt = Open( "$SAMPLE_DATA/Socioeconomic.jmp" );
/* Next line if want to have user pick a JMP data table */
//dt = Open();
/* No Open statement if want to run against the current data table */

cd = Column Dialog( Col ID = ColList( "Select Columns" ) );

names = cd["Col ID"];
nsel = N Items( names );

mv = Multivariate(
    Y( Eval( names ) ),
    Estimation Method( "Row-wise" ),
    Scatterplot Matrix( Density Ellipses( 1 ), Shaded Ellipses( 0 ), Ellipse Color( 3 ) ),
    Partial Correlations( 1 )
);

rmv = Report( mv );

dtcorr = rmv["Correlations"][Matrix Box( 1 )] << make into data table;
dtpart = rmv["Partial Corr"][Matrix Box( 1 )] << make into data table;

stkcorr = dtcorr << Stack(
    columns( Eval( names ) ),
    Source Label Column( "Label" ),
    Stacked Data Column( "Data" )
);

stkpart = dtpart << Stack(
    columns( Eval( names ) ),
    Source Label Column( "Label" ),
    Stacked Data Column( "Data" )
);

Close( dtcorr, nosave );
Close( dtpart, nosave );

stkcorr << New Column( "DataSqr", formula( Data ^ 2 ) );
stkpart << New Column( "DataSqr", formula( Data ^ 2 ) );

sumsqrcorr = Col Sum( (stkcorr:"DataSqr") ) - nsel;
sumsqrpart = Col Sum( (stkpart:"DataSqr") );

MSA = sumsqrcorr / (sumsqrcorr + sumsqrpart);

//Show( MSA );

Summarize( bycorr = by( stkcorr:"Row" ), sumsqrcorrby = Sum( stkcorr:"DataSqr" ) );
Summarize( bypart = by( stkpart:"Row" ), sumsqrpartby = Sum( stkpart:"DataSqr" ) );

Close( stkcorr, nosave );
Close( stkpart, nosave );

//show(sumsqrcorrby, sumsqrpartby);
//show(bycorr, bypart);

sumsqrcorrby = sumsqrcorrby - 1;
//show(sumsqrcorrby);
MSAvar = {};
For( i = 1, i <= nsel, i++,
    MSAvar = sumsqrcorrby / (sumsqrcorrby + sumsqrpartby);
    //Show( bycorr, MSAvar );
);

sr = New Window( "Summary Results",
    V List Box(
        Table Box( String Col Box( "Variable", bycorr ), Number Col Box( "MSA", MSAvar ) ),
        Text Box( "Overall MSA = " || Char( round(MSA, 5) ) )
    )
);

 

goutam
Level III

Re: How to get Kaiser's MSA (aka KMO) in JMP's Factor analysis?

The code worked like a charm!!! I ahev checked it on several data sets and results are identicla with what I get from running SAS. Thanks very much.

JMP folks (if you are listening in) - please incorporate this code/jsl in the next version of JMP as a red triangle option form multivariate correlation platform.

Jeff_Perkinson
Community Manager Community Manager

Re: How to get Kaiser's MSA (aka KMO) in JMP's Factor analysis?

We are working on adding this to JMP 16.
-Jeff
goutam
Level III

Re: How to get Kaiser's MSA (aka KMO) in JMP's Factor analysis?

I am using the same MSA script  posted in 2012. It worked well on earlier versions of JMP. But, on JMP Pro 15.1.0 the MSA calculations seem to be off. Can you please help? 

goutam
Level III

Re: How to get Kaiser's MSA (aka KMO) in JMP's Factor analysis?

Never mind! I made a mistake - it's running fine.