Page 1 of 1

Split Linear Regression model by Categorical Variables.

Posted: Thu Oct 19, 2017 5:35 pm
by eamonn123
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

Re: Split Linear Regression model by Categorical Variables.

Posted: Wed Jan 31, 2018 10:20 am
by johnbritt429
Getting the data into SPSS and creating the variables icolcat2 and icolcat3 from using reverse Helmert coding on collcat. Then running the regression using the newly created variables.

get file = "c:spssregelemapi2.sav".

compute icolcat2 = 0.
if (collcat=1) icolcat2 = -.5.
if (collcat=2) icolcat2 = .5.
compute icolcat3 = 2/3.
if (collcat=1) icolcat3 = -1/3.
if (collcat=2) icolcat3 = -1/3.

/dependent api00
/method = enter icolcat2 icolcat3 meals
/save pred(predict1) .

Learn More here: