- We will create a stimulation for the population of 10,000 college students
- Show each daily screen time in hours
- Collect random sample of 100 college students
- Use the sample mean to be able to estimate the mean of the population
2025-10-19
Example
Population parameter: \(\mu\) = true average screen time
Point estimate: \(\bar{x}\) = true average screen time
the example above is to describe the concept of point estimation
set.seed(123) # 1. Stimulate population: 10,000 college students daily screen time in hours population <- data.frame(screen_time = rnorm(10000, mean = 6, sd = 2)) # 2. Take sample of 100 college students sample_data <- population[sample(1:10000, 100), , drop = FALSE] # 3. Calculate the sample mean sample_mean <- mean(sample_data$screen_time)
sample_mean
## [1] 5.987638
library(ggplot2)
ggplot(population, aes(x = screen_time)) +
geom_histogram(binwidth = 1, fill = "#8C1D40", color = "white") +
labs(
title = "Histogram of Screen Time (population)",
x = "Screen Time in hours",
y = "Number of College Students"
) +
theme_minimal(base_size = 9 )
ggplot(sample_data, aes(x = screen_time)) +
geom_histogram(binwidth = 1, fill = "#004C97", color = "white") +
labs(
title = "Histogram of Screen Time (Sample of 100 students)",
x = "Screen Time in hours",
y = "Number of College Students"
) +
theme_minimal(base_size = 9 )