Our World Statistics Day conversations have been a great reminder of how much statistics can inform our lives. Do you have an example of how statistics has made a difference in your life? Share your story with the Community!
Choose Language Hide Translation Bar
Highlighted
frits_quadt
Level I

How can I parse effects to "Fit Model" in a script?

I am trying to pars effects to a fit model in a script. 

The effects are generated by a script using several runs of stepwise selection using nominal logistic regression. The selected variable names are outputted to a JMP datafile "final selection.jmp".

This is no problem if only main effects are selected, but I have not been successful in including a two factor interaction.

 

For main effects only I used the following script: 

 

 

Basedata=concat( projectpath, "final selection.jmp");
dt = OPEN(basedata);
myparameters = :Parameter << Get Values();
close(dt,nosave);

sdt = Open(concat(projectpath, "all data.jmp"));
UseEffects = {};
For (ii = 1, ii <= NItems(myparameters), ii++,
   colname = myparameters[ii];
   col = Column(sdt, colname);
   InsertInto(UseEffects, col)
  );
Fit Model(
 Y( :Y ),
 Effects( Eval(UseEffects)),
 Personality( "Nominal Logistic" ),
 Run( Likelihood Ratio Tests( 1 ), Wald Tests( 0 ), Confusion Matrix( 1 ) )
);

 

 

Using the same script if an interaction is selected results in an error message "could not find column ..."

 

I then tried the following script to generate an array with effects:

For (ii = 1, ii <= NItems(myparameters), ii++,
   colname = myparameters[ii];
   position = contains(colname,"*");
   If (position > 0,
   col = ":"||left(colname,position)||" :"||right(colname,length(colname)-position),
   col = ":"||colname);
   /*col = Column(sdt, colname);*/
   InsertInto(UseEffects, col)
  );

 

Although the effect names in UseEffects look ok, this also fails and gives again a "Column not found ... " error.

 

Any solution is welcome.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: How can I parse effects to "Fit Model" in a script?

I think you might need to use JSL expressions for this. Below is an example similar to yours using the Boston Housing sample data table:

 

myparameters = {"crim*zn", "zn", "indus", "nox", "rooms", "age", "distance"};

sdt = Open("$SAMPLE_DATA/Boston Housing.jmp");

EffectsExpr = Expr(Effects());

For (ii = 1, ii <= NItems(myparameters), ii++,
	colname = myparameters[ii];
	position = contains(colname,"*");
	If (position > 0,
		col = ":"||left(colname,position)||" :"||right(colname,length(colname)-position),
		col = ":"||colname
	);
	/*col = Column(sdt, colname);*/
	InsertInto(EffectsExpr, parse(col))
);

fmExpr = substitute(
	Expr(Fit Model(
	 Y( :chas ),
	 _effects_,
	 Personality( "Nominal Logistic" ),
	 Run( Likelihood Ratio Tests( 1 ), Wald Tests( 0 ), Confusion Matrix( 1 ) )
	)),
	expr(_effects_),
	nameexpr(EffectsExpr)
);

eval(fmExpr)
Michael Crotty
Sr Statistical Writer
JMP Development

View solution in original post

2 REPLIES 2
Highlighted

Re: How can I parse effects to "Fit Model" in a script?

I think you might need to use JSL expressions for this. Below is an example similar to yours using the Boston Housing sample data table:

 

myparameters = {"crim*zn", "zn", "indus", "nox", "rooms", "age", "distance"};

sdt = Open("$SAMPLE_DATA/Boston Housing.jmp");

EffectsExpr = Expr(Effects());

For (ii = 1, ii <= NItems(myparameters), ii++,
	colname = myparameters[ii];
	position = contains(colname,"*");
	If (position > 0,
		col = ":"||left(colname,position)||" :"||right(colname,length(colname)-position),
		col = ":"||colname
	);
	/*col = Column(sdt, colname);*/
	InsertInto(EffectsExpr, parse(col))
);

fmExpr = substitute(
	Expr(Fit Model(
	 Y( :chas ),
	 _effects_,
	 Personality( "Nominal Logistic" ),
	 Run( Likelihood Ratio Tests( 1 ), Wald Tests( 0 ), Confusion Matrix( 1 ) )
	)),
	expr(_effects_),
	nameexpr(EffectsExpr)
);

eval(fmExpr)
Michael Crotty
Sr Statistical Writer
JMP Development

View solution in original post

Highlighted
frits_quadt
Level I

Re: How can I parse effects to "Fit Model" in a script?

Thank you, I have used the solution you described and it did solve my problem.

 

 

Article Labels

    There are no labels assigned to this post.