change if the factor switches from level to similar interpretation holds for such parameters can thus be viewed as incremental effects it is also possible to model interaction between two variables for two continuous variablesthis simply adds the products of the original features to the model matrix adding interaction terms in python is achieved by replacing "+in the formula with "*"as the following example illustrates interaction mod ols(" ~ * ( )"datamydata mod _matrix pd dataframe (mod exog columns =mod exog_names print mod _matrix intercept ( )[ ( )[ : ( )[ : ( )[ analysis let us consider some easy linear regression models by using the student survey data set survey csv from the book' github sitewhich contains measurements such as heightweightsexetc from survey conducted among university students suppose we wish to investigate the relation between the shoe size (explanatory variableand the height (response variableof person firstwe load the data and draw scatterplot of the points (height versus shoe size)see figure (without the fitted linesurvey pd read_csv ('survey csv 'plt scatter survey shoe survey height plt xlabel ("shoe size"plt ylabel (height "we observe slight increase in the height as the shoe size increasesalthough this relationship is not very distinct we analyze the data through the simple linear regression model yi xi ei in statsmodels this is performed via the ols method as followsmodel ols(height ~shoe"datasurvey define the model fit model fit (#fit the model defined above fit params print (fit params intercept shoe dtype float the above output gives the least-squares estimates of and for this examplewe have and figure which includes the regression linewas obtained as follows