Thanks to visit codestin.com
Credit goes to github.com

Skip to content

spreg logic bug with rho outside |1| #243

@sjsrey

Description

@sjsrey

A user is running into the following error running the lag model:

/Users/serge/Dropbox/pysal/src/git/pysal/pysal/spreg/diagnostics_tsls.py in pr2_spatial(tslsreg)
    327     y = tslsreg.y
    328     predy_e = tslsreg.predy_e
--> 329     pr = pearsonr(y,predy_e)[0]
    330     pr2_result = float(pr**2)
    331     return pr2_result

AttributeError: 'NoneType' object has no attribute 'shape'

The original call was:

splagAll = ps.spreg.GM_Lag(y,x,w=w,name_y=y_name,name_x=x_names,name_w='1r',name_ds='data.txt')

In tracing this back it seems that in spreg/utils.py the function sp_att will return None, None if the estimate for rho is outside of |1|. This will cause the call in line 329 to fail since the second argument to pearsonr will be None.

We probably should raise a warning to the user about this since it likely points to a misspecification?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions