Teruo Nakatsuma (Faculty of Economics, Keio University, Japan)
- How to set up Python and necessary packages
- How to start Jupyter Notebook
- Jupyter Notebooks and related files in
notebook-a
- Jupyter Notebooks and related files in
notebook-b
I strongly recommend using Anaconda. It can install Python along with numerous essential packages at once and allows us to manage those packages flexibly.
Download and install Microsoft Visual C++ Redistributable. There are three versions:
If your PC's CPU is manufactured by Intel or AMD, the X64 version is suitable.
-
If you have an older Anaconda on your PC, uninstall it completely by folloiwng instructions.
-
Download an Anaconda installer (Windows, macOS or Linux) from here. Choose an installer for your OS. For macOS, you should check whether Intel chip or Apple Silicon chip is used and download the corresponding installer.
-
Doubleclick the installer and follow the instructions on the screen. Do not change the default settings.
Start Anaconda Powershell Prompt
(Windows) or Terminal
(macOS, Linux) and type
conda update conda
This will update conda (package manager) in Anaconda.
(Optional) To update all packages, type
conda update -n base --all
Then type
(Windows)
conda create -n bayes -c conda-forge jupyterlab seaborn bokeh jupyter_bokeh pymc python-graphviz
(macOS)
conda create -n bayes -c conda-forge jupyterlab seaborn bokeh jupyter_bokeh pymc numpyro python-graphviz
This will create the environment for PyMC. Then type
conda activate bayes
(Windows) Install numpyro
by typing
pip install numpyro
Finally, type
python -m ipykernel install --user --name bayes --display-name "Python (Bayes)"
Now you are ready for Python!
If you encounter any errors during the installation process, go back to the default environment by typing
conda deactivate
and remove bayes
by typing
conda env remove -n bayes
Then redo Step 2.
In case the computer says Command Line Tools for Xcode
is missing, install it as follows.
-
Install
Xcode
from App Store. -
Start
Xcode
. If a pop-up window asks you to install additional tools, follow the instruction. QuitXcode
. -
Start
Terminal
and installCommand Line Tools for Xcode
by typing
sudo xcode-select --install
If asked, type your login password.
Start Anaconda Powershell Prompt
(Windows) or Terminal
(macOS, Linux) and type
jupyter lab --port=8888
Your default browser will pop up.
Start Anaconda Navigator
. You may find it in Start Menu
(Windows) or Launchpad
(macOS). Then click the icon named JupyterLab
.
- For a
Bokeh
interactive plot to work properly, the Jupyter Notebook server must useport 8888
which is set by default. In case this port is occupied by another Jupyter Notebook server, you need to stop it by typing
jupyter server stop
before you open a new JupyterLab session. If this does not work, reboot your PC.
- PyMC may fail when you start your JupyterLab session in the
bayes
environment. If so, you must start it in thebase
environment. If the prompt starts with(bayes)
, type
conda deactivate
Then it will switch back to the base
environment.
file name | description |
---|---|
Cholera.csv | London cholera pandemic data |
Mroz.csv | US women's labor participation data |
StrikeDur.csv | strikes duration data |
USStocksSW.csv | monthly US stock returns data |
ar1_process.ipynb | convergence of the AR(1) process |
cholera.ipynb | Bernoulli model of the cholera data |
example_bernoulli.ipynb | posterior inference on Bernoulli dist. |
example_exponential.ipynb | posterior inference on exponential dist. |
example_normal.ipynb | posterior inference on normal dist. |
example_poisson.ipynb | posterior inference on Poisson dist. |
exponential_duration.ipynb | exponential duration model |
Housing.csv | sales prices of houses |
housing_price.ipynb | hedonic price model of houses |
labor_participation.ipynb | logit model of labor participation |
logit.ipynb | PyMC example of logit model |
poisson_regression.ipynb | PyMC example of Poisson regression model |
probit.ipynb | PyMC example of probit model |
prussian.csv | Prussian army horse kick data |
regression.ipynb | PyMC example of regression analysis |
ships_damage.ipynb | Poisson regression model of ships damage |
ships.csv | ships damage data |
strikes_duration.ipynb. | strikes duration |
wage_education.ipynb | relationship between wage and education |
file name | description |
---|---|
bivariate_distribution.ipynb | examples of bivariate distributions |
large_sample.ipynb | consistency and asymptotic normality |
markovchain.ipynb | Markov chain |
probability_distribution.ipynb | examples of probability distributions |
python_introduction.ipynb | simple example of Bayes' theorem |
skewness_kurtosis.ipynb | skewness and kurtosis |