Skip to content

Commit

Permalink
update 4가지 표본추출방법
Browse files Browse the repository at this point in the history
  • Loading branch information
statkclee committed May 13, 2024
1 parent b7e535c commit 5cc0f16
Show file tree
Hide file tree
Showing 9 changed files with 2,342 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "표본추출 개념 시각화"
title: "대표적 표본추출 방법"
author: "이광춘"
date: today
image: thumbnail.png
Expand All @@ -8,6 +8,7 @@ editor_options:
chunk_output_type: console
---

모집단에서 표본을 추출하는 대표적인 단순임의추출, 층화추출, 군집추출, 다단계추출 4가지 방법에 대한 개념을 시각적으로 확인해보자.

# Shiny 앱

Expand All @@ -22,6 +23,8 @@ editor_options:
library(shiny)
library(openintro)
data(COL)
library(showtext)
showtext_auto()
# _____ Simple Random _____ #
build_srs <- function(n, N) {
Expand Down Expand Up @@ -260,7 +263,40 @@ shinyApp(ui, server)


```{webr-r}
library(dplyr)
sampling_frame <- tibble(
ID = 1:1000,
나이 = sample(18:70, 1000, replace = TRUE),
소득 = sample(30000:100000, 1000, replace = TRUE),
지역 = sample(c("북부", "남부", "동부", "서부"), 1000, replace = TRUE),
군집 = sample(1:10, 1000, replace = TRUE)
)
### 1. 단순임의추출 (Simple Random Sampling)
# 단순임의추출: 100개의 관측치 무작위 선택
sample_n(sampling_frame, 100)
### 2. 층화추출 (Stratified Sampling)
# 층화추출: 각 지역별로 25개씩 추출
sampling_frame %>%
group_by(지역) %>%
sample_n(25) %>%
ungroup()
### 3. 군집추출 (Cluster Sampling)
# 군집추출: 군집 3개 임의 추출 후 모든 관측치 선택
clusters <- sample(unique(sampling_frame$군집), 3)
sampling_frame %>%
filter(군집 %in% clusters)
### 4. 다단계추출 (Multistage Sampling)
# 다단계추출: 먼저 군집을 선택하고, 각 군집에서 무작위로 10개씩 추출
sampling_frame %>%
filter(군집 %in% clusters) %>%
group_by(군집) %>%
sample_n(10) %>%
ungroup()
```


Expand Down
File renamed without changes.
File renamed without changes
32 changes: 14 additions & 18 deletions docs/01_data.html
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@
<li class="nav-item">
<a class="nav-link" href="./about.html">
<span class="menu-text">소개</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="./BitStat.html">
<span class="menu-text">BitStat</span></a>
</li>
<li class="nav-item compact">
<a class="nav-link" href="https://github.com/bit2r/BitStat2"> <i class="bi bi-github" role="img">
Expand Down Expand Up @@ -335,7 +339,7 @@ <h5 class="no-anchor card-title listing-title">
</div>
</a>
</div>
<div class="g-col-1" data-index="1" data-categories="확률분포,이산형 분포,베르누이 분포,이항 분포,포아송 분포" data-listing-date-sort="1715439600000" data-listing-file-modified-sort="1715482966694" data-listing-date-modified-sort="NaN" data-listing-reading-time-sort="7" data-listing-word-count-sort="1323">
<div class="g-col-1" data-index="1" data-categories="확률분포,이산형 분포,베르누이 분포,이항 분포,포아송 분포" data-listing-date-sort="1715526000000" data-listing-file-modified-sort="1715482966694" data-listing-date-modified-sort="NaN" data-listing-reading-time-sort="7" data-listing-word-count-sort="1323">
<a href="./01_data/dist_discrete/index.html" class="quarto-grid-link">
<div class="quarto-grid-item card h-100 card-left">
<p class="card-img-top">
Expand Down Expand Up @@ -370,14 +374,14 @@ <h5 class="no-anchor card-title listing-title">
이광춘
</div>
<div class="listing-date">
2024-05-12
2024-05-13
</div>
</div>
</div>
</div>
</a>
</div>
<div class="g-col-1" data-index="2" data-categories="news" data-listing-date-sort="1715439600000" data-listing-file-modified-sort="1715478734144" data-listing-date-modified-sort="NaN" data-listing-reading-time-sort="11" data-listing-word-count-sort="2189">
<div class="g-col-1" data-index="2" data-categories="news" data-listing-date-sort="1715526000000" data-listing-file-modified-sort="1715478734144" data-listing-date-modified-sort="NaN" data-listing-reading-time-sort="11" data-listing-word-count-sort="2189">
<a href="./01_data/dist_fitting/index.html" class="quarto-grid-link">
<div class="quarto-grid-item card h-100 card-left">
<p class="card-img-top">
Expand All @@ -400,22 +404,22 @@ <h5 class="no-anchor card-title listing-title">
이광춘
</div>
<div class="listing-date">
2024-05-12
2024-05-13
</div>
</div>
</div>
</div>
</a>
</div>
<div class="g-col-1" data-index="3" data-categories="표본,표본추출,단순임의추출,층화추출,군집추출,다단계추출,시각화" data-listing-date-sort="1715439600000" data-listing-file-modified-sort="1715484185419" data-listing-date-modified-sort="NaN" data-listing-reading-time-sort="10" data-listing-word-count-sort="1876">
<a href="./01_data/sampling_concept/index.html" class="quarto-grid-link">
<div class="g-col-1" data-index="3" data-categories="표본,표본추출,단순임의추출,층화추출,군집추출,다단계추출,시각화" data-listing-date-sort="1715526000000" data-listing-file-modified-sort="1715592790127" data-listing-date-modified-sort="NaN" data-listing-reading-time-sort="11" data-listing-word-count-sort="2012">
<a href="./01_data/sampling_method/index.html" class="quarto-grid-link">
<div class="quarto-grid-item card h-100 card-left">
<p class="card-img-top">
<img src="./01_data/sampling_concept/thumbnail.png" class="thumbnail-image card-img" style="height: 150px;">
<img src="./01_data/sampling_method/thumbnail.png" class="thumbnail-image card-img" style="height: 150px;">
</p>
<div class="card-body post-contents">
<h5 class="no-anchor card-title listing-title">
표본추출 개념 시각화
대표적 표본추출 방법
</h5>
<div class="listing-categories">
<div class="listing-category" onclick="window.quartoListingCategory('표본'); return false;">
Expand All @@ -441,22 +445,14 @@ <h5 class="no-anchor card-title listing-title">
</div>
</div>
<div class="card-text listing-description">


// Configure the Monaco Editor's loader
require.config({
paths: {
'vs': 'https://cdn.jsdelivr.net/npm/monaco-editor@0.47.0/min/vs'
}
});

모집단에서 표본을 추출하는 대표적인 단순임의추출, 층화추출, 군집추출, 다단계추출 4가지 방법에 대한 개념을 시각적으로 확인해보자.
</div>
<div class="card-attribution card-text-small justify">
<div class="listing-author">
이광춘
</div>
<div class="listing-date">
2024-05-12
2024-05-13
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit 5cc0f16

Please sign in to comment.