Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Regress all combinations of two cities out of 50

Trey1
7 - Meteor

Hi,

 

I have a list of sales data by major US city by week and am trying to find those cities in which sales week over week changes are most correlated. I want to do this with a simple linear regression for each pair of cities). So, I am trying to make a loop that will regress each city on each of the other 49 cities (minus duplicates) to give me the R^2 in a table which I can sort to find the highest R^2.

 

I have read about using a batch macro, an iterative macro, the step wise tool, the iterative tool, or the dynamic selection tool, and am not sure exactly which tool is best. I would appreciate any help!

 

EDIT: Including dummy data for clarity:

WeekNew YorkSan FranciscoLos AngelesHoustonChicago
185%10%84%67%14%
284%52%79%53%79%
399%27%48%1%50%
439%75%79%14%79%
572%62%100%79%41%
657%97%30%63%89%
727%64%79%89%86%
871%34%14%39%26%

 

All combinations of regressions:

YX
New YorkChicago
New YorkHouston
New YorkLos Angeles
New YorkSan Francisco
San FranciscoChicago
San FranciscoHouston
San FranciscoLos Angeles
Los AngelesChicago
Los AngelesHouston
HoustonChicago

 

I created the attached macro to loop through regressors, but I can't figure out how to then change the dependent variable and loop for additional regressors.

 

Thank you,

Trey

1 REPLY 1
Trey1
7 - Meteor

I solved this by:

 

Joining the list of cities on itself,

removing duplicate pairs,

splitting the pairs across two columns

creating a macro that feeds in one column for indep and one column for dep variables

 

Labels