11.07.2015 Views

statisticalrethinkin..

statisticalrethinkin..

statisticalrethinkin..

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

320 12. MONSTERS AND MIXTURESBut we’re going to be interested in using the solution numerically, not manipulating itanalytically. So we want the beta-binomial density function, within R. Several packages,including rethinking, provide it. e rethinking package calls it dbetabinom.12.3.4. Beta-binomial links. e fundamental parameters of the beta distribution are Aand B, as you saw above. But it’s going to usually be more convenient for us to model the betadistribution as a function of its mean, the average probability drawn from it, and dispersion,how spread out the distribution is. Under this parameterization, the mean is called ¯p (saypee-bar) and the dispersion θ. ese two parameters relate to A and B in a simple way:¯p =AA + B , θ = A + B.is way of using the beta distribution is very common, and so functions like dbetabinomalready expect input in this form, using the labels prob for ¯p and theta for θ. 111Redefining the beta distribution in this way is equivalent to using a link function. It’sjust like using a link, because neither of the parameters A nor B is the mean. But we’d like tomodel the mean, so we need a function to link these parameters to the mean. Since ¯p is themean, it defines our link function. But we’re also going to need to use log-odds again, so thatour linear model translates logically to the probability space between zero and one. So whatdoes the model look like, under this link strategy? Defining the logit of ¯p as a linear model,we get:logy i ∼ BetaBinomial(n i , ¯p i , θ)¯p i1 − ¯p i= α + βx iEffectively, we’ve pushed the logistic down one level of stochasticity, since the binomial levelis now determined by the beta probabilities. e parameters that are directly estimated inthis case will be α, β, and θ.Now, in some cases, you may need to also use a link for θ. Even if you don’t want to modelthe dispersion as a linear model—and I’m not going to encourage that in most circumstances,mainly because trying to model both ¯p and θ with linear models is a formula for stumblinginto a nonidentifiable model—even if you don’t want to do that, you have to restrict θ to begreater than zero. An easy approach to doing this is just to use a log-link, just like the meanλ of a Poisson, so that the estimates on the natural scale are always positive. is is what it’dlook like:logy i ∼ BetaBinomial(n i , ¯p i , θ)¯p i1 − ¯p i= α + βx ilog θ = τe name τ is arbitrary. It just needs to be different from θ, so you can keep in mind thatyou’ve estimated a parameter on the log scale as a stand-in for θ. en you’d estimate α, β,and τ as parameters. To get the posterior for θ, you’d just exponentiate the posterior for τ.I’ll use this kind of link in one of the model fits to come, so you’ll get to see what it looks likein code form.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!