Subscribe Bookmark RSS Feed

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
XanGregg

Staff

Joined:

Jun 23, 2011

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
Where would I put that code? Does it work on the newest added column, or a column of a particular name?
XanGregg

Staff

Joined:

Jun 23, 2011

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.
Thanks.
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

Joined:

Jun 23, 2011

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 );
Silly question, maybe, but...

How do I save a negative of the formula? i.e. formula * -1 ?
one more question...how do I concatenate formulas into the single file?
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 );