시작하기무료로 시작하기

Bayesian 모형의 R-제곱

이제 Bayesian 모형의 R-제곱을 계산해 보면서 stan_glm으로 추정한 모형의 예측력을 평가해 봅시다. stan_model 객체는 이미 로드되어 있어요.

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

rstanarm으로 배우는 Bayesian 회귀 모델링

강의 보기

연습 안내

  • stan_model의 잔차 분산을 계산하세요
  • stan_model의 적합값 분산을 계산하세요
  • R-제곱을 계산하세요

실습형 인터랙티브 연습

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

# Save the variance of residulas
ss_res <- ___(___(stan_model))

# Save the variance of fitted values
ss_fit <- ___(___(stan_model))

# Calculate the R-squared
1 - (___ / (___ + ___))
코드 편집 및 실행