knitr::opts_chunk$set(echo = TRUE)
SDS100::download_data("gapminder_2007.Rda")

$\$

Load and visualize the data

library(SDS100)


# Get the gapminder data

load("gapminder_2007.Rda")

lifeExp <- gapminder_2007$lifeExp 


# Visualize the data

$\$

Sample the data and calculate a statistic

# We can use the sample(data_vec, n) to get a sample of length n:



# How can we get x-bar from this sample in R? 

$\$

Sampling distributions

Q: How can we get a full sampling distribution?

# we can repeat a process many times using the SDS100 do_it() function

do_it(100)  *  {

  2 + 3

}

$\$

Create a sampling distribution

# Let's create a sampling distribution in R





# create a histogram of the sampling distribution


# get the population mean, and the mean of the sampling distribution
# is there bias? 



# add a vertical line to our sampling distribution histogram at mu

$\$

Changing the sample size

What happens to the sampling distribution as we change n? Experiment for n = 1, 5, 10, 20

$\$




emeyers/SDS100 documentation built on April 28, 2024, 5:07 p.m.