Subscribe Bookmark RSS Feed

Automatically selecting radiobox and make model based on this selection

laurentvm

Community Trekker

Joined:

May 13, 2013

Hi,

I am trying to automating JMP for successive stepwise model fitting. However, after having ran an stepwise regression, I can not select the radiobox for selecting my list of effects and launch the make model.

In fact, I cam select the radio box, but the list of effects does not upadte and in the make model window, the construct model effects is empty.

Here is my script:

cwin = Current Window();//("Fit Stepwise 2");

  rbiv = cwin << report;

  sel = cwin[Radio Box( 2 )];

  sel << set( 4 ) << reshow;

  cwin << reshow;

Do you have any idea on how to automatically select the radiobox and launch the make model according to this choice ?ing

2 REPLIES
ms

Super User

Joined:

Jun 23, 2011

Try  <<Enter(Variable). The message must be sent to the stepwise object not to the rpoert window. However, the Enter message seems not to evaluate its argument so it requires a little string manipulation.

Here's an example:

Names Default To Here( 1 );

//Example table

dt = Open( "$SAMPLE_DATA/Fitness.jmp" );

obj = Fit Model(

  Y( :Oxy ),

  Effects( :Runtime, :Weight, :RunPulse, :RstPulse, :MaxPulse ),

  Personality( Stepwise ),

  Run

);

obj << Finish;

Wait( 1 );

obj << All Possible Models( 2, 2 ); //Only a subset here

// Make Model of all possible models...

cwin = Report( obj );

models = cwin[String Col Box( "Model" )];

sel = cwin[Radio Box( 2 )];

For( k = 1, k <= N Items( models << get ), k++,

  obj<<remove all; //Remove before running next model

  sel << set( k ); // Just cosmetic...

 

  vars = Words( models[k], "," ); // List of selected variables

  For( i = 1, i <= N Items( vars ), i++,

  Eval( Parse( Eval Insert( "obj<<enter(^vars^)" ) ) ) // Enter variable one at a time

  );

  (obj << make model) << run;

);

laurentvm

Community Trekker

Joined:

May 13, 2013

Thanks it is perfectly what I need and it works! However, still have some question about making this script "clever".

In your example, you are parsing the list of parameter without taking into account AIC, BIC values, entering sequentially the parameters. Would it be possible to get the list of parameters for a prescribed p or AIC, ... ?

Moreover, I have to take care that my parameters have weird names (e.g. using :Name("")) so I had to use some tricks to get the variables in the right syntax because I was launching :

1 stepwise

A second stepwise (All possible model) by limiting the number of parameters to 21 from previous one

Then, selecting the model based on Rsquare

Then make model least square

Here is the old code (without your proposal). Basically, I think that with your code, I can remove the second window coming from fit2/wdw, by direclty launching all possible models, but I need to limit the number of parameter based on p for example.

Finally, do you know how to clear memory after all these steps to relaunch for another Y ?

Many thanks

obj_expr = Expr(

  manObj = Fit Model(

  Y,

  Effects,

  Personality( Stepwise ),

  Run( Stopping Rule( "P-value Threshold" ) )

  )

);

...

FIRST STEPWISE

y = Eval( colListY << GetItems );//print(y);

x = Eval( colListX << GetItems );//print(x);

  y = Regex( Char( y ), "\{(.+)\}", "\1" );

  x = Regex( Char( x ), "\{(.+)\}", "\1" );

  Substitute Into( obj_expr, Expr( Y ), Parse( "Y( (" || y || "))" ) );

  Substitute Into( obj_expr,

  Expr( Effects ),

  Parse( "Effects( response surface(" || x || "))" )

  );

  obj_expr;

  manObj<< Finish;

HERE SHOULD SELECT A SUBSET TO MAKE ALL POSS.

  fit2 = manObj << Make Model;

  wdw = Window( "Stepped Model" );

  param = wdw[ListBoxBox( 6 )] << GetItems;

  manObj << close window;

SECOND STEPWISE (here is the trick to get back :Name * :Name (cross products, second order response surface)

  liste = List();

  For( i = 1, i <= N Items( param ), i++,

  liste = param

  );

  //Print( liste );

  For( i = 1, i <= N Items( liste ), i++,

  x = liste;

  x = Concat( ":Name(\!"", x );

  x = Concat( x, "\!")" );

  x = Substitute( x, "*", "\!")*:Name(\!"" );

  x = Substitute( x, "\!"", "\!"" );

  liste = Parse( x );

  );

Fit Model(

  Y( Eval( wdw[ListBoxBox( 2 )] << GetItems ) ),

  Effects( Eval( liste ) ),

  Personality( Stepwise ),

  Run(

  Stopping Rule( "P-value Threshold" ),

  All Possible Models( 8, 56 )

  )

  );