Customer Value
The Cincinnati-Clifton Bank (CCB) would like to analyze the value of
a single credit card customer. Each customer generates an average of
$500 in profit each year they retain the credit card with a standard
deviation of $100. However, there is a 20% probability that a customer
will cancel their credit card at the end of any year. Build a simulation
model to compute the total profit generated by a single credit card
customer over the entire lifespan of their account. Use 1,000 simulation
trials in your analysis.
a. What is the expected (sample mean) total profit?
b. What is the sample standard deviation?
c. What is the probability that the total profit is less than $1,500
in profit.
d. Compute a 90% confidence interval for this probability.***
runSimulation <- function(trials, cancelProb, meanProfit, sdProfit){
sample = c()
for(i in 1:trials){
totalProfit = 0
numYears = rgeom(1, cancelProb)
#writeLines(paste("Number of years before cancelling:", numYears))
for(t in 0:numYears){
profit = rnorm(1, meanProfit, sdProfit)
totalProfit = totalProfit + profit
}
sample <- append(sample, totalProfit)
}
return(sample)
}
calcProb <- function(sample, value){
count = 0
for(profit in sample){
if(profit >= value){
count = count + 1
}
}
probability = count/length(sample)
return(probability)
}
A, B, C, & D
numTrials = 100000
results <- runSimulation(numTrials, .2, 500, 100)
prob = calcProb(results, 1500)
writeLines(paste("Expected Profit is:", dollar(mean(results))))
writeLines(paste("Stdev of Profit is:", dollar(sd(results))))
writeLines(paste("Probability of profit being at least $1500:", prob))
# Compute 99% confindence interval for our EV
CIL <- mean(results) - 2.576*(sd(results)/sqrt(numTrials))
CIU <- mean(results) + 2.576*(sd(results)/sqrt(numTrials))
# Compute a 95% confidence interval for the probability estimate
pCIL = prob - 1.96*sqrt( (prob*(1-prob))/numTrials )
pCIU = prob + 1.96*sqrt( (prob*(1-prob))/numTrials )
writeLines(paste("With 99% confidence the EV of profit falls in [", dollar(CIL),",", dollar(CIU), "]"))
writeLines(paste("With 95% confidence the probability of getting at least 1500 falls in [",
round(pCIL, digits = 2), ",", round(pCIU, digits = 2), "]"))
Result <- as.data.frame(results)
bw <- 2*IQR(Result$results)/length(Result$results)^(1/3)
ggplot(Result,
aes(x = results))+
geom_histogram(binwidth = bw,
fill = 'green',
color = 'black',
alpha = .5)+
labs(title = "Distribution of Profit",
x = "Profit",
y = "Frequency")+
hrbrthemes::theme_ft_rc()

## Expected Profit is: $2,486.21
## Stdev of Profit is: $2,236.58
## Probability of profit being at least $1500: 0.57273
## With 99% confidence the EV of profit falls in [ $2,467.99 , $2,504.43 ]
## With 95% confidence the probability of getting at least 1500 falls in [ 0.57 , 0.58 ]