Exercise

Predictions

Now you are going to predict the survival curve for a new customer from the Cox Proportional Hazard model you estimated before. The model is still available in the object fitCPH.

The new customer is a woman and used a voucher in her first order (voucher = 1). The order was placed 21 days ago and had a shopping cart value of 99.90 dollars. She didn't return the order (returned = 0).

Remember: voucher and returned can have the values 0 or 1.

Instructions

100 XP
  • Create a one-row dataframe called newCustomer with the new customer's characteristics listed in the assignment text above.
  • Predict the expected median time until the second order for this customer using print() and plot the predicted survival curve.
  • You are informed that due to database problems the gender was incorrectly coded: The new customer is actually a man. The dataframe newCustomer is copied into a dataframe called newCustomer2. Now go ahead and change the respective variable to male.
  • Recompute the predicted median with the corrected data newCustomer2. What changed?