Skip to content

Save residuals after OLS fit #117

@smmaurer

Description

@smmaurer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions