cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Have your say in shaping JMP's future by participating in the new JMP Wish List Prioritization Survey
Choose Language Hide Translation Bar
Arthur
Level II

How to Pass Variables to the X Parameter in Fit Life by X?

Hi everyone,

 

I need to dynamically pass variables to the X parameter in the fit life by x function. The first part of my code generates the analysis report as expected, but the second part only brings up the startup window without a report.

Here’s what my code looks like:

Names Default To Here(1);

dt = Open( "$sample_data/big class.jmp" );

x_var = "sex";
y_var = "weight";

obj1 = dt << Fit Life by X(
	Distribution( Weibull ),
	Nested Model Tests( Location and Scale ),
	Y( Eval(y_var) ),
	X( :sex ),
);

wait(2);

obj2 = dt << Fit Life by X(
	Distribution( Weibull ),
	Nested Model Tests( Location and Scale ),
	Y( :weight ),
	X( Eval(x_var) ),
);

Has anyone encountered this issue or knows how to correctly pass the variables to the X parameter?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
peng_liu
Staff

Re: How to Pass Variables to the X Parameter in Fit Life by X?

Please see the following.

Because "Relationship" is missing, the codes is trying to make the best guess based on X. But at the place where the codes checks on X, X is not a valid column yet, in this case. So, providing complete information, the codes don't need to walk into the trap.

 

Names Default To Here(1);

dt = Open( "$sample_data/big class.jmp" );

x_var = "sex";
y_var = "weight";

obj1 = dt << Fit Life by X(
	Distribution( Weibull ),
	Relationship( Location and Scale ),
	Nested Model Tests( Location and Scale ),
	Y( Eval(y_var) ),
	X( :sex ),
);

wait(2);

obj2 = dt << Fit Life by X(
	Distribution( Weibull ),
	Relationship( Location and Scale ),
	Nested Model Tests( Location and Scale ),
	Y( :weight ),
	X( Eval(x_var) ),
);

View solution in original post

5 REPLIES 5

Re: How to Pass Variables to the X Parameter in Fit Life by X?

This anomaly appears to be a bug. The Nested Model Tests argument is not recognized in the second case. Please report this to JMP Technical Support (support@jmp.com) so it can be entered as a defect and tracked.

jthi
Super User

Re: How to Pass Variables to the X Parameter in Fit Life by X?

This seems to require a bit more work to workaround as "normal" forcing won't work

Names Default To Here(1);

dt = Open("$sample_data/big class.jmp");

x_var = "sex";
y_var = "weight";

myexpr = EvalExpr(dt << Fit Life by X(
	Distribution( Weibull ),
	Nested Model Tests( Location and Scale ),
	Y( :weight ),
	X(Expr(NameExpr(AsColumn(dt, x_var)))),
));
show(myexpr);
obj = Eval(myexpr);

 

One of the extremely rare cases where I would say to use Eval(Parse()) (evil parse) but this seems to work

Names Default To Here(1);

dt = Open("$sample_data/big class.jmp");

x_var = "sex";
y_var = "weight";

obj2 = Eval(Parse(Eval Insert("\[dt << Fit Life by X(
	Distribution(Weibull),
	Nested Model Tests(Location and Scale),
	Y(:weight),
	X(:^x_var^)
)]\")));
-Jarmo
Arthur
Level II

Re: How to Pass Variables to the X Parameter in Fit Life by X?

This is another workaround as well. Thank you!

peng_liu
Staff

Re: How to Pass Variables to the X Parameter in Fit Life by X?

Please see the following.

Because "Relationship" is missing, the codes is trying to make the best guess based on X. But at the place where the codes checks on X, X is not a valid column yet, in this case. So, providing complete information, the codes don't need to walk into the trap.

 

Names Default To Here(1);

dt = Open( "$sample_data/big class.jmp" );

x_var = "sex";
y_var = "weight";

obj1 = dt << Fit Life by X(
	Distribution( Weibull ),
	Relationship( Location and Scale ),
	Nested Model Tests( Location and Scale ),
	Y( Eval(y_var) ),
	X( :sex ),
);

wait(2);

obj2 = dt << Fit Life by X(
	Distribution( Weibull ),
	Relationship( Location and Scale ),
	Nested Model Tests( Location and Scale ),
	Y( :weight ),
	X( Eval(x_var) ),
);
Arthur
Level II

Re: How to Pass Variables to the X Parameter in Fit Life by X?

Oh, this is exactly the right answer. Thank you very much!