cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar

How do I define effect columns once in a variable for use in model?

Hi everyone-

I am losing my mind trying to figure this out. I believe the answer lies in some magical combination of Eval() and Expr() but I can't figure it out. 

I have a list of columns I want to define at the beginning of the script and then reference for use as model effects, as shown below. How do I get the model to recognize the list as a list of columns to use as effects? Thank you!

 

JMP 19.1.0

dt = Current Data Table();
effect_list = {:run date, :reader, :sample bank, :plate dispense system, :dil_2_bot cap, :dil_2_bottle, :dil_2_nacl, :dil_2_proclin};

Local( {obj},
obj = dt << Fit Model(
Y( :manual result 34.2),
Effects( effect_list),
Target Level( "neg" ),
Personality( "Nominal Logistic" ),
Run( Likelihood Ratio Tests( 1 ), Wald Tests( 0 ) ),
By( :genotype )
);

 

1 ACCEPTED SOLUTION

Accepted Solutions
MathStatChem
Level VII

Re: How do I define effect columns once in a variable for use in model?

this can be tricky.  Here is one way to do it:

effect_list = {:run date, :reader, :sample bank, :plate dispense system, :dil_2_bot cap, :dil_2_bottle, :dil_2_nacl, :dil_2_proclin};


eff_expr=expr(Effects());

for each({effect, i}, effect_list, 
	Insert Into(eff_expr, name expr(effect))
);

Substitute(
		Expr(Fit Model(
			Y( :manual result 34.2 ),
			EEE,
			Target Level( "neg" ),
			Personality( "Nominal Logistic" ),
			Run( Likelihood Ratio Tests( 1 ), Wald Tests( 0 ) ),
			By( :genotype )
		)),
	Expr( EEE ), Name Expr( eff_expr )
);

 

View solution in original post

3 REPLIES 3
MathStatChem
Level VII

Re: How do I define effect columns once in a variable for use in model?

this can be tricky.  Here is one way to do it:

effect_list = {:run date, :reader, :sample bank, :plate dispense system, :dil_2_bot cap, :dil_2_bottle, :dil_2_nacl, :dil_2_proclin};


eff_expr=expr(Effects());

for each({effect, i}, effect_list, 
	Insert Into(eff_expr, name expr(effect))
);

Substitute(
		Expr(Fit Model(
			Y( :manual result 34.2 ),
			EEE,
			Target Level( "neg" ),
			Personality( "Nominal Logistic" ),
			Run( Likelihood Ratio Tests( 1 ), Wald Tests( 0 ) ),
			By( :genotype )
		)),
	Expr( EEE ), Name Expr( eff_expr )
);

 

Re: How do I define effect columns once in a variable for use in model?

This worked- thank you!

jthi
Super User

Re: How do I define effect columns once in a variable for use in model?

I'm not sure if Fit Model would work with Effects({columns}) (some platforms do) but it is safer to get rid of the list -> you can build the Effects part as an expression.

Here is one one more option

dt = Current Data Table();
effect_list = {:run date, :reader, :sample bank, :plate dispense system, :dil_2_bot cap, :dil_2_bottle,
:dil_2_nacl, :dil_2_proclin};

effect_expr = Substitute(effect_list, List(), Expr(Effects))

obj = Eval(EvalExpr(
	dt << Fit Model(
		Y(:manual result 34.2),
		Expr(NameExpr(effect_expr)),
		Target Level("neg"),
		Personality("Nominal Logistic"),
		Run(Likelihood Ratio Tests(1), Wald Tests(0)),
		By(:genotype)
	);	
));
-Jarmo

Recommended Articles