### Split Linear Regression model by Categorical Variables.

Posted:

**Thu Oct 19, 2017 5:35 pm**Ok probably didn't explain it well in the title.

But lets say I have two numeric variables, a dependent and independent (say Y and X), but there is a third categorical variable which divides the data into subgroups(Lets say by gender, coded as female = 0, male = 1). So I'm fine with running a linear regression model and just put in X and Y. But lets say instead of getting a model for all the data, I want one model for males and one for females. Just wondering what would be the best way to go about it. (obviously right now I could just create a different sheet for males and females, but presumably there's an easy way if the data is all in one sheet). Thanks in advance

But lets say I have two numeric variables, a dependent and independent (say Y and X), but there is a third categorical variable which divides the data into subgroups(Lets say by gender, coded as female = 0, male = 1). So I'm fine with running a linear regression model and just put in X and Y. But lets say instead of getting a model for all the data, I want one model for males and one for females. Just wondering what would be the best way to go about it. (obviously right now I could just create a different sheet for males and females, but presumably there's an easy way if the data is all in one sheet). Thanks in advance