\(n\) | \(\mu\) | mean(\(\bar{X}\)) | \(\sigma^2\) | var(\(\bar{X}\)) | \(\frac{\sigma^2}{n}\) |
---|---|---|---|---|---|
10 | 0 | -0.003408 | 1 | 0.0980502 | 0.1 |
50 | 0 | -0.0009473 | 1 | 0.0200694 | 0.02 |
100 | 0 | 0.0011459 | 1 | 0.010093 | 0.01 |
\(n\) | \(\mu\) | mean(\(\bar{X}\)) | \(\sigma^2\) | var(\(\bar{X}\)) | \(\frac{\sigma^2}{n}\) |
---|---|---|---|---|---|
10 | 0.3 | 0.29996 | 0.21 | 0.0216842 | 0.021 |
50 | 0.3 | 0.300286 | 0.21 | 0.0041745 | 0.0042 |
100 | 0.3 | 0.301151 | 0.21 | 0.0021253 | 0.0021 |
Figure 2 from Enders, C. K. (2005). Maximum likelihood estimation. Encyclopedia of statistics in behavioral science.
ggplot(data.frame(x = c(-4, 4)), aes(x)) +
stat_function(fun = dnorm,
geom = "line",
xlim = c(-4, 4)) +
stat_function(fun = dnorm,
geom = "area",
fill = "steelblue",
xlim = c(0, 4)) +
annotate("text", x = 0.8, y = 0.1, label = "50%", color = "white", size = 6) +
annotate("text", x = -0.8, y = 0.1, label = "50%", size = 6) +
xlim(-4, 4)
ggplot(data.frame(x = c(-4, 4)), aes(x)) +
stat_function(fun = dnorm,
geom = "line",
xlim = c(-4, 4)) +
stat_function(fun = dnorm,
geom = "area",
fill = "steelblue",
xlim = c(-3, -2)) +
stat_function(fun = dnorm,
geom = "area",
fill = "steelblue",
xlim = c(-1, 0)) +
stat_function(fun = dnorm,
geom = "area",
fill = "steelblue",
xlim = c(1, 2)) +
stat_function(fun = dnorm,
geom = "area",
fill = "steelblue",
xlim = c(3, 4)) +
annotate("text", x = -3.5, y = 0.05, label = "0.13%") +
annotate("text", x = -2.5, y = 0.1, label = "2.14%") +
annotate("text", x = -1.5, y = 0.05, label = "13.59%") +
annotate("text", x = -0.5, y = 0.2, label = "34.13%", color = "white") +
annotate("text", x = 0.5, y = 0.2, label = "34.13%") +
annotate("text", x = 1.5, y = 0.05, label = "13.59%", color = "white") +
annotate("text", x = 2.5, y = 0.1, label = "2.14%") +
annotate("text", x = 3.5, y = 0.05, label = "0.13%") +
geom_vline(xintercept = -3, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = -2, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = -1, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = 0, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = 1, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = 2, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = 3, linetype = "dashed", alpha = 0.3) +
xlim(-4, 4)
ggplot(data.frame(x = c(-4, 4)), aes(x)) +
stat_function(fun = dnorm,
geom = "line",
xlim = c(-4, 4)) +
stat_function(fun = dnorm,
geom = "area",
fill = "steelblue",
xlim = c(-1, 1)) +
annotate("text", x = 0, y = 0.1, label = "68.26%", color = "white", size = 6) +
annotate("text", x = 2.5, y = 0.1, label = "15.87%", size = 6) +
annotate("text", x = -2.5, y = 0.1, label = "15.87%", size = 6) +
geom_vline(xintercept = -3, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = -2, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = -1, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = 0, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = 1, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = 2, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = 3, linetype = "dashed", alpha = 0.3) +
xlim(-4, 4)
ggplot(data.frame(x = c(-4, 4)), aes(x)) +
stat_function(fun = dnorm,
geom = "line",
xlim = c(-4, 4)) +
stat_function(fun = dnorm,
geom = "area",
fill = "steelblue",
xlim = c(-1.645, 1.645)) +
annotate("text", x = 0, y = 0.1, label = "90%", color = "white", size = 6) +
annotate("text", x = 3, y = 0.05, label = "5%", size = 6) +
annotate("text", x = -3, y = 0.05, label = "5%", size = 6) +
geom_vline(xintercept = -3, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = -2, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = -1, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = 0, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = 1, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = 2, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = 3, linetype = "dashed", alpha = 0.3) +
xlim(-4, 4)
ggplot(data.frame(x = c(-4, 4)), aes(x)) +
stat_function(fun = dnorm,
geom = "line",
xlim = c(-4, 4)) +
stat_function(fun = dnorm,
geom = "area",
fill = "steelblue",
xlim = c(-1.96, 1.96)) +
annotate("text", x = 0, y = 0.1, label = "95%", color = "white", size = 6) +
annotate("text", x = 3, y = 0.05, label = "2.5%", size = 6) +
annotate("text", x = -3, y = 0.05, label = "2.5%", size = 6) +
geom_vline(xintercept = -3, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = -2, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = -1, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = 0, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = 1, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = 2, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = 3, linetype = "dashed", alpha = 0.3) +
xlim(-4, 4)
ggplot(data.frame(x = c(-4, 4)), aes(x)) +
stat_function(fun = dnorm,
geom = "line",
xlim = c(-4, 4)) +
stat_function(fun = dnorm,
geom = "area",
fill = "steelblue",
xlim = c(-2.326, 2.326)) +
annotate("text", x = 0, y = 0.1, label = "99%", color = "white", size = 6) +
annotate("text", x = 3, y = 0.05, label = "0.5%", size = 6) +
annotate("text", x = -3, y = 0.05, label = "0.5%", size = 6) +
geom_vline(xintercept = -3, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = -2, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = -1, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = 0, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = 1, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = 2, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = 3, linetype = "dashed", alpha = 0.3) +
xlim(-4, 4)
ggplot(data.frame(x = c(-4, 4)), aes(x)) +
stat_function(fun = dnorm,
geom = "line",
xlim = c(-4, 4)) +
stat_function(fun = dnorm,
geom = "area",
fill = "steelblue",
xlim = c(-1.96, 1.96)) +
annotate("text", x = 0, y = 0.1, label = "95%", color = "white", size = 6) +
annotate("text", x = 3, y = 0.05, label = "2.5%", size = 6) +
annotate("text", x = -3, y = 0.05, label = "2.5%", size = 6) +
geom_vline(xintercept = -3, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = -2, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = -1, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = 0, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = 1, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = 2, linetype = "dashed", alpha = 0.3) +
geom_vline(xintercept = 3, linetype = "dashed", alpha = 0.3) +
xlim(-4, 4)
qnorm()
functionqnorm(0.975, mean = 5, sd = 2)
\([\bar{X} - z_{1-\alpha/2}\ \sqrt{\frac{\sigma^2}{n}}, \bar{X} + z_{1-\alpha/2}\ \sqrt{\frac{\sigma^2}{n}}]\)
\([5.406 - 1.96 \times \sqrt{\frac{3.995}{50}}, 5.406 + 1.96 \times \sqrt{\frac{3.995}{50}}]\)
\([5.406 - 0.554, 5.406 + 0.554]\)
\([4.85, 5.96]\)
ci95min <- meanx - 1.96*sqrt(varx/n)
ci95max <- meanx + 1.96*sqrt(varx/n)
ggplot(data = datx, aes(x = x)) +
geom_histogram(bins = 30) +
geom_vline(xintercept = meanx) +
geom_vline(xintercept = ci95min, linetype = "dashed") +
geom_vline(xintercept = ci95max, linetype = "dashed") +
scale_x_continuous(breaks = c(0:10))