1. Learn
  2. /
  3. Courses
  4. /
  5. Hierarchical and Mixed Effects Models in R

Exercise

Marketing example

As described in the video, our client is interested in knowing if a friend's recommendation increases the number of people who buy, rather than pass, on his online product. He has given us a summary of his data as a data.frame called all_data. This data includes the number of Purchases and Passes for 4 test cities (city) as well as the customer ranking. This data structure lends itself to using cbind() on the two columns of interest to create a matrix (You could use other methods of making a matrix in R, but this is one of the easiest methods).

You are interested to see if the recommendation from a friend increases people buying the product. To answer this question, you will build a glmer() model and then examine the model's output.

If the parameter estimate for friend is significantly greater than zero, then a friend's recommendation increases the chance somebody makes a purchase. If the parameter estimate for friend is significantly less than zero, then a friend's recommendation decreases the chance somebody makes a purchase. If the parameter estimate for friend is not significantly different than zero, then a friend's recommendation has no effect on somebody making a purchase.

Instructions 1/2

undefined XP
    1
    2
  • Fit a glmer() with all_data data.frame. Use cbind(Purchases, Pass) being predicted by friend and ranking (friend goes first). Use city as your your random-effect and family = "binomial".
  • cbind() is required because glmer() requires a matrix input.