📚 The CoCalc Library - books, templates and other resources
License: OTHER
Kernel: Python 3
In [1]:
Out[1]:
/home/agustina/anaconda3/lib/python3.5/site-packages/statsmodels/compat/pandas.py:56: FutureWarning: The pandas.core.datetools module is deprecated and will be removed in a future version. Please use the pandas.tseries module instead.
from pandas.core import datetools
Code 6.1
In [2]:
Out[2]:
Code 6.2
In [3]:
Code 6.3
In [4]:
Out[4]:
0.4901580479490838
Code 6.4
In [5]:
Code 6.5
In [6]:
Code 6.6
In [7]:
Code 6.7
In [8]:
Code 6.8
In [9]:
Out[9]:
Code 6.9
In [10]:
Out[10]:
0.6108643020548935
Code 6.10
In [11]:
Out[11]:
94.924989685887581
Code 6.11
In [12]:
Out[12]:
100%|██████████| 2000/2000 [00:05<00:00, 338.85it/s]
In [13]:
In [14]:
Out[14]:
100.48254797793284
Code 6.12 - 14
The overthinking section corresponding to cells 6.12-14 is not ported because it requires an ad-hoc rethinking package function. Feel free to contribute code to this section.
Code 6.15
In [15]:
In [16]:
Out[16]:
100%|██████████| 2000/2000 [00:12<00:00, 161.13it/s]
Code 6.16
In [17]:
In [18]:
Code 6.17
In [19]:
Out[19]:
/home/agustina/anaconda3/lib/python3.5/site-packages/ipykernel/__main__.py:5: DeprecationWarning: `logsumexp` is deprecated!
Importing `logsumexp` from scipy.misc is deprecated in scipy 1.0.0. Use `scipy.special.logsumexp` instead.
Code 6.18
In [20]:
Code 6.19
In [21]:
Out[21]:
412.49046436448634
Code 6.20
In [22]:
Out[22]:
14.88328369492803
Code 6.21
In [23]:
Out[23]:
(17, 9)
Code 6.22
In [24]:
In [25]:
Out[25]:
100%|██████████| 2000/2000 [00:08<00:00, 243.55it/s]
87%|████████▋ | 1747/2000 [02:33<00:22, 11.39it/s]/home/agustina/anaconda3/lib/python3.5/site-packages/pymc3/step_methods/hmc/nuts.py:468: UserWarning: Chain 1 contains 1 diverging samples after tuning. If increasing `target_accept` does not help try to reparameterize.
% (self._chain_id, n_diverging))
100%|█████████▉| 1999/2000 [02:45<00:00, 12.10it/s]/home/agustina/anaconda3/lib/python3.5/site-packages/pymc3/step_methods/hmc/nuts.py:468: UserWarning: Chain 0 contains 2 diverging samples after tuning. If increasing `target_accept` does not help try to reparameterize.
% (self._chain_id, n_diverging))
100%|██████████| 2000/2000 [02:45<00:00, 12.10it/s]
100%|██████████| 2000/2000 [00:28<00:00, 69.65it/s]
100%|██████████| 2000/2000 [04:31<00:00, 7.38it/s]/home/agustina/anaconda3/lib/python3.5/site-packages/pymc3/step_methods/hmc/nuts.py:452: UserWarning: The acceptance probability in chain 0 does not match the target. It is 0.681715916019, but should be close to 0.8. Try to increase the number of tuning steps.
% (self._chain_id, mean_accept, target_accept))
/home/agustina/anaconda3/lib/python3.5/site-packages/pymc3/step_methods/hmc/nuts.py:468: UserWarning: Chain 0 contains 25 diverging samples after tuning. If increasing `target_accept` does not help try to reparameterize.
% (self._chain_id, n_diverging))
/home/agustina/anaconda3/lib/python3.5/site-packages/pymc3/step_methods/hmc/nuts.py:468: UserWarning: Chain 1 contains 5 diverging samples after tuning. If increasing `target_accept` does not help try to reparameterize.
% (self._chain_id, n_diverging))
Code 6.23
In [26]:
Out[26]:
/home/agustina/anaconda3/lib/python3.5/site-packages/pymc3/stats.py:220: UserWarning: For one or more samples the posterior variance of the
log predictive densities exceeds 0.4. This could be indication of
WAIC starting to fail see http://arxiv.org/abs/1507.04544 for details
""")
WAIC_r(WAIC=-17.054227823698863, WAIC_se=4.8600477062566103, p_WAIC=2.9504889764816951)
Code 6.24
In [27]:
Out[27]:
Code 6.25
In [28]:
Out[28]:
Code 6.26
In [29]:
Out[29]:
-0.69650384567058254
Code 6.27
Compare function already checks number of observations to be equal.
In [30]:
Out[30]:
Code 6.28
In [31]:
In [32]:
Out[32]:
Code 6.29
In [33]:
In [34]:
Out[34]:
100%|██████████| 10000/10000 [00:37<00:00, 264.13it/s]
Code 6.30
In [35]:
Out[35]:
100%|██████████| 10000/10000 [00:28<00:00, 355.45it/s]
In [36]:
Out[36]:
In [37]:
Out[37]:
This notebook was createad on a computer x86_64 running debian stretch/sid and using:
Python 3.5.4
IPython 4.1.2
PyMC3 3.2
NumPy 1.13.3
Pandas 0.21.0
SciPy 1.0.0
Matplotlib 2.0.2