cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
yvesprairie
Level IV

Getting derivatives of a kernel smoother function

Hi again,

I am using the kernel smoother to estimate some values and sane the prediction formula in a new column. It works very well for my purpose .

<JSL> 

obj = dt_clean << Bivariate( Y( :temperature ), X( :Z_res ) ,by (:date),invisible);

obj << Kernel Smoother( 1, 1, .2, 0 );

obj << (curve[2] << Save Prediction Formula);

Now I need the derivative of this function at each point of the X variable. I can do it easily within the data table using the derivative function inside the formula editor. However, I need to do this within some JSL code. I have tried all sorts of syntax but to no avail. Any suggestions on how to do this within the community?

 

Many thanks for any help you can provide, Yves

 

 

 

3 REPLIES 3

Re: Getting derivatives of a kernel smoother function

You can call this function from JSL that surfaces the feature from the Formula Editor:

derivative function.png

yvesprairie
Level IV

Re: Getting derivatives of a kernel smoother function

Thank you Mark for your quick reply. I had played around with the above function but I finally managed to get it to work by first  getting the prediction formula into an expression and applying the derivative function to the name expression and then saving into a new column. For reference, here is the code. Thanks again!

formula_exp = column(4) << Get Formula;
der_expr=derivative( name expr(formula_exp), :Z_res) ;
dt_clean<< New Column( "Derivative", Formula(  Name expr(der_expr)));
hogi
Level XIII

Re: Getting derivatives of a kernel smoother function

wow, really nice, thank! 
: - )

hogi_0-1776230359059.png

 

 


Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );
gb = dt << Graph Builder(
	Size( 437, 413 ),
	Graph Spacing( 4 ),
	Variables( X( :height ), Y( :weight ), Overlay( :sex ) ),
	Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) )
);
	
gbb = Report(gb)[GraphBuilderBox(1)];
gbb << updateElement(1, 1, 2, {Save Formula});

nc= n cols(dt);

myFormula = column (dt,nc) << get formula;

Eval (Eval Expr(New Column( "derivative",
	Formula(
		f = As Constant(
			Derivative( Expr(Name Expr(myFormula)),:height	));
		f;
	),
)));


gb << Add Variable( {:derivative, Role( "Y" )} )

Recommended Articles