where the {yi and {xi are given in table this is highly nonlinear optimization problemfor which standard nonlinear leastsquares methods do not work well insteadone can use global optimization methods such as ce and sco (see sections and using the ce methodwe found the minimal value for the objective functionwhich is attained at [ ] linear models in python in this section we describe how to define and analyze linear models using python and the data science module statsmodels we encourage the reader to regularly refer back to the theory in the preceding sections of this so as to avoid using python merely as black box without understanding the underlying principles to run the code start by importing the following code snippetimport matplotlib pyplot as plt import pandas as pd import statsmodels api as sm from statsmodels formula api import ols modeling although specifying normal linear model in python is relatively easyit requires some subtlety the main thing to realize is that python treats quantitative and qualitative (that iscategoricalexplanatory variables differently in statsmodelsordinary least-squares linear models are specified via the function ols (short for ordinary least-squaresthe main argument of this function is formula of the form xd( where is the name of the response variable and xd are the names of the explanatory variables if all variables are quantitativethis describes the linear model yi xi xi bd xid ei ( where xi is the -th explanatory variable for the -th observation and the errors ei are independent normal random variables such that eei and var ei orin matrix formy xb ewith and yn bd en xn xnd for the rest of this sectionwe assume all linear models to be normal