Format prediction posteriors
Now let's plot some new predictions. In this exercise, we'll predict how popular a song would be that was newly released and has a song_age
of 0. We're still predicting popularity
from song_age
and artist_name
. The new_predictions
object has already been created and contains the distributions for the predicted scores for a new song from Adele, Taylor Swift, and Beyoncé.
This exercise is part of the course
Bayesian Regression Modeling with rstanarm
Exercise instructions
- Print the predicted scores from the first 10 iterations of
new_predictions
. - Convert
new_predictions
to a data frame and name the columns of the data frame "Adele", "Taylor Swift", and "Beyoncé". - Structure the data in long format, with only two columns:
artist_name
andpredict
. - Print the first six rows of the newly structured
plot_posterior
data frame.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# View new data predictions
___[___:___, ]
# Convert to data frame and rename variables
new_predictions <- ___(new_predictions)
___(___) <- c("___", "___", "___")
# Create tidy data structure
plot_posterior <- ___(new_predictions, key = "artist_name", value = "predict")
# Print formated data
___(plot_posterior)