Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constant check #766

Merged
merged 4 commits into from Apr 1, 2016
Merged

Constant check #766

merged 4 commits into from Apr 1, 2016

Conversation

TaylorOshan
Copy link
Contributor

Noticed that when I tried to manually add a constant I wasn't getting the appropriate exception. For instance, model1 below works (no manual constant) but model2 throws a singular matrix error (because of the manual constant and automatic constant) instead of the expected "x array cannot contain a constant vector; constant will be added automatically".

import numpy as np
from pysal.spreg.ols import OLS
import pysal

db = pysal.open(pysal.examples.get_path('columbus.dbf'),'r')
y = np.array(db.by_col("HOVAL"))
y = np.reshape(y, (49,1))
X = []
X.append(db.by_col("INC"))
X.append(db.by_col("CRIME"))
X1 = np.array(X).T
X2 = np.hstack((np.ones(y.shape),X1))

model1 = OLS(y, X1)
model2 = OLS(y, X2)

It looks like the constant_check function is missing its input of 'x' and to obtain the correct behavior the 'not' should be removed from the if statement as well.

It was suggested that I tag a spreg developer pertaining to this potential bug. @pedrovma @darribas

@sjsrey sjsrey merged commit 9f60e11 into pysal:dev Apr 1, 2016
sjsrey added a commit to sjsrey/pysal that referenced this pull request Apr 1, 2016
sjsrey added a commit to sjsrey/pysal that referenced this pull request Apr 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants