cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
mkiesz
Level I

Using interaction effects in JSL fit model

Hi Community,

I'm try to create a script that dynamically creates a model with main effects and interactions.

 

For instance, I might have a subset of effect columns defined by the following:

 

 

all_cols = Current Data Table () << Get Column Names(String);
effect_cols = all_cols[3::8];

 

And then I build a series of models reducing the effect_cols.

Subsequently, I consider interaction terms. However, I'm having trouble building a list of column names or column references for interaction terms.

I've tried something like this:

if(length(effect_cols) > 1,
	interaction_effects = {};
	for(i = 1, i < length(effect_cols), i++,
		for(j=i+1,j<= length(effect_cols), j ++,
			inter_tmp = effect_cols[i] || "*" || effect_cols[j];
			interaction_effects = insert(interaction_effects,inter_tmp);
		)
	)
);

and building it into a model with this:

Fit Model(
		Y( :"Result"n ),
		Effects(
			concat(effect_cols,interaction_effects),
		Personality( "Standard Least Squares" ),
		Emphasis( "Effect Screening" ),
		Run(	),
)

However, this consistently gives an error and my other attempts at using parse() and eval() are not working. 

 

Any help is much appreciated.

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Using interaction effects in JSL fit model

If I remember correctly I have tried with something like this

 

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Tiretread.jmp");
effect_cols = {"SILICA", "HARDNESS", "SILANE", "SULFUR"};
terms = {};

For Each({first_term, idx}, effect_cols[1::N Items(effect_cols) - 1],
	For Each({second_term}, effect_cols[idx+1::N Items(effect_cols)],
		cur_interaction = Substitute(Expr(_firstterm_*_secondterm_),
			Expr(_firstterm_), NameExpr(AsColumn(first_term)),
			Expr(_secondterm_), NameExpr(AsColumn(second_term))
		);
		Insert Into(terms, Name Expr(cur_interaction));
	);
);

fitm = dt << Fit Model(
	Y(:ABRASION),
	Effects(Eval(terms)),
	Personality("Standard Least Squares"),
	Emphasis("Effect Screening")
);

jthi_0-1693121570938.png

 

 

-Jarmo

View solution in original post

2 REPLIES 2
ron_horne
Super User (Alumni)

Re: Using interaction effects in JSL fit model

Hi @mkiesz ,

did you try  to script the stepwise platform? it may have some of your model selection criteria built in.

 

jthi
Super User

Re: Using interaction effects in JSL fit model

If I remember correctly I have tried with something like this

 

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Tiretread.jmp");
effect_cols = {"SILICA", "HARDNESS", "SILANE", "SULFUR"};
terms = {};

For Each({first_term, idx}, effect_cols[1::N Items(effect_cols) - 1],
	For Each({second_term}, effect_cols[idx+1::N Items(effect_cols)],
		cur_interaction = Substitute(Expr(_firstterm_*_secondterm_),
			Expr(_firstterm_), NameExpr(AsColumn(first_term)),
			Expr(_secondterm_), NameExpr(AsColumn(second_term))
		);
		Insert Into(terms, Name Expr(cur_interaction));
	);
);

fitm = dt << Fit Model(
	Y(:ABRASION),
	Effects(Eval(terms)),
	Personality("Standard Least Squares"),
	Emphasis("Effect Screening")
);

jthi_0-1693121570938.png

 

 

-Jarmo