🔧
tool
相关软件(R代码)
```r # 拟合优度检验:孟德尔实验 observed <- c(315, 108, 101, 32) expected_prop <- c(9, 3, 3, 1) / 16 chisq.test(observed, p = expected_prop) # 独立性检验:基因型与疾病 genotype_disease <- matrix(c(38, 12, 40, 33, 52, 25), nr...
📖 定义
# 拟合优度检验:孟德尔实验
observed <- c(315, 108, 101, 32)
expected_prop <- c(9, 3, 3, 1) / 16
chisq.test(observed, p = expected_prop)
# 独立性检验:基因型与疾病
genotype_disease <- matrix(c(38, 12, 40, 33, 52, 25), nrow = 3, byrow = TRUE)
rownames(genotype_disease) <- c("AA", "Aa", "aa")
colnames(genotype_disease) <- c("患病", "未患病")
chisq.test(genotype_disease)
# 如果期望频数小于5,使用Fisher精确检验
fisher.test(genotype_disease)
# 查看期望频数
chisq.test(genotype_disease)$expected
# 卡方检验的模拟(Monte Carlo)
chisq.test(genotype_disease, simulate.p.value = TRUE, B = 10000)