探索性數(shù)據(jù)分析ToothGrowth

統(tǒng)計(jì)推斷 – ToothGrowth Data --- Statistical Inference – ToothGrowth Data (rstudio-pubs-static.s3.amazonaws.com)

R內(nèi)置數(shù)據(jù)集:ToothGrowth
牙齒生長(zhǎng)數(shù)據(jù)集包含了研究維生素C對(duì)60只豚鼠牙齒生長(zhǎng)影響的實(shí)驗(yàn)結(jié)果。每只動(dòng)物通過(guò)兩種給藥方法(抗壞血酸VC或橙汁OJ),接受三種劑量水平的維生素C(0.5、1.0和2.0mg/天)。

加載ToothGrowth數(shù)據(jù)集

library(datasets)
data("ToothGrowth")
str(ToothGrowth)
head(ToothGrowth)
數(shù)據(jù)基本信息

數(shù)據(jù)摘要

畫(huà)圖

library(ggplot2)
ggplot(data=ToothGrowth, aes(x=as.factor(dose), y=len, fill=supp)) +
  geom_bar(stat="identity") +
  facet_grid(. ~ supp) +
  guides(fill=guide_legend(title="Supplement Type"))+
  labs(x = "Dose", y = "Tooth Growth")
牙齒長(zhǎng)度與劑量的條形圖
g <- ggplot(ToothGrowth, aes(dose,len))
g+geom_point(aes(color=supp)) +ggtitle("Tooth Length vs Dose Amount") + xlab("Dose Amount") + ylab("Tooth Length") 
牙齒長(zhǎng)度與劑量的散點(diǎn)圖
g + geom_boxplot(aes(fill=dose)) + facet_grid(.~supp) + xlab("Dose Amount") + ylab("Tooth Length") + ggtitle("Tooth Length vs Dose Amount by Supplement Type")
牙齒長(zhǎng)度與劑量的箱線圖

圖形顯示:兩種給藥方法的劑量較高時(shí),牙齒長(zhǎng)度似乎更高。

統(tǒng)計(jì)檢驗(yàn)

library(dplyr)
t.test(len~dose,data=filter(ToothGrowth, supp=="OJ"& (dose=="0.5" | dose=="1")))$p.value

[1] 8.784919e-05

t.test(len~dose,data=filter(ToothGrowth, supp=="OJ"& (dose=="1" | dose=="2")))$p.value

[1] 0.03919514

t.test(len~dose,data=filter(ToothGrowth, supp=="VC"& (dose=="0.5" | dose=="1")))$p.value

[1] 6.811018e-07

t.test(len~dose,data=filter(ToothGrowth, supp=="VC"& (dose=="1" | dose=="2")))$p.value

[1] 9.155603e-05
所有 p 值都小于 0.05,這意味著無(wú)論使用哪種給藥方法,劑量對(duì)牙齒長(zhǎng)度都有正向影響。

按劑量顯示牙齒長(zhǎng)度與補(bǔ)充劑類型的箱線圖。


按劑量分組顯示牙齒長(zhǎng)度與計(jì)量箱線圖

當(dāng)劑量為 2 毫克/天時(shí),補(bǔ)充劑類型似乎不會(huì)影響牙齒長(zhǎng)度。對(duì)于其余劑量水平,我們需要進(jìn)行進(jìn)一步的測(cè)試。

> t.test(len~supp,data=filter(ToothGrowth, dose=="0.5"))$p.value
#[1] 0.006358607
> t.test(len~supp,data=filter(ToothGrowth, dose=="1"))$p.value
#[1] 0.001038376
> t.test(len~supp,data=filter(ToothGrowth, dose=="2"))$p.value
#[1] 0.9638516

根據(jù) p 值,當(dāng)劑量為 2 mg/天時(shí),兩種補(bǔ)充劑類型之間的效果差異不顯著。然而,當(dāng)劑量相對(duì)較低(0.5 或 1 毫克/天)時(shí),OJ會(huì)導(dǎo)致比 VC 更長(zhǎng)的牙齒長(zhǎng)度

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容