diff --git a/docs/lecs_html/01_sampling.slides.html b/docs/lecs_html/01_sampling.slides.html index db5ec77..5cb8823 100644 --- a/docs/lecs_html/01_sampling.slides.html +++ b/docs/lecs_html/01_sampling.slides.html @@ -1,15959 +1,15477 @@ - - -
- - - - - - -Photos/Images by #WOCinTech/#WOCinTech Chat (CC-BY)
IRdisplay::display_html('<iframe src="https://www.zoology.ubc.ca/~whitlock/Kingfisher/SamplingNormal.htm" width=1000, height=600></iframe> ')
+IRdisplay::display_html('<iframe src="https://www.zoology.ubc.ca/~whitlock/Kingfisher/SamplingNormal.htm" width=1000, height=800></iframe> ')
Recall that standard error is the standard deviation of point estimates
+$$\sigma_{\hat{p}} = \sqrt{\frac{p(1-p)}{n}}$$set.seed(201)
@@ -14904,9 +14906,24 @@ Let's code it up
-
+
+
+
+
+── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
+✔ ggplot2 3.3.6 ✔ purrr 0.3.4
+✔ tibble 3.1.8 ✔ dplyr 1.0.10
+✔ tidyr 1.2.1 ✔ stringr 1.4.1
+✔ readr 2.1.2 ✔ forcats 0.5.2
+── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
+✖ dplyr::filter() masks stats::filter()
+✖ dplyr::lag() masks stats::lag()
+
+
+
+
@@ -14953,7 +14970,7 @@ Draw a sample of size 10,
-In [38]:
+In [2]:
sample_size_10 <- rep_sample_n(student_population,size=10,reps=1000)
@@ -14971,9 +14988,7 @@ Draw a sample of size 10,
-
-
@@ -15020,7 +15035,7 @@ For each sample, compute the me
-In [39]:
+In [3]:
sampling_dist_10 <- sample_size_10 %>%
@@ -15040,9 +15055,7 @@ For each sample, compute the me
-
-
@@ -15144,11 +15157,11 @@ Plot the sampling distri
-In [51]:
+In [5]:
-ggplot(sampling_dist_10,aes(x=mean_grade)) + geom_histogram(binwidth=0.5, boundary = 0.4, color = "white")+
- theme(text = element_text(size = 15)) + ggtitle("Sampling distribution with n = 10")
+ggplot(sampling_dist_10,aes(x=mean_grade)) + geom_histogram(binwidth=0.5, boundary = 0.4, color = "white")+
+ theme(text = element_text(size = 15)) + ggtitle("Sampling distribution with n = 10")
@@ -15162,1223 +15175,25 @@ Plot the sampling distri
-
-
+
+`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
+
+
+
+
+
+
-
-
+
+
+
+b'\n'
@@ -16403,20 +15218,15 @@ Compare sampling distri
-In [60]:
+In [6]:
-# Create a sample of size 100, repeated 1000 times
-sample_size_100 <- rep_sample_n(student_population,size=100,reps=1000)
-
-# Create a sampling distribution of mean grade
+sample_size_100 <- rep_sample_n(student_population,size=100,reps=1000)
sampling_dist_100 <- sample_size_100 %>% group_by(replicate) %>% summarise(mean_grade = mean(grade))
-
-# Combine data frame for visualization
sampling_dist_100$size <- 100
sampling_dist_10$size <- 10
sampling_dist_combine <- rbind(sampling_dist_10,sampling_dist_100)
-ggplot(sampling_dist_combine,aes(x=mean_grade)) + geom_histogram(binwidth=0.5, boundary = 0.4, color = "white")+
+ggplot(sampling_dist_combine,aes(x=mean_grade)) + geom_histogram(binwidth=0.5, boundary = 0.4, color = "white")+
theme(text = element_text(size = 25)) + facet_wrap(~ size, ncol = 1)
@@ -16431,1486 +15241,14 @@ Compare sampling distri
-
-In [85]:
+In [7]:
sampling_dist_combine %>% group_by(size) %>% summarise(standard_error=sd(mean_grade))
@@ -17952,9 +15290,7 @@ Compute standard errors
-
-
@@ -17969,7 +15305,7 @@ Compute standard errors
10 3.228472
- 100 1.000857
+ 100 1.004032
@@ -17981,60 +15317,6 @@ Compute standard errors
-
-
-
-
-
-
-
-True or False¶
Discuss with your classmates using the following applet (https://www.statcrunch.com/applets/type3&samplingdist)
-A. The population distribution is always normally distributed (i.e., bell shaped)
-B. The sample distribution is always normally distributed (i.e., bell shaped)
-C. The sampling distribution is always normally distributed (i.e., bell shaped)
-
-
-
-
-
-
-
-
-
-
-
-D. The sample distribution has a similar shape to the population distribution
-E. The sampling distribution has a similar shape to the sampling distribution
-F. The sampling distribution has a similar shape to the population distribution
-
-
-
-
-
-
-
-
-
-
-
-G. The sample mean ($\bar{x}$) is equal to the population mean ($\mu$)
-H. The sampling distribution mean ($\mu_{\bar{x}}$) is equal to the population mean ($\mu$)
-I. The sample mean ($\bar{x}$) is equal to the sampling distribution mean ($\mu_{\bar{x}}$)
-
-
-
-
-
-
-
-
-
-
-
-Let's start working on worksheet_02¶
-
-
-