cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar

Saving the prediction formula to an existing column?

Hi,

I'm a new JMP user. I have several prediction formula saved to columns, and other columns linked to those. Now I want to update the formulas (many) in the original prediction columns with the new regression formula. Saving the prediction formula seems only possible to a new appended column. I suppose I could copy the formula from the new column and paste into the original column, but it's tedious. Perhaps the whole thing can be scripted, like excel's macro recorder??

Anyway, thanks in advance :)
Dave
11 REPLIES 11
XanGregg
Staff

Re: Saving the prediction formula to an existing column?

It can be scripted with JSL, but there's nothing like a macro recorder for tasks like that. You could do something like the following:

f = column("prednew") << Get Formula;
column("predold") << Set Formula( Name Expr( f ));

Message was edited by: xan@jmp

Re: Saving the prediction formula to an existing column?

Where would I put that code? Does it work on the newest added column, or a column of a particular name?
XanGregg
Staff

Re: Saving the prediction formula to an existing column?

Put it in a script window and run it. Save it as a JSL file it you need it often. The given code has the column names built in. If you want the last column as the source, replace "prednew" with NCol().

Note I fixed an error in my previous post by adding Name Expr() to make sure the formula is not evaluated before it is added to the new column.

Re: Saving the prediction formula to an existing column?

Thanks.

Re: Saving the prediction formula to an existing column?

Hi,

Do you know how I can get the script to put the formula into a file as plain text?

Very appreciated,
Dave
XanGregg
Staff

Re: Saving the prediction formula to an existing column?

Once you have the formula in a column, you can get it out, convert it to text, and then save it in a file.

f = Column( "saved formula col" ) << get formula;
t = Char( Name Expr( f ));
Save Text File( "myformula.txt", t );

Re: Saving the prediction formula to an existing column?

Silly question, maybe, but...

How do I save a negative of the formula? i.e. formula * -1 ?

Re: Saving the prediction formula to an existing column?

one more question...how do I concatenate formulas into the single file?

Re: Saving the prediction formula to an existing column?

oncatenation of all formula seem to work like this:

t = "";
f = Column( "Pred Formula neg MxBmin" ) << get formula;
a = Char( Name Expr( f ));
t = Concat(t, a);

t = concat(t, "\!N");
t = concat(t, "\!N");
f = Column( "Pred Formula MxBmin" ) << get formula;
a = Char( Name Expr( f ));
t = Concat(t, a);

t = concat(t, "\!N");
t = concat(t, "\!N");
f = Column( "Pred Formula MxBmax" ) << get formula;
a = Char( Name Expr( f ));
t = Concat(t, a);

t = concat(t, "\!N");
t = concat(t, "\!N");
f = Column( "Pred Formula MrB" ) << get formula;
a = Char( Name Expr( f ));
t = Concat(t, a);

t = concat(t, "\!N");
t = concat(t, "\!N");
f = Column( "Pred Formula neg FzR0min" ) << get formula;
a = Char( Name Expr( f ));
t = Concat(t, a);

Save Text File( "myformula.txt", t );