Pengambilan sampel berbobot

Menganalisis Data Survei di Python

EbunOluwa Andrew

Data Scientist

Apa itu pengambilan sampel berbobot?

  • Probabilitas tidak sama
  • Memungkinkan peneliti memperbaiki masalah saat pengumpulan data

Timbangan keadilan di meja, neraca

Menganalisis Data Survei di Python

Variabel umum dalam pengambilan sampel berbobot

  • Karakteristik demografis seperti gender, usia, lokasi, pendidikan
  • Mengakomodasi perbedaan antara yang ikut serta dan tidak dalam studi

Keluarga, siluet orang dari berbagai usia

Menganalisis Data Survei di Python

Pembobotan berbasis sel

1 https://www.geopoll.com/blog/weighting-survey-data-raking-cell-weighting/
Menganalisis Data Survei di Python

Pembobotan berbasis sel

1 https://www.geopoll.com/blog/weighting-survey-data-raking-cell-weighting/
Menganalisis Data Survei di Python

Pembobotan berbasis sel

1 https://www.geopoll.com/blog/weighting-survey-data-raking-cell-weighting/
Menganalisis Data Survei di Python

Pembobotan berbasis sel

1 https://www.geopoll.com/blog/weighting-survey-data-raking-cell-weighting/
Menganalisis Data Survei di Python

Menganalisis pola belanja remaja dengan Python

yp_survey
| Gender | Age | Entertainment |
|--------|-----|---------------|
| female |  19 | Agree         |
| female |  20 | Agree         |
| male   |  19 | Agree         |
| female |  19 | Disagree      |
| female |  24 | Disagree      |
| male   |  18 | Agree         |
| male   |  18 | Agree         |
| male   |  20 | Disagree      |
Menganalisis Data Survei di Python

Menganalisis pola belanja remaja dengan Python

import pandas as pd
yp_crosstab = pd.crosstab(
  yp_survey['Gender'],
  yp_survey['Entertainment'])
yp_crosstab
yp_crosstab.plot.barh()
|        | Agree | Disagree |
|--------|-------|----------|
| female |    81 |       84 |
| male   |    84 |       46 |

Menganalisis Data Survei di Python

Menganalisis pola belanja remaja dengan Python

survey = yp_survey.groupby(['Gender', 'Entertainment'])['Age'].count().reset_index()

survey.columns = ['Gender', 'Entertainment', 'Respondents'] survey
| Gender | Entertainment | Respondents |
|--------|---------------|-------------|
| female | Agree         |          81 |
| female | Disagree      |          84 |
| male   | Agree         |          84 |
| male   | Disagree      |          46 |
Menganalisis Data Survei di Python

Menganalisis pola belanja remaja dengan Python

survey['% total respondents'] = survey.Respondents * 100./survey.Respondents.sum()
survey['% of population'] = [35, 25, 20, 20]
survey['Weight'] = survey['% of population']/survey['% total respondents']
survey['Weighted Respondents'] = survey.Weight * survey.Respondents
Menganalisis Data Survei di Python

Menganalisis pola belanja remaja dengan Python

survey[['Gender','Entertainment',
        'Respondents','Weighted Respondents']].set_index(
  ['Gender','Entertainment']).plot.barh()

Menganalisis Data Survei di Python

Ayo berlatih!

Menganalisis Data Survei di Python

Preparing Video For Download...