1. User Specified Priors
In the last lesson we talked about the prior distributions that rstanarm uses by default, and we can exert some control by deciding whether or not to adjust the scales of those distributions. But what if we want to use a completely different distribution? We can define a new prior distribution using the same arguments that we learned about in the last lesson.
2. Why change the default prior?
There are a couple of reasons we may want to specify our own prior distributions. First, there may be a lot of research suggesting the parameter should be around a certain value. In this scenario, we should take advantage of our knowledge and include this information through the prior distribution. Alternatively, we may have a parameter that we know is constrained in some way. For example, maybe a parameter has to be positive, like a variance. Here we could specify a prior distribution that is also always positive to ensure that the parameter is correctly constrained.
3. Specify a prior
We can be explicit about the prior distributions to be used by specifying location and scale values in the prior functions. For example, here we've specified the intercept prior should have a mean of zero and a standard deviation of 10.
4. Specify a prior
However, just like when these values are unspecified, rstanarm will adjust the prior scales using the same rules we learned about. So if you want to make sure you are using the exact distribution you specified, make sure that autoscale is set to FALSE.
5. Specify a prior
Using the prior arguments, we can specify different priors for different parameters. For example, here we've specified that the intercept should have a normally distributed prior with a mean of three and a standard deviation of two, and the predictors should have a Cauchy prior with a mean of zero and a standard deviation of 1.
There are many different prior distributions that can be used. We've already seen the normal and exponential distributions, but there are t distributions and the Cauchy distribution as we've used here. We can see a full list of available distributions by looking at the priors help page. The process of how to choose a good prior distribution is beyond the scope of this course. However, a good practice is to choose a prior distribution that is consistent the expected distribution of your parameters. For example, we know from the central limit theorem that predictor coefficients are normally distributed. Therefore, it makes sense to use a normal prior for these parameters.
6. Flat priors
One situation we haven't discussed is how to specify completely uninformative, or flat priors. What if we're in a situation where we want the prior to provide no information? We can accomplish this by setting the priors to NULL. When we look at the prior summary, we can now see that a flat prior has been used. In practice this is not usually a good idea, because we are rarely in a situation where we have no prior information. In a linear regression for example, we know that the coefficients should be normally distributed. Even if we have no idea what the parameter values should be, it's generally better practice to specify a weakly informative prior using an adjusted scale than to use a completely flat prior.
7. Let's practice!
Now let's change the priors in our Spotify model.