statsmodels/statsmodels — Issue #95: check pickling result instances
Author: josef-pkt
Created: 2011-10-29 12:35:05+00:00
State: open
Labels: design, pandas-integration

As an example I tried to pickle example_discrete multinomial logit results, but I get

```
Traceback (most recent call last):
File "E:\Josef\eclipsegworkspace\statsmodels-git\statsmodels-josef\scikits\statsmodels\examples\example_discrete_mnl.py", line 51, in
mnl_res_l = pickle.load(open('mnl_res.dump', 'r'))
File "C:\Python26\lib\pickle.py", line 1370, in load
return Unpickler(file).load()
File "C:\Python26\lib\pickle.py", line 858, in load
dispatch[key](self)
File "C:\Python26\lib\pickle.py", line 1224, in load_build
inst.__dict__.update(state)
File "e:\josef\eclipsegworkspace\statsmodels-git\statsmodels-josef\scikits\statsmodels\base\wrapper.py", line 24, in __getattribute__
results = get('_results')
File "e:\josef\eclipsegworkspace\statsmodels-git\statsmodels-josef\scikits\statsmodels\base\wrapper.py", line 23, in
get = lambda name: object.__getattribute__(self, name)
AttributeError: 'DiscreteResultsWrapper' object has no attribute '_results'
```

run the following after running example_discrete for the data and mlogit_mod:

```
import pickle

mnl_res = mlogit_mod.fit(method='bfgs', maxiter=100)
mnl_res.cov_params()
#mnl_res.model.endog = None
#mnl_res.model.exog = None
pickle.dump(mnl_res, open('mnl_res.dump', 'w'))
mnl_res_l = pickle.load(open('mnl_res.dump', 'r'))
```

similar deepcopy doesn't work with ResettableCache (will be new ticket)

```
#copy.deepcopy(mlogit_res)
#raises exception: AttributeError: 'ResettableCache' object has no attribute '_resetdict'
```