cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

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

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 )
);

 

2 REPLIES 2
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 )
);

 

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