Sampling Variances


Slides

Keywords: Sampling Error, Estimand, Standard Error, Precision



Code



Sampling From A Larger Distribution:

set.seed(123)
sample <- rnorm(n = 50, mean = 10, sd = 2)
mean(sample)

Generating A Sampling Distribution:

# Step 1
means <- vector()
for (i in 1:100)
    means[i] <- mean(rnorm(n = 50, mean = 10, sd = 2))
hist(means, breaks=20)

# Step 2
means <- vector()
for (i in 1:1000)
    means[i] <- mean(rnorm(n = 50, mean = 10, sd = 2))
hist(means, breaks=20)

# Step 3
set.seed(123)
means <- vector()
for (i in 1:10000)
    means[i] <- mean(rnorm(n = 50, mean = 10, sd = 2))
hist(means, breaks=20)

# Calculate SD
sd(means)

Using the Standard Error Formula:

sd(sample)/sqrt(50)
Previous
Next