Split Linear Regression model by Categorical Variables.

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

Posts: 1
Joined: Thu Oct 19, 2017 5:24 pm

Split Linear Regression model by Categorical Variables.

Postby eamonn123 » 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
Posts: 1
Joined: Wed Jan 31, 2018 10:03 am

Re: Split Linear Regression model by Categorical Variables.

Postby johnbritt429 » Wed Jan 31, 2018 10:20 am

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: https://goo.gl/c4Yxrg

Who is online

Users browsing this forum: No registered users and 3 guests