포아송 회귀 그리기

R에서 Generalized Linear Models

Richard Erickson

Instructor

포아송과 geom_smooth 사용 시점

  • 연속형 예측 변수에 가장 적합합니다
  • 예: 용량 증가와 cm$^2$당 암세포 수
  • 그렇지 않으면 박스플롯 등 다른 도구 사용
R에서 Generalized Linear Models

암세포 용량 연구

  • 데이터 시뮬레이션
  • 용량-반응
    • x: 용량(dose)
    • y: cm$^2$당 암세포 수
R에서 Generalized Linear Models

점 그리기

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

점 그래프가 있는 ggplot

R에서 Generalized Linear Models

지터 추가

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

ggplot2의 지터링된 점 예시.

R에서 Generalized Linear Models

geom_smooth()

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

지터 위에 기본 geom_smooth() 적용 예시

R에서 Generalized Linear Models

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에서 Generalized Linear Models

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에서 Generalized Linear Models

단계 요약

  • 점이 겹치지 않게 표시
  • 포아송 추세선 추가
  • 도표 다듬기(여기서는 생략)
R에서 Generalized Linear Models

연습해 봅시다!

R에서 Generalized Linear Models

Preparing Video For Download...