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

Save residuals after OLS fit #117

Open
smmaurer opened this issue Oct 21, 2019 · 0 comments
Open

Save residuals after OLS fit #117

smmaurer opened this issue Oct 21, 2019 · 0 comments

Comments

@smmaurer
Copy link
Member

From @cvanoli:

Found a better way actually, since the fit function in the Regression Model in urbansim_templates uses the model_fit from urbansim.models, which at the same time, uses the statsmodels.regression.linear_model.OLSResults we can get the residuals from the fit object like the urbansim.models does here : https://github.com/UDST/urbansim/blob/master/urbansim/models/regression.py#L344.

So, I would suggest the following two lines to solve this:

  1. Add here https://github.com/UDST/urbansim_templates/blob/master/urbansim_templates/models/regression.py#L104 a self.residuals = None
  2. In the fit function after the fitted parameters: https://github.com/UDST/urbansim_templates/blob/master/urbansim_templates/models/regression.py#L192
    add self.residuals = results.resid

So in estimation, after you fit the model you can call the residuals as m.residuals

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

No branches or pull requests

1 participant