시작하기무료로 시작하기

두 모형 비교하기

이전 연습 문제에서 distance100arsenic을 설명 변수로 포함한 모형을 적합했어요. 이번 연습 문제에서는 각 변수를 추가했을 때 모형 적합도에 어떤 영향이 있는지 살펴보겠습니다.

여러분이 적합했던 모형은 아래와 같으며, 워크스페이스에 미리 로드되어 있습니다:

  1. model_dist = 'switch ~ distance100'

  2. model_dist_ars = 'switch ~ distance100 + arsenic

데이터셋 wells도 워크스페이스에 미리 로드되어 있습니다.

이 연습은 강의의 일부입니다

Python으로 배우는 Generalized Linear Models

강의 보기

연습 안내

  • null 모형에 distance100을 추가했을 때의 이탈도(deviance) 차이를 계산하세요.
  • distance100 변수가 포함된 모형에 arsenic을 추가했을 때의 이탈도(deviance) 차이를 계산하세요.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

# Compute the difference in adding distance100 variable
diff_deviance_distance = ____.____ - ____.____

# Print the computed difference in deviance
print('Adding distance100 to the null model reduces deviance by: ', 
      round(____,3))

# Compute the difference in adding arsenic variable
diff_deviance_arsenic = ____.____ - ____.____

# Print the computed difference in deviance
print('Adding arsenic to the distance model reduced deviance further by: ', 
      round(____,3))
코드 편집 및 실행