Estimating population probabilities

Here we use a simple logistic regression with no covariates to estimate the base probability of cocaine use in a population of students. The data we are using is from Add Health.

We use the logit() function as a link, and the ulam() function to estimate the mode. The syntax for ulam() is almost identical to quap(), but it can estimate a much larger class of models.

(This function will take a little time to run. It is writing and compiling a C++ program to estimate our model for us.)

Use the logistic() function from the rethinking package to see what the estimate and credible interval mean in terms of probability.

For the sake of completeness, let's see what the binomial model we were using during the first week of the semester looks like with the same data. (The prior will be slightly different)

Compare estimates from logistic regression with the estimates from this binomial model.