Creating and verifying the new simulated variables

This section simulates the independent variables Xeducation, Xgender, Xsatisfaction, Xpurch.last.month, and Xmonthly.charges. The code uses the sample() function to generate slightly different data for each of those two data frames based upon a probability vector. Some of the generated data distributions will have only slight differences between the churners and non-churners (for example, education levels), while other variables will be generated specifically to show the differences between members who stayed and who left (tenure2, and purchases last month):

#create new vars====# set the seed for reproduceabilityset.seed(1)#set the gender and Education Vectors.ed.vector <- c("Bachelor's ...

Get Practical Predictive Analytics now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.