Statistical Inference with python
- Take Ordinal Least Square(OLS) Regression As An Example
NCKU Tech Orange/Joanne Tseng 曾庭筠
How to do statistical Inference?
- 1st: Import Data
- 2nd: Specify an initial model
- 3rd: Estimation (for unknown parameters)
- 4th: Model Checking: Is Model Adequate?
IF NOT, BACK TO 2nd.
- 5th: Use the model
Before entering into first step...
We need to download some extension libraries.
pip install numpy
pip install pandas ## pandas is built on top of Numpy
Pandas contains high-level data structures to make data analysis fast and easy in Python.
pip install cython
pip install git+https://github.com/statsmodels/statsmodels.git
Statsmodels is a Python Module that allows users to explore data, estimate statistical models, and perform statistical tests.
1st. Import data
Create data frame, Import data file
DataFrame(data,columns,index)
pandas.read_csv('/Users/tzeng/Desktop/filename.csv')
pandas.read_table('/Users/tzeng/Desktop/filename.txt')
2nd. Specify an initial model

We use simple linear regression as our model
y = a * x + b
3rd. Estimate for unknown parameters
-
a is estimated as 0.1329
- b is estimated as 0.0434
4th. Model Checking
- Normality
-
Linearity
- Homogeneity

5th. use the model
y = 0.0434 * x + 0.1329
to do prediction