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.
Deze oefening maakt deel uit van de cursus
Machine Learning for Marketing Analytics in R
Oefeninstructies
- Compute the Cox PH model using
cph(). Include the variablesshoppingCartValue,voucher,returnedandgenderas predictors. Pay attention to specify the formula correctly. Store the result in an object calledfitCPH. And, of course, print the results. - Take the exponential of the
coefficientsto interpret them. With respect to interpretation, take into account thatshoppingCartValueis a continuous variable, whereas the remaining variables are categorical. - Plot the result summary.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Determine distributions of predictor variables
dd <- datadist(dataNextOrder)
options(datadist = "dd")
# Compute Cox PH Model and print results
___ <- ___(Surv(daysSinceFirstPurch, boughtAgain) ___ shoppingCartValue ___ voucher ___ returned ___ gender,
data = ___,
x = TRUE, y = TRUE, surv = TRUE)
print(___)
# Interpret coefficients
___(fitCPH$___)
# Plot result summary
___(___(fitCPH), log = TRUE)