НачатьНачать бесплатно

Calculating Frequentist R-squared

Let's practice calculating the R-squared. By starting with the frequentist R-squared, we can check our formulas for calculating the R-squared by hand, by checking against the value in the frequentist summary. The lm_model and lm_summary objects are already in your environment.

Это упражнение является частью курса

Bayesian Regression Modeling with rstanarm

Посмотреть курс

Инструкции к упражнению

  • Print the R-squared value from the lm_summary object
  • Calculate the variance of the residuals of the lm_model
  • Calculate the variance of the predicted values of the lm_model
  • Calculate the R-squared value

Интерактивное практическое упражнение

Попробуйте выполнить это упражнение, дополнив этот пример кода.

# Print the R-squared from the linear model
lm_summary$___

# Calulate sums of squares
ss_res <- ___(___(lm_model))
ss_fit <- ___(___(lm_model))

# Calculate the R-squared
1 - (___ / (___ + ___))
Редактировать и запускать код