ChadFulton / tsa-notebooks

Jupyter notebooks on time series econometrics topics.
274 stars 173 forks source link

2nd bug on Implementing and estimating an ARMA(1, 1) state space model #13

Open jasepark2 opened 5 years ago

jasepark2 commented 5 years ago

after modification it works well upto page 3 but I had another bug on prediction/forecasts due to depreciation of ix and I modified .ix to .loc but the plot still looks no lower and upper bound.

Third bug happened when I tried Metropolis-Hastings-ARIMA (1,1) and for some reason I had problem with installation with pymc nonetheless of my successful records on installation with pip.

However, Gibbs codes run well.

My last bug was found at the last box titled "Construct the predictions / forecasts" This is same as my second bug and I had no lower and upper bound line on my plot and followings are error message for your information.

Happy New Year and thanks for your excellent implementation on MCMC and TSA.

KeyError Traceback (most recent call last) C:\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance) 3062 try: -> 3063 return self._engine.get_loc(key) 3064 except KeyError:

pandas_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'lower CPIAUCNS'

During handling of the above exception, another exception occurred:

KeyError Traceback (most recent call last)

in () 15 alpha=0.15) 16 lines, = ax.plot(forecast.index, forecast) ---> 17 ax.fill_between(forecast.index, ci['lower CPIAUCNS'], ci['upper CPIAUCNS'], 18 alpha=0.2) 19 C:\Anaconda3\lib\site-packages\pandas\core\frame.py in __getitem__(self, key) 2683 return self._getitem_multilevel(key) 2684 else: -> 2685 return self._getitem_column(key) 2686 2687 def _getitem_column(self, key): C:\Anaconda3\lib\site-packages\pandas\core\frame.py in _getitem_column(self, key) 2690 # get column 2691 if self.columns.is_unique: -> 2692 return self._get_item_cache(key) 2693 2694 # duplicate columns & possible reduce dimensionality C:\Anaconda3\lib\site-packages\pandas\core\generic.py in _get_item_cache(self, item) 2484 res = cache.get(item) 2485 if res is None: -> 2486 values = self._data.get(item) 2487 res = self._box_item_values(item, values) 2488 cache[item] = res C:\Anaconda3\lib\site-packages\pandas\core\internals.py in get(self, item, fastpath) 4113 4114 if not isna(item): -> 4115 loc = self.items.get_loc(item) 4116 else: 4117 indexer = np.arange(len(self.items))[isna(self.items)] C:\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance) 3063 return self._engine.get_loc(key) 3064 except KeyError: -> 3065 return self._engine.get_loc(self._maybe_cast_indexer(key)) 3066 3067 indexer = self.get_indexer([key], method=method, tolerance=tolerance) pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() KeyError: 'lower CPIAUCNS'
ChadFulton commented 5 years ago

after modification it works well upto page 3 but I had another bug on prediction/forecasts due to depreciation of ix and I modified .ix to .loc but the plot still looks no lower and upper bound.

Thanks for this note.

Third bug happened when I tried Metropolis-Hastings-ARIMA (1,1) and for some reason I had problem with installation with pymc nonetheless of my successful records on installation with pip.

That's interesting, I don't know why that would be. Perhaps you installed pymc3 instead, or the pip you used to install the package isn't the one associated with the python you're actually using?

My last bug was found at the last box titled "Construct the predictions / forecasts" This is same as my second bug and I had no lower and upper bound line on my plot and followings are error message for your information.

My guess would be that the fredapi.Fred function you used to get the data doesn't set the name of the series the way that pandas_datareader does. You could replace cpi = fred.get_series('CPIAUCNS',"1971-01","2016-12") with cpi = fred.get_series('CPIAUCNS',"1971-01","2016-12").rename('CPIAUCNS') and then the lower and upper bound lines should work.

jasepark2 commented 5 years ago

Dear Chad, Fed one is working well with your original code. I mis-understood the error message was due to Yahoos's no more service on Fed data. However, I am still working on pymc which shows same headache on google. My erroe message after type pip install pymc is

Command "python setup.py egg_info" failed with error code 1 in C:\Users\JASE\AppData\Local\Temp\pip-install-gqu0u1gr\pymc\

I had every single check on google but I finally failed to find the solution.

Anyway, Happy new year and keep providing us your excellent arts.