BaşlayınÜcretsiz Başlayın

Plotting a Bayesian model

In previous exercises we have estimated a Bayesian model predicting a song's popularity (popularity) from its age (song_age). Now let's visualize the model. Using the songs dataset and stan_model object that are already loaded, create a visualization showing the data the estimated regression line using ggplot2.

Bu egzersiz

Bayesian Regression Modeling with rstanarm

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Save a tidy summary of the model parameters to tidy_coef
  • Pull out the estimated intercept and slope from tidy_coef
  • Create a plot showing the data and estimate regression line with song_age on the x-axis and popularity on the y-axis

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Save the model parameters
tidy_coef <- ___(stan_model)

# Extract intercept and slope
model_intercept <- tidy_coef$___[1]
model_slope <- tidy_coef$___[2]

# Create the plot
ggplot(songs, aes(x = ___, y = ___)) +
  geom_point() +
  geom_abline(intercept = ___, slope = ___)
Kodu Düzenle ve Çalıştır