Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.

Selection alpha for stepwise regression


Is there a way when using the stepwise tool for logistic regression to adjust the alpha level (P-value) for inclusion/elimination of variables into the final model?  I am getting variables retained with p-values of more then 0.1 and would like to eliminate them from the model without having to manually go in and remove them.


Hey @WonderHog! I am not super familiar with the R tools in Alteryx, but I thought I would give this a shot.


If you right click on your Stepwise tool and click 'Open Macro' you can edit the way the tool works. My thought is to try changing the code in the first R tool within that Stepwise tool. A little more than halfway down in the code, under '#The selection criteria' you will see that a value of k is set to 2. Try changing that to 2.705543, as shown in the below picture.




If this doesn't work, maybe try attaching the workflow you are having troubles with, and I can take another look.


Hi Fireball.  Thanks for the response.  I found where to make the alteration to the R code, but when I went back to the workflow to run it, the code reverted to the original (k.val <- 2).  How do I save the changes so that it remains in the workflow?


p.s., Where does the "Magic number" of 2.705543 come from?




Hey @WonderHog. Did you make sure to save the modified macro by replacing the old one in C:\Program Files\Alteryx\R-3.3.2\Plugin\Macros\Predictive Tools\Stepwise.yxmc? Otherwise, if you do not want to (or can't) save over that one, you can save it either with a different name or to a different known location. Then try deleting the current Stepwise tool in your workflow and then right clicking on your canvas to Insert the macro you modified from the folder where you just saved it in. 


As far as the mysterious 2.705543 number, it is based on a chi-squared distribution with one degree of freedom.