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
Anders_M
Level I

How to write a script for selecting several columns (>1000) in a data table as input for an Analysis (e.g. inverse correlations)

Hi I am new to JSL and would like to make a script for selecting multiple columns (>1000) and to use them an input for analysis. For example using the Mulitvariate analysis tool and calculating the inverse correlation.
I have made a script for selecting two columns for Bivariate analysis but how to extend it for multiple columns as used in e.g Mulitvariate analysis. 

 

I have tried to find clues at this forum but I do something wrong and I am stuck. I would be very greatful if someone could help me with this. 

 

Best Regards /Anders 

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
xvar = .;
yvar = .;
win = New Window( "Example of Returning Values",
	<<Modal,
	Text Box( " Select numeric columns. " ),
	H List Box(
		Text Box( " X, Factor " ),
		x = Col List Box(
			dt, // data table reference
			all, // display all columns from the data table
 
// get the name of the selected column before the window closes

			xvar = (x << Get Selected)[1];
			Show( xvar );
			
		),
		Text Box( "Y, Response" ),
		y = Col List Box(
			dt,
			all,
			yvar = (y << Get Selected)[1];
			Show( yvar );
		)
	)
);
If (win["Button"] == 1, // if the user clicks OK...
xcol = Column( dt, xvar ); //  get the columns
ycol = Column( dt, yvar );


dt << Bivariate( Y( ycol ), X( xcol ) ); // create a Bivariate plot
//dt << Multivariate( Y(ycol), Inverse Correlations(1)); // create a Inverse Correlation Matris
// How to select several columns as input for Multivariate ( Y(???), Inverse Correlations(1));
);
Anders Mannelqvist
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to write a script for selecting several columns (>1000) in a data table as input for an Analysis (e.g. inverse correlations)

You were headed in the right direction.  Your original script limited the Yvar to only 1 variable, and so by removing that restriction it lets one choose multiple variables, which then are transferred as a list to the Multivariate input.

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
xvar = .;
yvar = .;
win = New Window( "Example of Returning Values",
	<<Modal,
	Text Box( " Select numeric columns. " ),
	H List Box(
		
		Text Box( "Y, Response" ),
		y = Col List Box(
			dt,
			all,
			yvarList = (y << Get Selected);
			Show( yvarList );
		)
	)
);
If( win["Button"] == 1, // if the user clicks OK...
	Multivariate(
		Y( Eval( yvarList ) ),
		Estimation Method( "Row-wise" ),
		Scatterplot Matrix( 1 ),
		Inverse Correlations( 1 )
	)
);
Jim

View solution in original post

5 REPLIES 5
txnelson
Super User

Re: How to write a script for selecting several columns (>1000) in a data table as input for an Analysis (e.g. inverse correlations)

You were headed in the right direction.  Your original script limited the Yvar to only 1 variable, and so by removing that restriction it lets one choose multiple variables, which then are transferred as a list to the Multivariate input.

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
xvar = .;
yvar = .;
win = New Window( "Example of Returning Values",
	<<Modal,
	Text Box( " Select numeric columns. " ),
	H List Box(
		
		Text Box( "Y, Response" ),
		y = Col List Box(
			dt,
			all,
			yvarList = (y << Get Selected);
			Show( yvarList );
		)
	)
);
If( win["Button"] == 1, // if the user clicks OK...
	Multivariate(
		Y( Eval( yvarList ) ),
		Estimation Method( "Row-wise" ),
		Scatterplot Matrix( 1 ),
		Inverse Correlations( 1 )
	)
);
Jim
jthi
Super User

Re: How to write a script for selecting several columns (>1000) in a data table as input for an Analysis (e.g. inverse correlations)

You could also take a look at Column Dialog instead of building modal new window. Depending on the level of customization you need, it might be simpler to use.

 

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Solubility.jmp");
colDiag = Column Dialog(y = ColList("Y", Data Type("Numeric")));
dt << Multivariate(Y(colDiag["y"]));
-Jarmo
txnelson
Super User

Re: How to write a script for selecting several columns (>1000) in a data table as input for an Analysis (e.g. inverse correlations)

I like this a lot!

Jim
Anders_M
Level I

Re: How to write a script for selecting several columns (>1000) in a data table as input for an Analysis (e.g. inverse correlations)

Thanks Jarmo.

A good suggestion for lower level of customization and simpler use. /Anders 

Anders Mannelqvist
Anders_M
Level I

Re: How to write a script for selecting several columns (>1000) in a data table as input for an Analysis (e.g. inverse correlations)

Thanks, that's a very simple way! 

Anders Mannelqvist