BookmarkSubscribe
Choose Language Hide Translation Bar
Reinaldo
Community Trekker

Re: Doesn't JMP contain Goodman-Kruskal gamma coefficient (or correlation) on its stats package?

The JMP community has a lot of information. Is this JMP Addin can be found in the URL https://community.jmp.com/t5/JMP-Add-Ins/The-JMP-to-R-Add-In-Builder/ta-p/43879 ?

It seems this JMP Add-in runs in Windows only, doesn't it?

Tnx, Jim!

~Rei
0 Kudos
txnelson
Super User

Re: Doesn't JMP contain Goodman-Kruskal gamma coefficient (or correlation) on its stats package?

You are correct.  The JMP to R Addin Builder only works in Windows.  However, JMP supports an interface to R.  So you can run your R code from your JMP session under Mac.

Jim
Reinaldo
Community Trekker

Re: Doesn't JMP contain Goodman-Kruskal gamma coefficient (or correlation) on its stats package?

When you tell me "run your R code from JMP session under Mac", what do you mean about 'JMP session'? Does it refer to create and run a script? Tnx

~Rei
0 Kudos
txnelson
Super User

Re: Doesn't JMP contain Goodman-Kruskal gamma coefficient (or correlation) on its stats package?

The JMP to R interface allows for a JMP script to pass to R JMP data tables, lists, matrices, etc. along with R programming statments,  to R for porcessing and then retrieve the results back to JMP once the R processing has been completed.

See:

     Help==>Books==Scripting Guide==>Working with R

A Bootstrap Sample

See the file JMPtoR_bootstrap.jsl in the sample scripts folder for an example script. This script performs a bootstrap simulation by using the JMP to R Project integration. The script produces a JMP window that asked the user to specify the variable to perform bootstrapping over. Then the user selects a statistic to compute for each bootstrap sample. Finally, the data is sent to R using the R interface in JSL. The boot package in R is used to call the boot() function and the boot.ci() function to calculate the sample statistic for each bootstrap sample and the bootstrap confidence interval. The results are brought back to JMP and displayed using the JMP Distribution platform.

/* 
This script performs a bootstrap simulation by using the JMP to R Project integration.
A JMP Dialog is built where the variable you wish to perform bootstrapping over can be specified.
A statistic to compute for each bootstrap sample is chosen and the data are sent to R using new
JSL functionality available in JMP 9. 

The boot package in R is used to call the boot() function and the boot.ci() function to 
calculate the sample statistic for each bootstrap sample and the bootstrap confidence interval.
 
The results are brought back to JMP and displayed using the JMP Distribution platform.
*/

Names Default To Here( 1 );

StatList = {"Mean", "20% Trimmed Mean", "Median", "Standard Deviation", "Variance",
"Median Absolute Deviation (MAD)"};
RFunctionList = {"mean", "mean", "median", "sd", "var", "mad"};

//Generate Normal(0,1) data;
zmat = J( 50, 1, Random Normal() );
dt = New Table( "Normal(0,1) Random Data",
	New Column( "Normal Data", Numeric, <<Set Values( zmat ) )
);


bd = Column Dialog(
	Bootvar_CL = ColList( "Column to Bootstrap",
		Min Col( 1 ),
		Max Col( 1 ),
		DataType( Numeric )
	),
	VList(
		"Bootstrap Statistic to Compute",
		Bootstat_RB = RadioButtons( StatList ),
		HList( "Number of Replications", Reps_N = EditNumber( 100 ) ),
		NA_CB = Check Box( "Exclude Missing Values", 0 )
	)
);

//Get values from Column Dialog;
Bootvar = bd["Bootvar_CL"];
StatLoc = bd["Bootstat_RB"];
NReps = Floor( bd["Reps_N"] );
If( NReps <= 1,
	Throw( "Invalid Number of Replications" )
);
ExcludeNA = bd["NA_CB"];

bv_mat = Column( Bootvar[1] ) << Get As Matrix;
RFunc = RFunctionList[StatLoc];
Stat_Label = StatList[StatLoc];
If( StatLoc == 2,
	trimm = ",trim = .1",
	trimm = ""
);  //option for trimmed mean in R mean function;
If( ExcludeNA == 1,
	na = "TRUE",
	na = "FALSE"
);

//submit to R;
R Init();
R Send( bv_mat );
R Submit(
	Eval Insert(
		"\[
	library(boot)								# Load Boot package
	RStatFctn <- function(x,d) {            	# Build Function for bootsrapping statistic
		return(^RFunc^(x[d] ^trimm^, na.rm = ^na^))
	}
	b <- boot(bv_mat, RStatFctn, R = ^NReps^)  	#Call Bootstrap function
	b.ci=boot.ci(b, conf = 0.95, type="basic")  #call Boostrap CI function
	b.ciout = b.ci$basic[,4:5]
	#plot(b)                                    #uncomment this if you want the R graphic
	]\"
	)
);
b_mat = R Get( b$t );
b_ci = R Get( b.ciout );
boot_dt = New Table( "Bootstrap Samples",
	New Column( Stat_Label, Numeric, <<Set Values( b_mat ) )
);

nw = New Window( Eval Insert( "Bootstrap Results for ^Stat_Label^" ),
	Distribution( Stack( 1 ), Continuous Distribution( Column( 1 ) ) ),
	Panel Box( "Bootstrap 95% Confidence Interval",
		Lineup Box(
			Number Col Box( "Lower Bound", Matrix( Round( b_ci[1], 2 ) ) ),
			Number Col Box( "Upper Bound", Matrix( Round( b_ci[2], 2 ) ) )
		)
	)
);

 

Jim