<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Using interaction effects in JSL fit model in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Using-interaction-effects-in-JSL-fit-model/m-p/671409#M85941</link>
    <description>&lt;P&gt;Hi Community,&lt;/P&gt;&lt;P&gt;I'm try to create a script that dynamically creates a model with main effects and interactions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For instance, I might have a subset of effect columns defined by the following:&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;all_cols = Current Data Table () &amp;lt;&amp;lt; Get Column Names(String);
effect_cols = all_cols[3::8];&lt;/CODE&gt;&lt;/PRE&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;And then I build a series of models reducing the effect_cols.&lt;/P&gt;&lt;P class=""&gt;Subsequently, I consider interaction terms. However, I'm having trouble building a list of column names or column references for interaction terms.&lt;/P&gt;&lt;P class=""&gt;I've tried something like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;if(length(effect_cols) &amp;gt; 1,
	interaction_effects = {};
	for(i = 1, i &amp;lt; length(effect_cols), i++,
		for(j=i+1,j&amp;lt;= length(effect_cols), j ++,
			inter_tmp = effect_cols[i] || "*" || effect_cols[j];
			interaction_effects = insert(interaction_effects,inter_tmp);
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P class=""&gt;and building it into a model with this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Fit Model(
		Y( :"Result"n ),
		Effects(
			concat(effect_cols,interaction_effects),
		Personality( "Standard Least Squares" ),
		Emphasis( "Effect Screening" ),
		Run(	),
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P class=""&gt;However, this consistently gives an error and my other attempts at using parse() and eval() are not working.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
    <pubDate>Fri, 25 Aug 2023 18:40:29 GMT</pubDate>
    <dc:creator>mkiesz</dc:creator>
    <dc:date>2023-08-25T18:40:29Z</dc:date>
    <item>
      <title>Using interaction effects in JSL fit model</title>
      <link>https://community.jmp.com/t5/Discussions/Using-interaction-effects-in-JSL-fit-model/m-p/671409#M85941</link>
      <description>&lt;P&gt;Hi Community,&lt;/P&gt;&lt;P&gt;I'm try to create a script that dynamically creates a model with main effects and interactions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For instance, I might have a subset of effect columns defined by the following:&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;all_cols = Current Data Table () &amp;lt;&amp;lt; Get Column Names(String);
effect_cols = all_cols[3::8];&lt;/CODE&gt;&lt;/PRE&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;And then I build a series of models reducing the effect_cols.&lt;/P&gt;&lt;P class=""&gt;Subsequently, I consider interaction terms. However, I'm having trouble building a list of column names or column references for interaction terms.&lt;/P&gt;&lt;P class=""&gt;I've tried something like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;if(length(effect_cols) &amp;gt; 1,
	interaction_effects = {};
	for(i = 1, i &amp;lt; length(effect_cols), i++,
		for(j=i+1,j&amp;lt;= length(effect_cols), j ++,
			inter_tmp = effect_cols[i] || "*" || effect_cols[j];
			interaction_effects = insert(interaction_effects,inter_tmp);
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P class=""&gt;and building it into a model with this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Fit Model(
		Y( :"Result"n ),
		Effects(
			concat(effect_cols,interaction_effects),
		Personality( "Standard Least Squares" ),
		Emphasis( "Effect Screening" ),
		Run(	),
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P class=""&gt;However, this consistently gives an error and my other attempts at using parse() and eval() are not working.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 25 Aug 2023 18:40:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-interaction-effects-in-JSL-fit-model/m-p/671409#M85941</guid>
      <dc:creator>mkiesz</dc:creator>
      <dc:date>2023-08-25T18:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: Using interaction effects in JSL fit model</title>
      <link>https://community.jmp.com/t5/Discussions/Using-interaction-effects-in-JSL-fit-model/m-p/671476#M85947</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/41845"&gt;@mkiesz&lt;/a&gt; ,&lt;/P&gt;
&lt;P&gt;did you try&amp;nbsp; to script the stepwise platform? it may have some of your model selection criteria built in.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Aug 2023 15:30:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-interaction-effects-in-JSL-fit-model/m-p/671476#M85947</guid>
      <dc:creator>ron_horne</dc:creator>
      <dc:date>2023-08-26T15:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using interaction effects in JSL fit model</title>
      <link>https://community.jmp.com/t5/Discussions/Using-interaction-effects-in-JSL-fit-model/m-p/671534#M85950</link>
      <description>&lt;P&gt;If I remember correctly I have tried with something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;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 &amp;lt;&amp;lt; Fit Model(
	Y(:ABRASION),
	Effects(Eval(terms)),
	Personality("Standard Least Squares"),
	Emphasis("Effect Screening")
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1693121570938.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/56029iA9C64D45F28BE910/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1693121570938.png" alt="jthi_0-1693121570938.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Aug 2023 07:33:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-interaction-effects-in-JSL-fit-model/m-p/671534#M85950</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-08-27T07:33:22Z</dc:date>
    </item>
  </channel>
</rss>

