LoslegenKostenlos starten

R-squared for a Bayesian Model

Now let's calculate the R-squared for a Bayesian model so we can assess the predictions of models estimated with stan_glm. The stan_model object is already loaded.

Diese Übung ist Teil des Kurses

<Kurs>Bayesian Regression Modeling with rstanarm</Kurs>
Kurs ansehen

Übungsanweisungen

  • Calculate the variance of the residuals of stan_model
  • Calculate the variance of the fitted values of stan_model
  • Calculate the R-squared

Interaktive praktische Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

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

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

# Calculate the R-squared
1 - (___ / (___ + ___))
Code bearbeiten und ausführen