Skip to content
This repository has been archived by the owner on Jul 19, 2018. It is now read-only.

Possibility for adding a summary text for GWR diagnostics #5

Open
Ziqi-Li opened this issue Jan 16, 2018 · 2 comments
Open

Possibility for adding a summary text for GWR diagnostics #5

Ziqi-Li opened this issue Jan 16, 2018 · 2 comments

Comments

@Ziqi-Li
Copy link
Member

Ziqi-Li commented Jan 16, 2018

Like what statsmodel.OLS.fit.summary() does? Can follow GWR4's summary .txt.

@Ziqi-Li Ziqi-Li changed the title Possibility for adding a summary text for diagnostics Possibility for adding a summary text for GWR diagnostics Jan 16, 2018
@TaylorOshan
Copy link
Collaborator

Definitely possible. Might be helpful to use the summary statement that is available in some of the spreg functions. Running the following two stage least squares code example:

import numpy as np
import pysal
db = pysal.open(pysal.examples.get_path("columbus.dbf"), 'r')
y_var = 'CRIME'
y = np.array([db.by_col(y_var)]).reshape(49, 1)
x_var = ['INC']
x = np.array([db.by_col(name) for name in x_var]).T
yd_var = ['HOVAL']
yd = np.array([db.by_col(name) for name in yd_var]).T
q_var = ['DISCBD']
q = np.array([db.by_col(name) for name in q_var]).T
w = pysal.rook_from_shapefile(pysal.examples.get_path("columbus.shp"))
w.transform = 'r'
tsls = TSLS(y, x, yd, q, w=w, spat_diag=True, name_y=y_var, name_x=x_var,
                name_yend=yd_var, name_q=q_var, name_ds='columbus', name_w='columbus.gal')
print tsls.summary

produces the following output:

REGRESSION
----------
SUMMARY OF OUTPUT: TWO STAGE LEAST SQUARES
------------------------------------------
Data set            :    columbus
Weights matrix      :columbus.gal
Dependent Variable  :       CRIME                Number of Observations:          49
Mean dependent var  :     35.1288                Number of Variables   :           3
S.D. dependent var  :     16.7321                Degrees of Freedom    :          46
Pseudo R-squared    :      0.2794

------------------------------------------------------------------------------------
            Variable     Coefficient       Std.Error     z-Statistic     Probability
------------------------------------------------------------------------------------
            CONSTANT      88.4657958      15.1346096       5.8452645       0.0000000
                 INC       0.5200379       1.4146781       0.3676016       0.7131703
               HOVAL      -1.5821659       0.7931892      -1.9946891       0.0460768
------------------------------------------------------------------------------------
Instrumented: HOVAL
Instruments: DISCBD

DIAGNOSTICS FOR SPATIAL DEPENDENCE
TEST                           MI/DF       VALUE           PROB
Anselin-Kelejian Test             1           1.158          0.2820
================================ END OF REPORT =====================================

@ljwolf
Copy link
Member

ljwolf commented Jan 31, 2018

If you look into that summary-table-building code in spreg, it's.... a bit hairy. I'd highly recommend we try something like a jinja template rather than doing a ton of string munging.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants