Getting derivatives of a kernel smoother functionHi 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 .
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
Automation and ScriptingRe: Getting derivatives of a kernel smoother functionYou can call this function from JSL that surfaces the feature from the Formula Editor:

Re: Getting derivatives of a kernel smoother functionThank 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)));
Re: Getting derivatives of a kernel smoother functionwow, really nice, thank!
: - )

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" )} )