1. Learn
  2. /
  3. Courses
  4. /
  5. Machine Learning for Marketing Analytics in R

Exercise

Cox Proportional Hazard Model

Now you are going to compute a Cox Proportional Hazard model on the online shop data. Your data stored in dataNextOrder now contains four additional variables: the shoppingCartValue of the first order in dollars, whether the customer used a voucher, whether the order was returned, and the gender.

The rms package is already loaded in the workspace.

Instructions

100 XP
  • Compute the Cox PH model using cph(). Include the variables shoppingCartValue, voucher, returned and gender as predictors. Pay attention to specify the formula correctly. Store the result in an object called fitCPH. And, of course, print the results.
  • Take the exponential of the coefficients to interpret them. With respect to interpretation, take into account that shoppingCartValue is a continuous variable, whereas the remaining variables are categorical.
  • Plot the result summary.