Échantillonnage par grappes

Échantillonnage en R

Richie Cotton

Data Evangelist at DataCamp

Stratifié vs par grappes

Échantillonnage stratifié

  • Diviser la population en sous-groupes
  • Utiliser un échantillonnage aléatoire simple dans chaque sous-groupe

Échantillonnage par grappes

  • Utiliser un échantillonnage aléatoire simple pour choisir certains sous-groupes
  • Utiliser un échantillonnage aléatoire simple seulement dans ces sous-groupes
Échantillonnage en R

Variétés de café

Grains de café disposés en rangées et en colonnes.

varieties_pop <- unique(
  coffee_ratings$variety
)
 [1] "Bourbon"              
 [2] "Catimor"              
 [3] "Ethiopian Yirgacheffe"
 [4] "Caturra"              
 [5] "SL14"  
...
[27] "Marigojipe"           
[28] "Pache Comun"
Échantillonnage en R

Étape 1 : échantillonner les sous-groupes

Grains de café en rangées et colonnes, tous gris sauf trois.

varieties_samp <- sample(
  varieties_pop, 
  size = 3
)
"Sumatra"       "Blue Mountain" "SL28"
Échantillonnage en R

Étape 2 : échantillonner chaque groupe

coffee_ratings %>% 
  filter(variety %in% varieties_samp) %>% 
  group_by(variety) %>% 
  slice_sample(n = 5) %>% 
  ungroup()
Échantillonnage en R

Résultat de l'étape 2

# A tibble: 10 x 8
   total_cup_points variety       country_of_origin aroma flavor aftertaste  body balance
              <dbl> <chr>         <chr>             <dbl>  <dbl>      <dbl> <dbl>   <dbl>
 1             81.5 Blue Mountain Haiti              7.42   7.33       7.25  7.42    7.33
 2             82.7 Blue Mountain Mexico             7.75   7.58       7.25  7.67    7.58
 3             84.5 SL28          Kenya              7.92   7.83       7.67  7.67    7.75
 4             81.9 SL28          Zambia             7.67   7.08       7.42  7.75    7.42
 5             84.7 SL28          Kenya              7.75   7.92       7.83  7.58    7.75
 6             85.5 SL28          Kenya              7.92   7.92       7.83  7.83    7.92
 7             83.8 SL28          Kenya              7.75   7.58       7.5   7.75    7.75
 8             86.6 Sumatra       Taiwan             8      8          8     8       8.17
 9             81.7 Sumatra       Indonesia          7.17   7.42       7.33  7.33    7.42
10             83.5 Sumatra       Indonesia          7.25   7.67       7.58  7.83    7.58
Échantillonnage en R

Échantillonnage à plusieurs degrés

  • L'échantillonnage par grappes est un type d'échantillonnage à plusieurs degrés.
  • Il peut y avoir plus de 2 étapes.
  • Les enquêtes nationales peuvent échantillonner des États, des comtés, des villes et des quartiers.
Échantillonnage en R

Passons à la pratique !

Échantillonnage en R

Preparing Video For Download...