%matplotlib inline
import pymc3 as pm
import matplotlib.pyplot as plt
import numpy as np
import math
import seaborn as sns
import scipy.stats as st
"figure.figsize"] = (10,10)
plt.rcParams[from warnings import filterwarnings
'ignore') filterwarnings(
Introduction
Now that we have more data from Afterpayon the actual rate of purchases that attract late fees (±10%), I wanted to go back and compute the average late fees. This post is effectively an adaption of the work I did in this post.
Average Late Fees
with pm.Model() as average_late_fee_model:
= pm.Uniform('underlying_sales_aud', lower=5.24715*10**9, upper=5.247249*10**9)
underlying_sales_aud
= pm.Uniform('late_fees_rev', lower=46.05 * 10**6, upper=46.149 * 10**6)
late_fees_rev_aud
= pm.Uniform('average_transaction_value', lower=144.50, upper=154.49)
average_transaction_value_aud
= pm.Uniform('late_payment_rate',lower=9.5,upper=10.5)/100.0
late_payment_rate
= pm.Deterministic('number_of_transactions', underlying_sales_aud / average_transaction_value_aud)
number_of_transactions
= pm.Deterministic('late_transactions', late_payment_rate * number_of_transactions)
late_transactions
= pm.Deterministic('average_late_fee_aud', late_fees_rev_aud / late_transactions)
average_late_fee_aud
pm.model_to_graphviz(model)
with average_late_fee_model:
= pm.sample_prior_predictive(samples = 100_000) samples
Results
= samples['average_late_fee_aud']
late_fee_samples 'Histogram of late fees')
plt.title('Relative Frequency')
plt.ylabel('Late fee (AUD)')
plt.xlabel(=False, norm_hist=True)
sns.distplot(late_fee_samples,kde plt.show()
"average_late_fee_aud"]) pm.summary(samples[
arviz.stats.stats_utils - WARNING - Shape validation failed: input_shape: (1, 100000), minimum_shape: (chains=2, draws=4)
mean | sd | hpd_3% | hpd_97% | mcse_mean | mcse_sd | ess_mean | ess_sd | ess_bulk | ess_tail | r_hat | |
---|---|---|---|---|---|---|---|---|---|---|---|
x | 13.146 | 0.458 | 12.313 | 13.982 | 0.001 | 0.001 | 99393.0 | 99393.0 | 99248.0 | 99302.0 | NaN |
Conclusion
The late fees that Afterpay customers pay are low, somewhere between 12 AUD and 14 AUD on average. This fits what we observed in previous posts, where customers were typically late on only one of the four payments.