शुरू करेंमुफ़्त में शुरू करें

Cox Proportional Hazard मॉडल

अब आप online shop डेटा पर Cox Proportional Hazard मॉडल compute करने जा रहे हैं। आपके dataNextOrder डेटा में अब चार अतिरिक्त वैरिएबल हैं: पहली order का shoppingCartValue (डॉलर में), ग्राहक ने voucher इस्तेमाल किया या नहीं, order returned हुआ या नहीं, और gender.

वर्कस्पेस में rms पैकेज पहले से लोड है.

यह अभ्यास पाठ्यक्रम का हिस्सा है

R में Marketing Analytics के लिए Machine Learning

पाठ्यक्रम देखें

अभ्यास निर्देश

  • cph() का उपयोग करके Cox PH मॉडल compute कीजिए। प्रेडिक्टर के रूप में shoppingCartValue, voucher, returned और gender वैरिएबल शामिल करें। ध्यान दें कि फ़ॉर्मूला सही तरीके से specify हो। परिणाम को fitCPH नाम के ऑब्जेक्ट में स्टोर करें और परिणाम print भी करें.
  • व्याख्या के लिए coefficients का exponential लीजिए। व्याख्या करते समय यह ध्यान में रखें कि shoppingCartValue एक continuous वैरिएबल है, जबकि शेष वैरिएबल categorical हैं.
  • परिणाम का summary प्लॉट करें.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

# 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)
कोड संपादित करें और चलाएँ