'remove data arrays, all nobs arrays from result and model
This reduces the size of the instance, so it can be pickled with less
memory. Currently tested for use with predict from an unpickled
results and model instance.
.. warning:: Since data and some intermediate results have been removed
calculating new statistics that require them will raise exceptions.
The exception will occur the first time an attribute is accessed
that has been set to None.
Not fully tested for time series models, tsa, and might delete too much
for prediction or not all that would be possible.
The lists of arrays to delete are maintained as attributes of
the result and model instance, except for cached values. These
lists could be changed before calling remove_data.
The attributes to remove are named in:
model._data_attr : arrays attached to both the model instance
and the results instance with the same attribute name.
result.data_in_cache : arrays that may exist as values in
result._cache (TODO : should privatize name)
result._data_attr_model : arrays attached to the model
instance but not to the results instance'

def remove_data(self):

    def wipe(obj, att):
        p = att.split('.')
        att_ = p.pop((-1))
        try:
            obj_ = reduce(getattr, ([obj] + p))
            if hasattr(obj_, att_):
                setattr(obj_, att_, None)
        except AttributeError:
            pass
    model_only = [('model.' + i) for i in getattr(self, '_data_attr_model', [])]
    model_attr = [('model.' + i) for i in self.model._data_attr]
    for att in ((self._data_attr + model_attr) + model_only):
        wipe(self, att)
    data_in_cache = getattr(self, 'data_in_cache', [])
    data_in_cache += ['fittedvalues', 'resid', 'wresid']
    for key in data_in_cache:
        try:
            self._cache[key] = None
        except (AttributeError, KeyError):
            pass
