Inferential statistics in survey analysis

Analyzing Survey Data in Python

EbunOluwa Andrew

Data Scientist

Introduction to inferential statistics in survey analysis

  • Associations between variables
  • How well sample represents larger population
  • Cause-and-effect relationships
Analyzing Survey Data in Python

Sample scenarios

Teenage girl in a car as her mother sits next to her

Happy young businesswoman

Analyzing Survey Data in Python

Z-score

  • Positive = higher than mean
  • Negative = lower than mean
  • Greater than absolute value of 3:
    • Unusual value
  • scipy.stats.zscore()

Gaussian distribution

Analyzing Survey Data in Python

Survey example on demographics

print(survey)
| Gender | Age | Height | Weight |
|--------|-----|--------|--------|
| female |  20 |    163 |     48 |
| female |  19 |    163 |     58 |
| female |  20 |    176 |     67 |
| female |  20 |    170 |     59 |
| male   |  20 |    186 |     77 |
Analyzing Survey Data in Python

Visualizing age column

survey.Age.plot(kind='hist')

histogram of Age column

Analyzing Survey Data in Python

Calculating z-score on age column

survey['Age_zscore'] = stats.zscore(survey.Age)
print(survey)
| Gender | Age | Height | Weight | Age_zscore    |
|--------|-----|--------|--------|---------------|
| female |  20 |    163 |     48 | -0.1293116227 |
| female |  19 |    163 |     58 | -0.4955134449 |
| female |  20 |    176 |     67 | -0.1293116227 |
...
Analyzing Survey Data in Python

Calculating z-score on age column

survey[(survey.Age_zscore >= 3) |
       (survey.Age_zscore <= -3)]
| Gender | Age | Height | Weight | Age_zscore   |
|--------|-----|--------|--------|--------------|
| male   |  30 |    178 |     71 | 3.5327065994 |
| female |  30 |    160 |     47 | 3.5327065994 |
| male   |  29 |    189 |     96 | 3.1665047772 |
| male   |  29 |    183 |    111 | 3.1665047772 |
| male   |  29 |    173 |     81 | 3.1665047772 |
| female |  30 |    173 |     69 | 3.5327065994 |
| female |  29 |    170 |     58 | 3.1665047772 |
...
Analyzing Survey Data in Python

Z-score analysis

Business Man with a credit card - Photo by rupixen.com on Unsplash

Analyzing Survey Data in Python

Let's practice!

Analyzing Survey Data in Python

Preparing Video For Download...