Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
altug_bayram
Level IV

Kendall's Tau from Formula

Hello 

 

I had some questions in a different thread regarding need to get linear fit slopes from a formula as opposed to a script. 

 

This question is similar. Is there a way to extract Kendall's Tau for a given time series parameter using a formula (and not using the multi-variate analysis or a script) ? 

 

My goal is to test the non-parametric trend for different time lengths that the data is produced from (i.e. would like to set rolling windows and then test Kendall's Tau) .  thanks ....

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
txnelson
Super User

Re: Kendall's Tau from Formula

Here is the calculation across all of the analysis columns in the data table, and placed into the rows of the calculated formula column.  The data table is attached, the formula is below

tau.PNG

Jim

View solution in original post

Highlighted
txnelson
Super User

Re: Kendall's Tau from Formula

When one uses JMP Platforms in a formula, just as when you use them interactively or in a script, the input to the Platform has to be columns from a data table.  Therefore, you can not reference the input by creating an input matrix.  So what I did to make your formula work, is to take advantage of being able to Exclude rows from the data table and when the platform is run, it will ignore those rows.  Here is the formula, and the output it creates:

dt = Current Data Table();
If( Row() >= 10,
	currentRow = Row();
	dt << clear rowstates;
	dt << select where( Row() <= currentRow - 10 | Row() > currentRow );
	excludeRows = dt << get selected rows;
	dt << hide and exclude;
	mv = dt << Multivariate(
		invisible,
		Y( :TimeStep, :F ),
		Estimation Method( "Row-wise" ),
		Matrix Format( "Square" ),
		Scatterplot Matrix( Density Ellipses( 0 ), Shaded Ellipses( 0 ) ),
		Kendall's τ( 1 )
	);
	tau = (Report( mv )["Nonparametric: Kendall's τ"][Number Col Box( 1 )] << get)[1];
	mv << close window;
	If( Row() == N Rows( dt ),
		dt << clear rowstates
	);
	tau;
);

The data table

movingtau.PNG

I suggest that once you have created the column, and it has run the formula, that you go to the Col Info dialog, and remove the formula.  It will leave the static values, but will not keep rerunning the formula over and over....it isn't the fastest

Jim

View solution in original post

5 REPLIES 5
Highlighted
txnelson
Super User

Re: Kendall's Tau from Formula

Here is the calculation across all of the analysis columns in the data table, and placed into the rows of the calculated formula column.  The data table is attached, the formula is below

tau.PNG

Jim

View solution in original post

Highlighted
altug_bayram
Level IV

Re: Kendall's Tau from Formula

hello 

Thanks for this great answer. This was actually a revelation for me because this showed that a formulae can contain script like structures, which was unknown to me . 

I accepted your solution but do need your help one more time.

Uploading a sample data set. 

My need of MK tau is on rows for  a single column. That is actually correctly done (my adaptation from your prior help) in col Tau_WholeData. 

What I am really trying to do is to get a trend of a single parameter in timesteps (temporal trend if you will). 

So I am trying to set a moving (rolling) window of size 10, start the window at row 10, and then move it by one record (row) - each time calculating MK Tau of the prior 10 rows . 

 

I did similar things w/ Index function (e.g. Index( Row() - 9, Row() )) for 10 rows and I tried 3-4 different options of placing this into the  Tau_WholeData formula - so far no success. 

 

I appreciate if you could let me know how I should change this. 

thanks ... 

 

 

Highlighted
altug_bayram
Level IV

Re: Kendall's Tau from Formula

Seeing your other answer on the linear slopes, I got  another idea of where to put the index for MK but did not work either. 

attached in my latest w/ that 5th attempt

Highlighted
txnelson
Super User

Re: Kendall's Tau from Formula

When one uses JMP Platforms in a formula, just as when you use them interactively or in a script, the input to the Platform has to be columns from a data table.  Therefore, you can not reference the input by creating an input matrix.  So what I did to make your formula work, is to take advantage of being able to Exclude rows from the data table and when the platform is run, it will ignore those rows.  Here is the formula, and the output it creates:

dt = Current Data Table();
If( Row() >= 10,
	currentRow = Row();
	dt << clear rowstates;
	dt << select where( Row() <= currentRow - 10 | Row() > currentRow );
	excludeRows = dt << get selected rows;
	dt << hide and exclude;
	mv = dt << Multivariate(
		invisible,
		Y( :TimeStep, :F ),
		Estimation Method( "Row-wise" ),
		Matrix Format( "Square" ),
		Scatterplot Matrix( Density Ellipses( 0 ), Shaded Ellipses( 0 ) ),
		Kendall's τ( 1 )
	);
	tau = (Report( mv )["Nonparametric: Kendall's τ"][Number Col Box( 1 )] << get)[1];
	mv << close window;
	If( Row() == N Rows( dt ),
		dt << clear rowstates
	);
	tau;
);

The data table

movingtau.PNG

I suggest that once you have created the column, and it has run the formula, that you go to the Col Info dialog, and remove the formula.  It will leave the static values, but will not keep rerunning the formula over and over....it isn't the fastest

Jim

View solution in original post

Highlighted
altug_bayram
Level IV

Re: Kendall's Tau from Formula

Jim 

This worked great. 

Only small issue is a warning w/ the use "Current Data Table" within a formulae. 

JMP throws a warning stating to use an Eval or Expr Eval function instead. 

I would likely activate and then deactivate this function after its done calculating. 

 

This has been great help. Thanks so much. 

 

Article Labels

    There are no labels assigned to this post.