绘制泊松回归

R 中的广义线性模型

Richard Erickson

Instructor

何时对泊松用 geom_smooth

  • 最适用于连续型自变量
  • 例如:剂量增加与每平方厘米癌细胞数增加
  • 否则用箱线图等工具
R 中的广义线性模型

癌细胞剂量研究

  • 模拟数据
  • 剂量-反应
    • x:剂量
    • y:每平方厘米癌细胞数
R 中的广义线性模型

绘制散点

ggplot(data = dat, aes(x = dose, y = cells)) +
    geom_point()

带点的 ggplot

R 中的广义线性模型

抖动散点

ggplot(data = dat, aes(x = dose, y = cells)) +
   geom_jitter(width = 0.05, height = 0.05)

ggplot2 抖动点示例。

R 中的广义线性模型

geom_smooth()

ggplot(data = dat, aes(x = dose, y = cells)) +
   geom_jitter(width = 0.05, height = 0.05)
   geom_smooth()

抖动点上的默认 geom_smooth() 示例

R 中的广义线性模型

使用 geom_smooth() 的 GLM

ggplot(data = dat, aes(x = dose, y = cells)) +
   geom_jitter(width = 0.05, height = 0.05)
   geom_smooth(method = 'glm')

使用 geom_smooth() 和默认 GLM(即 LM)的示例

R 中的广义线性模型

使用 geom_smooth() 的泊松 GLM

ggplot(data = dat, aes(x = dose, y = cells)) +
   geom_jitter(width = 0.05, height = 0.05) +
   geom_smooth(method = 'glm', method.args = list(family = 'poisson'))

泊松回归图示例

R 中的广义线性模型

步骤概览

  • 绘制不重叠的点
  • 添加泊松趋势线
  • 美化图形(此处未完成)
R 中的广义线性模型

开始练习!

R 中的广义线性模型

Preparing Video For Download...