Subscribe Bookmark RSS Feed

Extracting VIP vs Coefficients for Centered and Scaled Data

matteo_patelmo

Community Trekker

Joined:

Dec 23, 2015

Hello, I would like to extract, in a data table, the values for VIP and Coefficients for Centered and Scaled Data from the PLS output window.

 

Is this possible through JSL?

 

thanks
Matteo

1 ACCEPTED SOLUTION

Accepted Solutions
stan_koprowski

Community Manager

Joined:

Aug 8, 2012

Solution

Hi,

 

I think this will do you what you want.

You can find the report section of any output by right-clicking and select Edit-->Show Tree Structure.

 

I used the Baltic sample table for this example.

 

Edit--Show Tree StructureEdit--Show Tree StructureTableBox(7)  VIP tableTableBox(7) VIP table

I joined the tables using Tables --> JMP Query Builder.

 

Here is the full script.

 

Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Baltic.jmp" );
P = Partial Least Squares(
	Y( :ls, :ha, :dt ),
	X(
		:v1,
		:v2,
		:v3,
		:v4,
		:v5,
		:v6,
		:v7,
		:v8,
		:v9,
		:v10,
		:v11,
		:v12,
		:v13,
		:v14,
		:v15,
		:v16,
		:v17,
		:v18,
		:v19,
		:v20,
		:v21,
		:v22,
		:v23,
		:v24,
		:v25,
		:v26,
		:v27
	),
	Validation Method( Name( "Leave-One-Out" ), Initial Number of Factors( 15 ) ),
	Fit(
		Method( NIPALS ),
		Number of Factors( 7 ),
		Variable Importance Plot( 1 ),
		VIP vs Coefficients Plots( 1 )
	),
	SendToReport(
		Dispatch(
			{"NIPALS Fit with 7 Factors"},
			"Model Coefficients for Centered and Scaled Data",
			OutlineBox,
			{Close( 0 )}
		),
		Dispatch(
			{"NIPALS Fit with 7 Factors", "Variable Importance Plot"},
			"Variable Importance Table",
			OutlineBox,
			{Close( 0 )}
		)
	)
);

pls_rpt = p << report; //Get the report
//Find the specific section of report by right-clicking Edit-->show properties

//pls_rpt[Outline Box( 9 )] << Close;  //Close the outline box; for example
//pls_rpt[Outline Box( 12 )] << Close; //Close the outline box; not necessary

coef_tbl = pls_rpt[Table Box( 5 )];
VIP_tbl = pls_rpt[Table Box( 7 )];
coef_tbl << Make Into Data Table(Invisible);
tbl_1# = Current Data Table()<< Set Name("Coefficients_Tbl");

VIP_tbl<<Make Into Data Table(Invisible);
tbl_2# = Current Data Table()<< Set Name("VIP_Tbl");

New SQL Query(
	Version( 130 ),
	Connection( "JMP" ),
	JMP Tables( ["Coefficients_Tbl" => "_MEMORY_", "VIP_Tbl" => "_MEMORY_"] ),
	QueryName( "SQLQuery2" ),
	Select(
		Column( "VIP", "t1", Numeric Format( "Fixed Dec", "4", "NO", "" ) ),
		Column( "Coefficient", "t2" ),
		Column( "ls", "t2", Numeric Format( "Fixed Dec", "4", "NO", "" ) ),
		Column( "ha", "t2", Numeric Format( "Fixed Dec", "4", "NO", "" ) ),
		Column( "dt", "t2", Numeric Format( "Fixed Dec", "4", "NO", "" ) )
	),
	From(
		Table( "VIP_Tbl", Alias( "t1" ) ),
		Table(
			"Coefficients_Tbl",
			Alias( "t2" ),
			Join(
				Type( Left Outer ),
				EQ( Column( "X", "t1" ), Column( "Coefficient", "t2" ) )
			)
		)
	)
) << Run;

Close( tbl_1#, NoSave );
Close( tbl_2#, NoSave );

 

Cheers,

Stan

 

7 REPLIES
M_Anderson

Staff

Joined:

Nov 21, 2014

Sure. Find the object for the table in the Tree Structure for the report. Send that object the "Make Into Data Table()" command. It will create a new data table with the information. Search for the "Make Into Data Table()" command in the scripting index for an example of the coding.

M
matteo_patelmo

Community Trekker

Joined:

Dec 23, 2015

Hello Mike, thanks. In the tree structure I was able to identify a tablebox with coefficients but not the VIPs.  It looks like the table behind the framebox containing the VIP vs coefficients is not accessible.

 

 

M_Anderson

Staff

Joined:

Nov 21, 2014

You have to right click on the table and select Columns > VIF for the VIF’s to show up. This will also show the command necessary to see them using JSL (Show the VIF column, then copy script to script window under the red triangle).

M
matteo_patelmo

Community Trekker

Joined:

Dec 23, 2015

Actually I was looking for VIP , not VIF, under PLS platform. I've not been able to find a table containing both VIP and coefficients.

 

In any case I think I figured out a workaround. Coefficients and VIPs are in two separate table boxes, so I will just extract them separately.

 

thanks

Matteo

matteo_patelmo

Community Trekker

Joined:

Dec 23, 2015

Hello Mike, thanks. In the tree structure I was able to identify a tablebox with just coefficients but not the VIPs, in a sibling outlinebox.

 

I cannot find any table associated with the framebox I would like to extract data from (VIP vs coefficients).

 

thanks
Matteo

 

 

 

 

 

stan_koprowski

Community Manager

Joined:

Aug 8, 2012

Solution

Hi,

 

I think this will do you what you want.

You can find the report section of any output by right-clicking and select Edit-->Show Tree Structure.

 

I used the Baltic sample table for this example.

 

Edit--Show Tree StructureEdit--Show Tree StructureTableBox(7)  VIP tableTableBox(7) VIP table

I joined the tables using Tables --> JMP Query Builder.

 

Here is the full script.

 

Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Baltic.jmp" );
P = Partial Least Squares(
	Y( :ls, :ha, :dt ),
	X(
		:v1,
		:v2,
		:v3,
		:v4,
		:v5,
		:v6,
		:v7,
		:v8,
		:v9,
		:v10,
		:v11,
		:v12,
		:v13,
		:v14,
		:v15,
		:v16,
		:v17,
		:v18,
		:v19,
		:v20,
		:v21,
		:v22,
		:v23,
		:v24,
		:v25,
		:v26,
		:v27
	),
	Validation Method( Name( "Leave-One-Out" ), Initial Number of Factors( 15 ) ),
	Fit(
		Method( NIPALS ),
		Number of Factors( 7 ),
		Variable Importance Plot( 1 ),
		VIP vs Coefficients Plots( 1 )
	),
	SendToReport(
		Dispatch(
			{"NIPALS Fit with 7 Factors"},
			"Model Coefficients for Centered and Scaled Data",
			OutlineBox,
			{Close( 0 )}
		),
		Dispatch(
			{"NIPALS Fit with 7 Factors", "Variable Importance Plot"},
			"Variable Importance Table",
			OutlineBox,
			{Close( 0 )}
		)
	)
);

pls_rpt = p << report; //Get the report
//Find the specific section of report by right-clicking Edit-->show properties

//pls_rpt[Outline Box( 9 )] << Close;  //Close the outline box; for example
//pls_rpt[Outline Box( 12 )] << Close; //Close the outline box; not necessary

coef_tbl = pls_rpt[Table Box( 5 )];
VIP_tbl = pls_rpt[Table Box( 7 )];
coef_tbl << Make Into Data Table(Invisible);
tbl_1# = Current Data Table()<< Set Name("Coefficients_Tbl");

VIP_tbl<<Make Into Data Table(Invisible);
tbl_2# = Current Data Table()<< Set Name("VIP_Tbl");

New SQL Query(
	Version( 130 ),
	Connection( "JMP" ),
	JMP Tables( ["Coefficients_Tbl" => "_MEMORY_", "VIP_Tbl" => "_MEMORY_"] ),
	QueryName( "SQLQuery2" ),
	Select(
		Column( "VIP", "t1", Numeric Format( "Fixed Dec", "4", "NO", "" ) ),
		Column( "Coefficient", "t2" ),
		Column( "ls", "t2", Numeric Format( "Fixed Dec", "4", "NO", "" ) ),
		Column( "ha", "t2", Numeric Format( "Fixed Dec", "4", "NO", "" ) ),
		Column( "dt", "t2", Numeric Format( "Fixed Dec", "4", "NO", "" ) )
	),
	From(
		Table( "VIP_Tbl", Alias( "t1" ) ),
		Table(
			"Coefficients_Tbl",
			Alias( "t2" ),
			Join(
				Type( Left Outer ),
				EQ( Column( "X", "t1" ), Column( "Coefficient", "t2" ) )
			)
		)
	)
) << Run;

Close( tbl_1#, NoSave );
Close( tbl_2#, NoSave );

 

Cheers,

Stan

 

matteo_patelmo

Community Trekker

Joined:

Dec 23, 2015

Thanks!

 

Matteo