pysal.model.spreg.
SURerrorML
(bigy, bigX, w, regimes=None, nonspat_diag=True, spat_diag=False, vm=False, epsilon=1e07, name_bigy=None, name_bigX=None, name_ds=None, name_w=None, name_regimes=None)[source]¶User class for SUR Error estimation by Maximum Likelihood
Parameters: 


Examples
First import pysal.lib to load the spatial analysis tools.
>>> import pysal.lib
Open data on NCOVR US County Homicides (3085 areas) using pysal.lib.io.open(). This is the DBF associated with the NAT shapefile. Note that pysal.lib.io.open() also reads data in CSV format.
>>> db = pysal.lib.io.open(pysal.lib.examples.get_path("NAT.dbf"),'r')
The specification of the model to be estimated can be provided as lists. Each equation should be listed separately. Equation 1 has HR80 as dependent variable, and PS80 and UE80 as exogenous regressors. For equation 2, HR90 is the dependent variable, and PS90 and UE90 the exogenous regressors.
>>> y_var = ['HR80','HR90']
>>> x_var = [['PS80','UE80'],['PS90','UE90']]
>>> yend_var = [['RD80'],['RD90']]
>>> q_var = [['FP79'],['FP89']]
The SUR method requires data to be provided as dictionaries. PySAL provides the tool sur_dictxy to create these dictionaries from the list of variables. The line below will create four dictionaries containing respectively the dependent variables (bigy), the regressors (bigX), the dependent variables’ names (bigyvars) and regressors’ names (bigXvars). All these will be created from th database (db) and lists of variables (y_var and x_var) created above.
>>> bigy,bigX,bigyvars,bigXvars = pysal.model.spreg.sur_utils.sur_dictxy(db,y_var,x_var)
To run a spatial error model, we need to specify the spatial weights matrix. To do that, we can open an already existing gal file or create a new one. In this example, we will create a new one from NAT.shp and transform it to rowstandardized.
>>> w = pysal.lib.weights.Queen.from_shapefile(pysal.lib.examples.get_path("NAT.shp"))
>>> w.transform='r'
We can now run the regression and then have a summary of the output by typing: print(reg.summary)
Alternatively, we can just check the betas and standard errors, asymptotic t and pvalue of the parameters:
>>> reg = SURerrorML(bigy,bigX,w=w,name_bigy=bigyvars,name_bigX=bigXvars,name_ds="NAT",name_w="nat_queen")
>>> reg.bSUR
{0: array([[ 4.0222855 ],
[ 0.88489646],
[ 0.42402853]]), 1: array([[ 3.04923009],
[ 1.10972634],
[ 0.47075682]])}
>>> reg.sur_inf
{0: array([[ 0.36692181, 10.96224141, 0. ],
[ 0.14129077, 6.26294579, 0. ],
[ 0.04267954, 9.93517021, 0. ]]), 1: array([[ 0.33139969, 9.20106497, 0. ],
[ 0.13352591, 8.31094371, 0. ],
[ 0.04004097, 11.756878 , 0. ]])}
Attributes: 


__init__
(bigy, bigX, w, regimes=None, nonspat_diag=True, spat_diag=False, vm=False, epsilon=1e07, name_bigy=None, name_bigX=None, name_ds=None, name_w=None, name_regimes=None)[source]¶Initialize self. See help(type(self)) for accurate signature.
Methods
__init__ (bigy, bigX, w[, regimes, …]) 
Initialize self. 