Skip to content

nakatsuma/probability_and_statistics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PROBABILITY AND STATISTICS A/B (MATHEMATICAL STATISTICS)

Course materials for PROBABILITY AND STATISTICS A/B (MATHEMATICAL STATISTICS)

Teruo Nakatsuma (Faculty of Economics, Keio University, Japan)



How to set up Python and necessary packages

I strongly recommend using Anaconda. It can install Python along with numerous essential packages at once and allows us to manage those packages flexibly.

Step 1: Installing Anaconda

  1. If you have an older Anaconda on your PC, uninstall it completely by folloiwng instructions.

  2. 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.

  3. Doubleclick the installer and follow the instructions on the screen. Do not change the default settings.

Step 2: Creating an environment

Start Anaconda Powershell Prompt (Windows) or Terminal (macOS, Linux) and type

conda update conda

This will update conda (package manager) in Anaconda. 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

and type

python -m ipykernel install --user --name bayes --display-name "Python (Bayes)"

Now you are ready for Python!


Troubleshooting about installation

1. Retry installation

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.

2. (macOS) Installing Command Line Tools for Xcode

In case the computer says Command Line Tools for Xcode is missing, install it as follows.

  1. Install Xcode from App Store.

  2. Start Xcode. If a pop-up window asks you to install additional tools, follow the instruction. Quit Xcode.

  3. Start Terminal and install Command Line Tools for Xcode by typing

sudo xcode-select --install

If asked, type your login password.


How to start Jupyter Notebook

Start Anaconda Powershell Prompt (Windows) or Terminal (macOS, Linux) and type

conda activate bayes

Then type

jupyter lab --port=8888

Your default browser will pop up.

Troubleshooting about Jupyter Notebook

For a bokeh interactive plot to work properly, the Jupyter Notebook server must use port 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 Jupyter Notebook. If this does not work, reboot your PC.


Jupyter Notebooks and related files in notebook-a

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

Jupyter Notebooks and related files in notebook-b

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

Releases

No releases published

Packages

No packages published