開始使用免費開始

繪製 GLM 圖形

我們常常需要「用眼睛」看看資料,以及資料中的趨勢。ggplot2 允許我們在圖上加入趨勢線。預設的線條是用一種稱為在地迴歸(local regression)的技術產生的。不過,我們也可以指定使用不同的模型來產生這些線條,包括 GLM。

在這個練習中,你會看到如何使用 ggplot2 繪製 GLM。

本練習屬於課程

R 的階層式與混合效果模型

檢視課程

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Plot the data using jittered points and the default stat_smooth
ggplot(data = df_long, aes(x = dose, y = mortality)) + 
	geom_jitter(height = 0.05, width = 0.1) +
	___(fill = 'pink', color = 'red') 
編輯並執行程式碼