前言
系列博客是主要讲lecture里的重要知识点,这里面包括了data visualisation、data collection、 Chi-square test、 goodness of fit tests、 measure of performance 、 measure of risk 、 testing for homogeneity 、 testing for independent 和 testing in small sample。都是比较基础的知识点,掌握好,了解它。有的知识点讲的不够详细,后期会补上,现在把重点放在final内容。
Week 1
1.1 Data visualisation 数据可视化
我们要了解Palmer penguins数据集,并且要可视化。
这里不做过多讲解,基础代码部分自己对照lecture在Rstudio里运行
# install.packages("palmerpenguins")
library(palmerpenguins)
了解Palmer penguins数据集的更多信息。
help(penguins, package = "palmerpenguins")
# or more simply
?penguins
快速查看数据集的基本信息。
library(dplyr)
dplyr::glimpse(penguins) # glimpse the structure of the penguins data frame
使用ggplot2
包将数据集可视化。
ggplot(data = penguins) + aes(x = species, fill = sex) +
geom_bar(position = "fill") +
labs(x = "", y = "Proportion of penguins", fill = "Sex") +
scale_y_continuous(labels = scales::percent_format()) +
facet_grid(cols = vars(island), scales = "free_x", space = "free_x") +
theme_linedraw(base_size = 22)
这个part更多知识点参考其他博客里讲述ggplot
绘图部分。
1.2 Data collection 数据收集
Sample and Population 样本和人口
- A sample is part of a population(sample是population的一部分)
- A statistic can be computed from a sample, and used to estimate a parameter.(可以从样本计算统计量,并用于估计参数)
- A statistic summarises what the researcher knows. A parameter is what the researcher wants to know.(统计数据总结了研究人员所知道的。 参数是研究人员想知道的)
为什么要用sample的方法,而不收集完整的Population来观察数据。