# Linear Regression and Interaction Variables

I'm working with some turnstile data.

My factor variables are day of week (e.g, Monday - Sunday) and binned hour of day (e.g, 4, 8, 12, 16, 20, 00).

My question is straight forward:

To create a set of simple interaction variables (a la Python Scikitlearn PolynomialFactors) is it best to:

1. Change day labels to integers and multiply by the numerically represented hour of day bins?

2. Change day labels to integers, then one hot encode both the days of week and hours of day, then determine the interaction variables?

3. Does it matter whether I use 1 or 2?

I'm thinking #2. But I only understand it on an intuitive level. It seems, using that one hot encoding both sets of factor variables and then running them through PolynomialFactors yields observations that are in dummy variable form and take into consideration both sets of factor variables as well as interacting variables. Can someone confirm?

I would think #1 is NOT the way to go about creation of interaction variables in this case because the digitized days (0-6) and bins (0, 4, 8, 12, 16, 20) would imply hierarchy and multiplying the two sets directly would provide unwanted weights when creating the interaction variables.

Hoping someone can confirm or correct my insights and provide some more color into the creation of interaction variables.

Thank you.

Yet, this procedure avoids one danger when working with categorical variables. If the variables are coded in a way as proposed by you, say Monday to Sunday are coded with the integers 1 to 7, then you have a numerical relationship that 2 $\times$ Monday = Tuesday which you probably don't want to have.