Sai số tương đối của ước lượng điểm

Lấy mẫu trong R

Richie Cotton

Data Evangelist at DataCamp

Mẫu là số dòng

coffee_ratings %>% 
  slice_sample(n = 300) %>% 
  nrow()
300
coffee_ratings %>% 
  slice_sample(prop = 0.25) %>% 
  nrow()
334
Lấy mẫu trong R

Nhiều cỡ mẫu

coffee_ratings %>% 
  summarize(mean_points = mean(total_cup_points)) %>% 
  pull(mean_points)

82.15
coffee_ratings %>% 
  slice_sample(n = 10) %>% 
  summarize(mean_points = mean(total_cup_points)) %>% 
  pull(mean_points)
82.82
coffee_ratings %>% 
  slice_sample(n = 100) %>% 
  summarize(mean_points = mean(total_cup_points)) %>% 
  pull(mean_points)
82.02
coffee_ratings %>% 
  slice_sample(n = 1000) %>% 
  summarize(mean_points = mean(total_cup_points)) %>% 
  pull(mean_points)
82.16
Lấy mẫu trong R

Sai số tương đối

Tham số tổng thể

population_mean <- coffee_ratings %>% 
  summarize(mean_points = mean(total_cup_points)) %>% 
  pull(mean_points)

Ước lượng điểm

sample_mean <- coffee_ratings %>% 
  slice_sample(n = sample_size) %>% 
  summarize(mean_points = mean(total_cup_points)) %>% 
  pull(mean_points)

Sai số tương đối (phần trăm)

100 * abs(population_mean - sample_mean) / population_mean
Lấy mẫu trong R

Sai số tương đối vs. cỡ mẫu

ggplot(errors, aes(sample_size, relative_error)) +
  geom_line() +
  geom_smooth(method = "loess")

Biểu đồ phân tán: sai số tương đối theo cỡ mẫu.

Lấy mẫu trong R

Ayo berlatih!

Lấy mẫu trong R

Preparing Video For Download...