thusthe first column is always taken as an "interceptparameterunless otherwise specified to remove the intercept termadd - to the ols formulaas in ols(' ~ - 'for any linear modelthe model matrix can be retrieved via the constructionmodel_matrix pd dataframe(model exog,columns=model exog_nameslet us look at some examples of linear models in the first model the variables and are both considered (by pythonto be quantitative mydata pd dataframe ({' [ , , , , , ' [ , , , , , ' [ , , , , , ]}mod ols(" ~ + "datamydata mod_matrix pd dataframe (mod exog columns =mod exog_names print mod_matrix + intercept suppose the second variable is actually qualitativee it represents colorand the levels and stand for redblueand green we can account for such categorical variable by using the astype method to redefine the data type (see section mydata [' 'mydata [' 'astype ('category 'alternativelya categorical variable can be specified in the model formula by wrapping it with (observe how this changes the model matrix mod ols(" ~ + ( )"datamydata mod _matrix pd dataframe (mod exog columns =mod exog_names print mod _matrix intercept ( )[ ( )[ thusif statsmodels formula of the form ( contains factor (qualitativevariablesthe model is no longer of the form ( )but contains indicator variables for each level of the factor variableexcept the first level for the case abovethe corresponding linear model is yi xi {xi {xi ei ( where we have used parameters and to correspond to the indicator features of the qualitative variable the parameter describes how much the response is expected to