<?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 Re: Adding/removing effects in stepwise regression via JSL and column number/name in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Adding-removing-effects-in-stepwise-regression-via-JSL-and/m-p/54304#M30688</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/11486"&gt;@pedbundoc&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Welcome to the community and good luck on your thesis.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unlike other dialog inputs, the Effects input is not just a list of columns.&amp;nbsp; You also specify higher order effercts in that argument.&amp;nbsp; You can build the list of effects using things like "column(1), column(2), column(3), column(1)*column(2), column(2)*column(2)" etc.&amp;nbsp; Also, you cannot (I believe) specify multiple indices&amp;nbsp;within the&amp;nbsp;Column() function in any scenario.&amp;nbsp; A better solution would be to get a list of column references and subset the list using your column indices like so:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();
all_cols = dt &amp;lt;&amp;lt; Get Column Reference();

//let's say factors are columns 2-4
effect_cols = all_cols[2::4];&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Now, JMP doesn't seem to like letting me just insert the variable effect_cols directly as the Effects argument for the Fit Model script.&amp;nbsp; It looks for a column named "effect_cols" rather than evaluating the list.&amp;nbsp; Therefore, you parse the Fit Model script from a string where we substitute in the evaluation of effect_cols like so:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Step_Str = "\[step = dt &amp;lt;&amp;lt; Fit Model(
	Y( Column(5) ),
	Effects(
		^effect_cols^
	),
	Personality( "Stepwise" ),
	Run
);]\";

eval(parse(eval insert(Step_Str)));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This should work for you if you only have main effects.&amp;nbsp;&amp;nbsp;Otherwise, you'll have to be a bit more creative.&amp;nbsp; Still totally do-able.&lt;/P&gt;&lt;P&gt;Now, for the issue of removing effects.&amp;nbsp; Remove is only going to work if you give it a string argument matching the names of&amp;nbsp;one of the effects.&amp;nbsp; You can use an eval(parse(eval insert())) sequence like we did before to parse a string where we sub in a variable containing the effect name we want to remove.&amp;nbsp; Here's an example where I take the effect with the largest p-value and remove it:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//Get a reference to the report window containing the stepwise object
step_rprt = step &amp;lt;&amp;lt; Report;

//get the term names and current p-values from Current Estimates
terms = step_rprt["Current Estimates"][StringColBox(1)] &amp;lt;&amp;lt; Get;
pvals = step_rprt["Current Estimates"][NumberColBox(5)] &amp;lt;&amp;lt; Get;

//Remove Intercept from each
remove from(terms,1); //remove intercept
remove from(pvals,1); //remove p-value for intercept

max_index = Contains(pvals, max(pvals)); //get index of max p-value

//create an expression to remove the term with the largest p-value
remove_worst = parse(eval insert("\[step &amp;lt;&amp;lt; Remove("^terms[max_index]^");]\"));

//Evaluate the expression
eval(remove_worst);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hope that helps!&lt;/P&gt;</description>
    <pubDate>Mon, 02 Apr 2018 17:59:24 GMT</pubDate>
    <dc:creator>cwillden</dc:creator>
    <dc:date>2018-04-02T17:59:24Z</dc:date>
    <item>
      <title>Adding/removing effects in stepwise regression via JSL and column number/name</title>
      <link>https://community.jmp.com/t5/Discussions/Adding-removing-effects-in-stepwise-regression-via-JSL-and/m-p/54277#M30672</link>
      <description>&lt;P&gt;Hi everyone!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really need help on this because I'm using JMP and JSL for my thesis. I am current using JMP via JSL to analyze some data, and my focus is stepwise regression. I'll have some code snippets attached by the way for ease in helping.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1.) How to add multiple effects on the initial model via column number?&lt;/P&gt;&lt;P&gt;Currently, I can set Y using only the column number I want, but I can't add X's using the column number.&lt;/P&gt;&lt;P&gt;I want it to go from this&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;obj = dt &amp;lt;&amp;lt; Fit Model(Y(:Column Name(i)),
Effects(
:Effect1Name, :Effect2Name, /*and so on and so forth*/
),
Personality(Stepwise), Run Model(Stopping Rule(MinimumBIC))
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;to this&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;obj = dt &amp;lt;&amp;lt; Fit Model(Y(:Column Name(i)),
Effects(
:Column(/*indices of columns to place as effects*/)
),
Personality(Stepwise), Run Model(Stopping Rule(MinimumBIC))
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2.) How to remove effects that are least significant?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;After running the original script, I see that some effects are not really that significant. The default scripting will be to use&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;obj &amp;lt;&amp;lt; Remove(:/*hardcoded column name*/);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;but I want it to be flexible so I can automate it so that it looks like this&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;obj &amp;lt;&amp;lt; Remove(:Column Name(indextoremove));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;but the above snippet produces this error message&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Term not found in access or evaluation of 'Column Name' , Column Name/*###*/(indextoremove)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Apr 2018 11:52:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Adding-removing-effects-in-stepwise-regression-via-JSL-and/m-p/54277#M30672</guid>
      <dc:creator>pedbundoc</dc:creator>
      <dc:date>2018-04-02T11:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: Adding/removing effects in stepwise regression via JSL and column number/name</title>
      <link>https://community.jmp.com/t5/Discussions/Adding-removing-effects-in-stepwise-regression-via-JSL-and/m-p/54304#M30688</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/11486"&gt;@pedbundoc&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Welcome to the community and good luck on your thesis.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unlike other dialog inputs, the Effects input is not just a list of columns.&amp;nbsp; You also specify higher order effercts in that argument.&amp;nbsp; You can build the list of effects using things like "column(1), column(2), column(3), column(1)*column(2), column(2)*column(2)" etc.&amp;nbsp; Also, you cannot (I believe) specify multiple indices&amp;nbsp;within the&amp;nbsp;Column() function in any scenario.&amp;nbsp; A better solution would be to get a list of column references and subset the list using your column indices like so:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();
all_cols = dt &amp;lt;&amp;lt; Get Column Reference();

//let's say factors are columns 2-4
effect_cols = all_cols[2::4];&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Now, JMP doesn't seem to like letting me just insert the variable effect_cols directly as the Effects argument for the Fit Model script.&amp;nbsp; It looks for a column named "effect_cols" rather than evaluating the list.&amp;nbsp; Therefore, you parse the Fit Model script from a string where we substitute in the evaluation of effect_cols like so:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Step_Str = "\[step = dt &amp;lt;&amp;lt; Fit Model(
	Y( Column(5) ),
	Effects(
		^effect_cols^
	),
	Personality( "Stepwise" ),
	Run
);]\";

eval(parse(eval insert(Step_Str)));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This should work for you if you only have main effects.&amp;nbsp;&amp;nbsp;Otherwise, you'll have to be a bit more creative.&amp;nbsp; Still totally do-able.&lt;/P&gt;&lt;P&gt;Now, for the issue of removing effects.&amp;nbsp; Remove is only going to work if you give it a string argument matching the names of&amp;nbsp;one of the effects.&amp;nbsp; You can use an eval(parse(eval insert())) sequence like we did before to parse a string where we sub in a variable containing the effect name we want to remove.&amp;nbsp; Here's an example where I take the effect with the largest p-value and remove it:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//Get a reference to the report window containing the stepwise object
step_rprt = step &amp;lt;&amp;lt; Report;

//get the term names and current p-values from Current Estimates
terms = step_rprt["Current Estimates"][StringColBox(1)] &amp;lt;&amp;lt; Get;
pvals = step_rprt["Current Estimates"][NumberColBox(5)] &amp;lt;&amp;lt; Get;

//Remove Intercept from each
remove from(terms,1); //remove intercept
remove from(pvals,1); //remove p-value for intercept

max_index = Contains(pvals, max(pvals)); //get index of max p-value

//create an expression to remove the term with the largest p-value
remove_worst = parse(eval insert("\[step &amp;lt;&amp;lt; Remove("^terms[max_index]^");]\"));

//Evaluate the expression
eval(remove_worst);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hope that helps!&lt;/P&gt;</description>
      <pubDate>Mon, 02 Apr 2018 17:59:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Adding-removing-effects-in-stepwise-regression-via-JSL-and/m-p/54304#M30688</guid>
      <dc:creator>cwillden</dc:creator>
      <dc:date>2018-04-02T17:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: Adding/removing effects in stepwise regression via JSL and column number/name</title>
      <link>https://community.jmp.com/t5/Discussions/Adding-removing-effects-in-stepwise-regression-via-JSL-and/m-p/54343#M30706</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/8582"&gt;@cwillden&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for replying! You have greatly resolved my first concern (adding multiple effects)!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On the second concern, I am already able to remove the term with the largest p-value. However, I believe it is not the criteria I am using to remove a term.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I am doing (if I am doing this on a point-and-click method and not scripting) is:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Load the table.&lt;/LI&gt;&lt;LI&gt;Run the Fit Model module&lt;BR /&gt;&lt;OL&gt;&lt;LI&gt;Add the Y, and X's.&lt;/LI&gt;&lt;LI&gt;Select stepwise regression&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;Build the model. (Click on Go)&lt;/LI&gt;&lt;LI&gt;Click on Run to display the Report.&lt;/LI&gt;&lt;LI&gt;Go to the Parameter estimates table.&lt;/LI&gt;&lt;LI&gt;Inspect and remove terms based on the Prob&amp;gt;|t|.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I believe the code you sent was removing terms based on the Prob&amp;gt;F of the Current Estimates table of the Fit Stepwise window. What I want to do is remove terms based on the Prob&amp;gt;|t| of the Parameter Estimates table of the Report: Fit Model window.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again, thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 05:16:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Adding-removing-effects-in-stepwise-regression-via-JSL-and/m-p/54343#M30706</guid>
      <dc:creator>pedbundoc</dc:creator>
      <dc:date>2018-04-03T05:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: Adding/removing effects in stepwise regression via JSL and column number/name</title>
      <link>https://community.jmp.com/t5/Discussions/Adding-removing-effects-in-stepwise-regression-via-JSL-and/m-p/54355#M30713</link>
      <description>&lt;P&gt;Hi again&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/8582"&gt;@cwillden&lt;/a&gt;!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I changed something in my code, inspired by what I was previously doing and in conjuction with your code snippet. And now, it works!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks you very much!&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 10:33:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Adding-removing-effects-in-stepwise-regression-via-JSL-and/m-p/54355#M30713</guid>
      <dc:creator>pedbundoc</dc:creator>
      <dc:date>2018-04-03T10:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Adding/removing effects in stepwise regression via JSL and column number/name</title>
      <link>https://community.jmp.com/t5/Discussions/Adding-removing-effects-in-stepwise-regression-via-JSL-and/m-p/208480#M41895</link>
      <description>&lt;PRE class=" language-jsl"&gt;&lt;CODE class="  language-jsl"&gt;&lt;SPAN class="token string"&gt;^effect_cols^ doesnt&amp;nbsp;appear&amp;nbsp;to&amp;nbsp;work&amp;nbsp;within&amp;nbsp;eval(parse(eval insert(Step_Str)));&amp;nbsp;as&amp;nbsp;the&amp;nbsp;brackets "{"&amp;nbsp;of&amp;nbsp;the&amp;nbsp;list&amp;nbsp;still&amp;nbsp;exist.&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 May 2019 18:02:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Adding-removing-effects-in-stepwise-regression-via-JSL-and/m-p/208480#M41895</guid>
      <dc:creator>jamescultra</dc:creator>
      <dc:date>2019-05-15T18:02:30Z</dc:date>
    </item>
  </channel>
</rss>

