# How to write regression equation for logistic regression model based on categorical data

Here's an example of a formula: Intelligence ~ SEX + AGE + SCHOOLING

How would I write out the regression equation for the above if for example schooling had 3 categories? E.g. High School, Undergraduate, Postgraduate, as well as SEX with 2 categories? E.g. Male, Female.

• Welcome to CV! This can be done using a design matrix, or if you want to avoid linear algebra, by using $k-1$ dummy variables (see e.g. en.wikipedia.org/wiki/Dummy_variable_(statistics)#ANCOVA_models), where $k$ is the number of categories of the variable. Commented Oct 24, 2018 at 6:00

Because you said logistic regression, assume intelligence has two level: high and low.

Define: $$Y = 1$$ if intelligence is high, = 0 otherwise

$$X_1 = 1$$ for male, = 0 for female

$$X_2 = \text{age}$$

$$X_3 = 1$$ for High school, = 0 for other school

$$X_4 = 1$$ for Undergraduate, = 0 for other school

The model is: $$\log\left(\frac {\pi}{1-\pi}\right) = \beta_0 + \beta_1X_1 + \beta_2X_2 + \beta_3X_3 +\beta_4X_4,$$ where $$\Pr(Y=1) = \pi$$.