Hypothesis Testing#
As we previously determined, the following metrics have a right-skewed distribution:
from_purchase_to_approved_hours
total_payment
delivery_time_days
total_weight_kg
avg_products_price
total_freight_value
Given the skewness of these metrics and the fact that most of our hypotheses will involve more than two categories, we will use regression analysis to test our hypotheses.
Regression analysis utilizes the full variance of the data when building a model.
To account for the right-skewness, we will employ a Generalized Linear Model (GLM) regression with a Gamma distribution and a log-link function.
For multiple comparisons, we will apply the Holm correction.
Time Patterns#
Are orders processed longer at night?
For each time of day N (except Sunday):
\(H_{0}^{N}:\) The mean order processing time at night equals the mean order processing time during time period N.
\(H_{1}^{N}:\) The mean order processing time at night does not equal the mean order processing time during time period N.
df_sales.assign(from_purchase_to_approved_hours = lambda x: x.from_purchase_to_approved_hours + 1e-6).stats.glm(
formula='from_purchase_to_approved_hours ~ C(purchase_time_of_day, Treatment(reference="Night"))'
, family=sm.families.Gamma(link=sm.families.links.Log())
, p_adjust='holm'
)
Variable | VIF |
---|---|
C(purchase_time_of_day, Treatment(reference="Night"))[T.Afternoon] | 1.0 |
C(purchase_time_of_day, Treatment(reference="Night"))[T.Evening] | 1.0 |
C(purchase_time_of_day, Treatment(reference="Night"))[T.Morning] | 1.0 |
Dep. Variable: | from_purchase_to_approved_hours | No. Observations: | 96346 |
---|---|---|---|
Model: | GLM | Df Residuals: | 96342 |
Model Family: | Gamma | Df Model: | 3 |
Link Function: | Log | Scale: | 4.0286 |
Method: | IRLS | Log-Likelihood: | -2.3764e+05 |
Date: | Tue, 05 Aug 2025 | Deviance: | 4.4813e+05 |
Time: | 11:55:32 | Pearson chi2: | 3.88e+05 |
No. Iterations: | 9 | Pseudo R-squ. (CS): | 0.0008234 |
Covariance Type: | HC3 |
coef | std err | t | P>|t| | [0.025 | 0.975] | |
---|---|---|---|---|---|---|
Intercept | 2.4603 | 0.020 | 122.914 | 0.000 | 2.421 | 2.500 |
C(purchase_time_of_day, Treatment(reference="Night"))[T.Afternoon] | -0.1477 | 0.023 | -6.406 | 0.000 | -0.193 | -0.103 |
C(purchase_time_of_day, Treatment(reference="Night"))[T.Evening] | -0.1881 | 0.023 | -8.209 | 0.000 | -0.233 | -0.143 |
C(purchase_time_of_day, Treatment(reference="Night"))[T.Morning] | -0.0839 | 0.024 | -3.513 | 0.000 | -0.131 | -0.037 |
coef | p-unc | p-corr | |
---|---|---|---|
Intercept | 2.46 | 0.000 | nan |
C(purchase_time_of_day, Treatment(reference="Night"))[T.Afternoon] | -0.15 | 0.000 | 0.000 |
C(purchase_time_of_day, Treatment(reference="Night"))[T.Evening] | -0.19 | 0.000 | 0.000 |
C(purchase_time_of_day, Treatment(reference="Night"))[T.Morning] | -0.08 | 0.000 | 0.000 |
Result:
At the 0.05 significance level, the mean order processing time at night is statistically significantly different from the mean order processing time at any other time of day.
Moreover, the processing time at night is statistically significantly longer than during other periods.
Are orders processed longer on weekdays?
H0: The average processing time for orders on weekdays and weekends is the same.
H1: The average processing time for orders on weekdays and weekends differs
df_sales.assign(from_purchase_to_approved_hours = lambda x: x.from_purchase_to_approved_hours + 1e-6).stats.glm(
formula='from_purchase_to_approved_hours ~ C(purchase_day_type, Treatment(reference="Weekday"))'
, family=sm.families.Gamma(link=sm.families.links.Log())
)
VIF requires at least two predictors. Skipping check.
Dep. Variable: | from_purchase_to_approved_hours | No. Observations: | 96346 |
---|---|---|---|
Model: | GLM | Df Residuals: | 96344 |
Model Family: | Gamma | Df Model: | 1 |
Link Function: | Log | Scale: | 3.9920 |
Method: | IRLS | Log-Likelihood: | -2.3742e+05 |
Date: | Tue, 05 Aug 2025 | Deviance: | 4.4728e+05 |
Time: | 11:55:33 | Pearson chi2: | 3.85e+05 |
No. Iterations: | 9 | Pseudo R-squ. (CS): | 0.003053 |
Covariance Type: | HC3 |
coef | std err | t | P>|t| | [0.025 | 0.975] | |
---|---|---|---|---|---|---|
Intercept | 2.2617 | 0.007 | 304.098 | 0.000 | 2.247 | 2.276 |
C(purchase_day_type, Treatment(reference="Weekday"))[T.Weekend] | 0.2567 | 0.015 | 17.360 | 0.000 | 0.228 | 0.286 |
Result:
At the 0.05 significance level, the mean order processing time on weekdays is statistically significantly different from the mean order processing time on weekends.
Moreover, the processing time on weekdays is statistically significantly shorter than on weekends.
Customer Reviews Scores#
Does reviews score of 1 have a higher average order value?
For each rating N (except 1):
\(H_{0}^{N}:\) The mean order value for rating 1 equals the mean order value for rating N.
\(H_{1}^{N}:\) The mean order value for rating 1 does not equal the mean order value for rating N.
df_sales.stats.glm(
formula='total_payment ~ C(order_avg_reviews_score, Treatment(reference=1))'
, family=sm.families.Gamma(link=sm.families.links.Log())
, p_adjust='holm'
)
Variable | VIF |
---|---|
C(order_avg_reviews_score, Treatment(reference=1))[T.2] | 1.0 |
C(order_avg_reviews_score, Treatment(reference=1))[T.3] | 1.0 |
C(order_avg_reviews_score, Treatment(reference=1))[T.4] | 1.0 |
C(order_avg_reviews_score, Treatment(reference=1))[T.5] | 1.0 |
Dep. Variable: | total_payment | No. Observations: | 96346 |
---|---|---|---|
Model: | GLM | Df Residuals: | 96341 |
Model Family: | Gamma | Df Model: | 4 |
Link Function: | Log | Scale: | 1.8232 |
Method: | IRLS | Log-Likelihood: | -6.0315e+05 |
Date: | Tue, 05 Aug 2025 | Deviance: | 73396. |
Time: | 11:55:34 | Pearson chi2: | 1.76e+05 |
No. Iterations: | 8 | Pseudo R-squ. (CS): | 0.002713 |
Covariance Type: | HC3 |
coef | std err | t | P>|t| | [0.025 | 0.975] | |
---|---|---|---|---|---|---|
Intercept | 5.2693 | 0.016 | 328.951 | 0.000 | 5.238 | 5.301 |
C(order_avg_reviews_score, Treatment(reference=1))[T.2] | -0.1362 | 0.029 | -4.685 | 0.000 | -0.193 | -0.079 |
C(order_avg_reviews_score, Treatment(reference=1))[T.3] | -0.2514 | 0.021 | -12.106 | 0.000 | -0.292 | -0.211 |
C(order_avg_reviews_score, Treatment(reference=1))[T.4] | -0.2260 | 0.019 | -12.086 | 0.000 | -0.263 | -0.189 |
C(order_avg_reviews_score, Treatment(reference=1))[T.5] | -0.2177 | 0.017 | -12.821 | 0.000 | -0.251 | -0.184 |
coef | p-unc | p-corr | |
---|---|---|---|
Intercept | 5.27 | 0.000 | nan |
C(order_avg_reviews_score, Treatment(reference=1))[T.2] | -0.14 | 0.000 | 0.000 |
C(order_avg_reviews_score, Treatment(reference=1))[T.3] | -0.25 | 0.000 | 0.000 |
C(order_avg_reviews_score, Treatment(reference=1))[T.4] | -0.23 | 0.000 | 0.000 |
C(order_avg_reviews_score, Treatment(reference=1))[T.5] | -0.22 | 0.000 | 0.000 |
Result:
At the 0.05 significance level, the mean order value for rating 1 is statistically significantly different from the mean order value for any other rating.
Moreover, the mean order value for rating 1 is statistically significantly higher than for other ratings.
Are orders with review score of 1 delivered longer?
For each rating N (except 1):
\(H_{0}^{N}:\) The mean delivery time for rating 1 equals the mean delivery time for rating N.
\(H_{1}^{N}:\) The mean delivery time for rating 1 does not equal the mean delivery time for rating N.
df_sales.stats.glm(
formula='delivery_time_days ~ C(order_avg_reviews_score, Treatment(reference=1))'
, family=sm.families.Gamma(link=sm.families.links.Log())
, p_adjust='holm'
)
Variable | VIF |
---|---|
C(order_avg_reviews_score, Treatment(reference=1))[T.2] | 1.0 |
C(order_avg_reviews_score, Treatment(reference=1))[T.3] | 1.0 |
C(order_avg_reviews_score, Treatment(reference=1))[T.4] | 1.0 |
C(order_avg_reviews_score, Treatment(reference=1))[T.5] | 1.0 |
Dep. Variable: | delivery_time_days | No. Observations: | 96211 |
---|---|---|---|
Model: | GLM | Df Residuals: | 96206 |
Model Family: | Gamma | Df Model: | 4 |
Link Function: | Log | Scale: | 0.44468 |
Method: | IRLS | Log-Likelihood: | -3.1745e+05 |
Date: | Tue, 05 Aug 2025 | Deviance: | 37991. |
Time: | 11:55:35 | Pearson chi2: | 4.28e+04 |
No. Iterations: | 7 | Pseudo R-squ. (CS): | 0.1121 |
Covariance Type: | HC3 |
coef | std err | t | P>|t| | [0.025 | 0.975] | |
---|---|---|---|---|---|---|
Intercept | 3.0591 | 0.008 | 393.622 | 0.000 | 3.044 | 3.074 |
C(order_avg_reviews_score, Treatment(reference=1))[T.2] | -0.2406 | 0.016 | -15.280 | 0.000 | -0.271 | -0.210 |
C(order_avg_reviews_score, Treatment(reference=1))[T.3] | -0.4029 | 0.011 | -36.655 | 0.000 | -0.424 | -0.381 |
C(order_avg_reviews_score, Treatment(reference=1))[T.4] | -0.5502 | 0.009 | -59.917 | 0.000 | -0.568 | -0.532 |
C(order_avg_reviews_score, Treatment(reference=1))[T.5] | -0.6922 | 0.008 | -84.196 | 0.000 | -0.708 | -0.676 |
coef | p-unc | p-corr | |
---|---|---|---|
Intercept | 3.06 | 0.000 | nan |
C(order_avg_reviews_score, Treatment(reference=1))[T.2] | -0.24 | 0.000 | 0.000 |
C(order_avg_reviews_score, Treatment(reference=1))[T.3] | -0.40 | 0.000 | 0.000 |
C(order_avg_reviews_score, Treatment(reference=1))[T.4] | -0.55 | 0.000 | 0.000 |
C(order_avg_reviews_score, Treatment(reference=1))[T.5] | -0.69 | 0.000 | 0.000 |
Result:
At the 0.05 significance level, the mean delivery time for rating 1 is statistically significantly different from the mean delivery time for any other rating.
Moreover, the mean delivery time for rating 1 is statistically significantly longer than for other ratings.
Installments#
Are installment orders processed faster?
\(H_{0}:\) The mean processing time of installment-based orders equals the mean processing time of non-installment orders.
\(H_{1}:\) The mean processing time of installment-based orders does not equal the mean processing time of non-installment orders.
df_sales.assign(from_purchase_to_approved_hours = lambda x: x.from_purchase_to_approved_hours + 1e-6).stats.glm(
formula='from_purchase_to_approved_hours ~ C(order_has_installment, Treatment(reference="Has Installments"))'
, family=sm.families.Gamma(link=sm.families.links.Log())
)
VIF requires at least two predictors. Skipping check.
Dep. Variable: | from_purchase_to_approved_hours | No. Observations: | 96346 |
---|---|---|---|
Model: | GLM | Df Residuals: | 96344 |
Model Family: | Gamma | Df Model: | 1 |
Link Function: | Log | Scale: | 5.3357 |
Method: | IRLS | Log-Likelihood: | -2.4076e+05 |
Date: | Tue, 05 Aug 2025 | Deviance: | 4.1670e+05 |
Time: | 11:55:36 | Pearson chi2: | 5.14e+05 |
No. Iterations: | 9 | Pseudo R-squ. (CS): | 0.05990 |
Covariance Type: | HC3 |
coef | std err | t | P>|t| | [0.025 | 0.975] | |
---|---|---|---|---|---|---|
Intercept | 1.5922 | 0.013 | 124.214 | 0.000 | 1.567 | 1.617 |
C(order_has_installment, Treatment(reference="Has Installments"))[T.No Installments] | 1.1739 | 0.015 | 80.109 | 0.000 | 1.145 | 1.203 |
Result:
At the 0.05 significance level, the mean order processing time for installment payments is statistically significantly different from the mean order processing time for non-installment payments.
Moreover, the mean order processing time for installment payments is statistically significantly shorter than for non-installment payments.
Do installment orders have a higher average order value?
\(H_{0}:\) The mean order value of installment-based orders equals the mean order value of non-installment orders.
\(H_{1}:\) The mean order value of installment-based orders does not equal the mean order value of non-installment orders.
df_sales.stats.glm(
formula='total_payment ~ C(order_has_installment, Treatment(reference="Has Installments"))'
, family=sm.families.Gamma(link=sm.families.links.Log())
)
VIF requires at least two predictors. Skipping check.
Dep. Variable: | total_payment | No. Observations: | 96346 |
---|---|---|---|
Model: | GLM | Df Residuals: | 96344 |
Model Family: | Gamma | Df Model: | 1 |
Link Function: | Log | Scale: | 1.8866 |
Method: | IRLS | Log-Likelihood: | -6.0313e+05 |
Date: | Tue, 05 Aug 2025 | Deviance: | 68063. |
Time: | 11:55:37 | Pearson chi2: | 1.82e+05 |
No. Iterations: | 7 | Pseudo R-squ. (CS): | 0.03146 |
Covariance Type: | HC3 |
coef | std err | t | P>|t| | [0.025 | 0.975] | |
---|---|---|---|---|---|---|
Intercept | 5.2843 | 0.006 | 952.606 | 0.000 | 5.273 | 5.295 |
C(order_has_installment, Treatment(reference="Has Installments"))[T.No Installments] | -0.4950 | 0.009 | -55.592 | 0.000 | -0.512 | -0.478 |
Result:
At the 0.05 significance level, the mean order value for installment payments is statistically significantly different from the mean order value for non-installment payments.
Moreover, the mean order value for installment payments is statistically significantly higher than for non-installment payments.
Do installment orders have a higher average order weight?
\(H_{0}:\) The mean weight of installment-based orders equals the mean weight of non-installment orders.
\(H_{1}:\) The mean weight of installment-based orders does not equal the mean weight of non-installment orders.
df_sales.assign(total_weight_kg = lambda x: x.total_weight_kg + 1e-6).stats.glm(
formula='total_weight_kg ~ C(order_has_installment, Treatment(reference="Has Installments"))'
, family=sm.families.Gamma(link=sm.families.links.Log())
)
VIF requires at least two predictors. Skipping check.
Dep. Variable: | total_weight_kg | No. Observations: | 96346 |
---|---|---|---|
Model: | GLM | Df Residuals: | 96344 |
Model Family: | Gamma | Df Model: | 1 |
Link Function: | Log | Scale: | 4.1103 |
Method: | IRLS | Log-Likelihood: | -1.9360e+05 |
Date: | Tue, 05 Aug 2025 | Deviance: | 1.8836e+05 |
Time: | 11:55:38 | Pearson chi2: | 3.96e+05 |
No. Iterations: | 8 | Pseudo R-squ. (CS): | 0.01172 |
Covariance Type: | HC3 |
coef | std err | t | P>|t| | [0.025 | 0.975] | |
---|---|---|---|---|---|---|
Intercept | 1.0603 | 0.008 | 129.641 | 0.000 | 1.044 | 1.076 |
C(order_has_installment, Treatment(reference="Has Installments"))[T.No Installments] | -0.4431 | 0.013 | -33.710 | 0.000 | -0.469 | -0.417 |
Result:
At the 0.05 significance level, the mean order weight for installment payments is statistically significantly different from the mean order weight for non-installment payments.
Moreover, the mean order weight for installment payments is statistically significantly higher than for non-installment payments.
Do installment orders have a higher average product price in the order?
\(H_{0}:\) The mean product price in orders with installment payments equals the mean product price in orders without installment payments.
\(H_{1}:\) The mean product price in orders with installment payments does not equal the mean product price in orders without installment payments.
df_sales.stats.glm(
formula='avg_products_price ~ C(order_has_installment, Treatment(reference="Has Installments"))'
, family=sm.families.Gamma(link=sm.families.links.Log())
)
VIF requires at least two predictors. Skipping check.
Dep. Variable: | avg_products_price | No. Observations: | 96346 |
---|---|---|---|
Model: | GLM | Df Residuals: | 96344 |
Model Family: | Gamma | Df Model: | 1 |
Link Function: | Log | Scale: | 2.1777 |
Method: | IRLS | Log-Likelihood: | -5.8102e+05 |
Date: | Tue, 05 Aug 2025 | Deviance: | 83596. |
Time: | 11:55:38 | Pearson chi2: | 2.10e+05 |
No. Iterations: | 8 | Pseudo R-squ. (CS): | 0.03467 |
Covariance Type: | HC3 |
coef | std err | t | P>|t| | [0.025 | 0.975] | |
---|---|---|---|---|---|---|
Intercept | 5.0635 | 0.006 | 802.494 | 0.000 | 5.051 | 5.076 |
C(order_has_installment, Treatment(reference="Has Installments"))[T.No Installments] | -0.5597 | 0.010 | -58.672 | 0.000 | -0.578 | -0.541 |
Result:
At the 0.05 significance level, the mean product price in orders with installment payments is statistically significantly different from the mean product price in orders without installment payments.
Moreover, the mean product price in orders with installment payments is statistically significantly higher than in orders without installment payments.
Do installment orders have a higher average delivery cost?
\(H_{0}:\) The mean delivery cost for orders with installment payments equals the mean delivery cost for orders without installment payments.
\(H_{1}:\) The mean delivery cost for orders with installment payments does not equal the mean delivery cost for orders without installment payments.
df_sales.assign(total_freight_value = lambda x: x.total_freight_value + 1e-6).stats.glm(
formula='total_freight_value ~ C(order_has_installment, Treatment(reference="Has Installments"))'
, family=sm.families.Gamma(link=sm.families.links.Log())
)
VIF requires at least two predictors. Skipping check.
Dep. Variable: | total_freight_value | No. Observations: | 96346 |
---|---|---|---|
Model: | GLM | Df Residuals: | 96344 |
Model Family: | Gamma | Df Model: | 1 |
Link Function: | Log | Scale: | 0.89391 |
Method: | IRLS | Log-Likelihood: | -3.9351e+05 |
Date: | Tue, 05 Aug 2025 | Deviance: | 46190. |
Time: | 11:55:39 | Pearson chi2: | 8.61e+04 |
No. Iterations: | 7 | Pseudo R-squ. (CS): | 0.01284 |
Covariance Type: | HC3 |
coef | std err | t | P>|t| | [0.025 | 0.975] | |
---|---|---|---|---|---|---|
Intercept | 3.2249 | 0.004 | 800.485 | 0.000 | 3.217 | 3.233 |
C(order_has_installment, Treatment(reference="Has Installments"))[T.No Installments] | -0.2155 | 0.006 | -35.256 | 0.000 | -0.227 | -0.204 |
Result:
At the 0.05 significance level, the mean delivery cost for orders with installment payments is statistically significantly different from the mean delivery cost for orders without installment payments.
Moreover, the mean delivery cost for orders with installment payments is statistically significantly higher than for orders without installment payments.
Order Processing and Delivery#
Do delayed orders have a higher average order value?
\(H_{0}:\) The mean value of delayed orders equals the mean value of non-delayed orders.
\(H_{1}:\) The mean value of delayed orders does not equal the mean value of non-delayed orders.
df_sales.stats.glm(
formula='total_payment ~ C(is_delayed, Treatment(reference="Delayed"))'
, family=sm.families.Gamma(link=sm.families.links.Log())
)
Variable | VIF |
---|---|
C(is_delayed, Treatment(reference="Delayed"))[T.Missing Delivery Dt] | 1.0 |
C(is_delayed, Treatment(reference="Delayed"))[T.Not Delayed] | 1.0 |
Dep. Variable: | total_payment | No. Observations: | 96346 |
---|---|---|---|
Model: | GLM | Df Residuals: | 96343 |
Model Family: | Gamma | Df Model: | 2 |
Link Function: | Log | Scale: | 1.8743 |
Method: | IRLS | Log-Likelihood: | -6.0438e+05 |
Date: | Tue, 05 Aug 2025 | Deviance: | 73819. |
Time: | 11:55:40 | Pearson chi2: | 1.81e+05 |
No. Iterations: | 7 | Pseudo R-squ. (CS): | 0.0002999 |
Covariance Type: | HC3 |
coef | std err | t | P>|t| | [0.025 | 0.975] | |
---|---|---|---|---|---|---|
Intercept | 5.1518 | 0.016 | 332.268 | 0.000 | 5.121 | 5.182 |
C(is_delayed, Treatment(reference="Delayed"))[T.Missing Delivery Dt] | 0.0089 | 0.123 | 0.072 | 0.942 | -0.233 | 0.251 |
C(is_delayed, Treatment(reference="Delayed"))[T.Not Delayed] | -0.0850 | 0.016 | -5.253 | 0.000 | -0.117 | -0.053 |
Result:
At the 0.05 significance level, the mean value of delayed orders is statistically significantly different from the mean value of non-delayed orders.
Moreover, the mean value of delayed orders is statistically significantly higher than of non-delayed orders.
Do delayed orders have a higher average order weight?
\(H_{0}:\) The mean weight of delayed orders equals the mean weight of non-delayed orders.
\(H_{1}:\) The mean weight of delayed orders does not equal the mean weight of non-delayed orders.
df_sales.assign(total_weight_kg = lambda x: x.total_weight_kg + 1e-6).stats.glm(
formula='total_weight_kg ~ C(is_delayed, Treatment(reference="Delayed"))'
, family=sm.families.Gamma(link=sm.families.links.Log())
)
Variable | VIF |
---|---|
C(is_delayed, Treatment(reference="Delayed"))[T.Missing Delivery Dt] | 1.0 |
C(is_delayed, Treatment(reference="Delayed"))[T.Not Delayed] | 1.0 |
Dep. Variable: | total_weight_kg | No. Observations: | 96346 |
---|---|---|---|
Model: | GLM | Df Residuals: | 96343 |
Model Family: | Gamma | Df Model: | 2 |
Link Function: | Log | Scale: | 3.9901 |
Method: | IRLS | Log-Likelihood: | -1.9283e+05 |
Date: | Tue, 05 Aug 2025 | Deviance: | 1.9292e+05 |
Time: | 11:55:41 | Pearson chi2: | 3.84e+05 |
No. Iterations: | 8 | Pseudo R-squ. (CS): | 0.0002701 |
Covariance Type: | HC3 |
coef | std err | t | P>|t| | [0.025 | 0.975] | |
---|---|---|---|---|---|---|
Intercept | 0.9750 | 0.023 | 42.661 | 0.000 | 0.930 | 1.020 |
C(is_delayed, Treatment(reference="Delayed"))[T.Missing Delivery Dt] | -0.3118 | 0.161 | -1.938 | 0.053 | -0.627 | 0.004 |
C(is_delayed, Treatment(reference="Delayed"))[T.Not Delayed] | -0.1152 | 0.024 | -4.836 | 0.000 | -0.162 | -0.069 |
Result:
At the 0.05 significance level, the mean weight of delayed orders is statistically significantly different from the mean weight of non-delayed orders.
Moreover, the mean weight of delayed orders is statistically significantly higher than that of non-delayed orders.
Do delayed orders have a higher average product price in the order?
\(H_{0}:\) The mean product price in delayed orders equals the mean product price in non-delayed orders.
\(H_{1}:\) The mean product price in delayed orders does not equal the mean product price in non-delayed orders.
df_sales.stats.glm(
formula='avg_products_price ~ C(is_delayed, Treatment(reference="Delayed"))'
, family=sm.families.Gamma(link=sm.families.links.Log())
)
Variable | VIF |
---|---|
C(is_delayed, Treatment(reference="Delayed"))[T.Missing Delivery Dt] | 1.0 |
C(is_delayed, Treatment(reference="Delayed"))[T.Not Delayed] | 1.0 |
Dep. Variable: | avg_products_price | No. Observations: | 96346 |
---|---|---|---|
Model: | GLM | Df Residuals: | 96343 |
Model Family: | Gamma | Df Model: | 2 |
Link Function: | Log | Scale: | 2.2900 |
Method: | IRLS | Log-Likelihood: | -5.8480e+05 |
Date: | Tue, 05 Aug 2025 | Deviance: | 90898. |
Time: | 11:55:41 | Pearson chi2: | 2.21e+05 |
No. Iterations: | 8 | Pseudo R-squ. (CS): | 0.0004556 |
Covariance Type: | HC3 |
coef | std err | t | P>|t| | [0.025 | 0.975] | |
---|---|---|---|---|---|---|
Intercept | 4.9336 | 0.018 | 278.035 | 0.000 | 4.899 | 4.968 |
C(is_delayed, Treatment(reference="Delayed"))[T.Missing Delivery Dt] | 0.0848 | 0.140 | 0.607 | 0.544 | -0.189 | 0.358 |
C(is_delayed, Treatment(reference="Delayed"))[T.Not Delayed] | -0.1134 | 0.018 | -6.146 | 0.000 | -0.150 | -0.077 |
Result:
At the 0.05 significance level, the mean product price in delayed orders is statistically significantly different from the mean product price in non-delayed orders.
Moreover, the mean product price in delayed orders is statistically significantly higher than in non-delayed orders.
Do delayed orders have a higher average delivery cost?
\(H_{0}:\) The mean delivery cost for delayed orders equals the mean delivery cost for non-delayed orders.
\(H_{1}:\) The mean delivery cost for delayed orders does not equal the mean delivery cost for non-delayed orders.
df_sales.assign(total_freight_value = lambda x: x.total_freight_value + 1e-6).stats.glm(
formula='total_freight_value ~ C(is_delayed, Treatment(reference="Delayed"))'
, family=sm.families.Gamma(link=sm.families.links.Log())
)
Variable | VIF |
---|---|
C(is_delayed, Treatment(reference="Delayed"))[T.Missing Delivery Dt] | 1.0 |
C(is_delayed, Treatment(reference="Delayed"))[T.Not Delayed] | 1.0 |
Dep. Variable: | total_freight_value | No. Observations: | 96346 |
---|---|---|---|
Model: | GLM | Df Residuals: | 96343 |
Model Family: | Gamma | Df Model: | 2 |
Link Function: | Log | Scale: | 0.89540 |
Method: | IRLS | Log-Likelihood: | -3.9415e+05 |
Date: | Tue, 05 Aug 2025 | Deviance: | 47250. |
Time: | 11:55:42 | Pearson chi2: | 8.63e+04 |
No. Iterations: | 7 | Pseudo R-squ. (CS): | 0.0006139 |
Covariance Type: | HC3 |
coef | std err | t | P>|t| | [0.025 | 0.975] | |
---|---|---|---|---|---|---|
Intercept | 3.2036 | 0.010 | 305.611 | 0.000 | 3.183 | 3.224 |
C(is_delayed, Treatment(reference="Delayed"))[T.Missing Delivery Dt] | -0.1191 | 0.085 | -1.408 | 0.159 | -0.285 | 0.047 |
C(is_delayed, Treatment(reference="Delayed"))[T.Not Delayed] | -0.0847 | 0.011 | -7.727 | 0.000 | -0.106 | -0.063 |
Result:
At the 0.05 significance level, the mean delivery cost in delayed orders is statistically significantly different from the mean delivery cost in non-delayed orders.
Moreover, the mean delivery cost in delayed orders is statistically significantly higher than in non-delayed orders.
Does delivery delay affect the distribution of order ratings?
\(H_{0}:\) The distribution of order ratings is identical for delayed and non-delayed orders.
\(H_{1}:\) The distribution of order ratings differs between delayed and non-delayed orders.
We will use:
OrderedModel, since the rating is an ordinal variable.
(
df_sales.assign(
order_avg_reviews_score=lambda x: pd.Categorical(
x.order_avg_reviews_score,
categories=[1, 2, 3, 4, 5],
ordered=True
)
)
.stats.ordered_model(
formula = 'order_avg_reviews_score ~ C(is_delayed, Treatment(reference="Delayed"))'
)
)
Optimization terminated successfully.
Current function value: 1.128950
Iterations: 37
Function evaluations: 38
Gradient evaluations: 38
Dep. Variable: | order_avg_reviews_score | Log-Likelihood: | -1.0877e+05 |
---|---|---|---|
Model: | OrderedModel | AIC: | 2.176e+05 |
Method: | Maximum Likelihood | BIC: | 2.176e+05 |
Date: | Tue, 05 Aug 2025 | ||
Time: | 11:55:51 | ||
No. Observations: | 96346 | ||
Df Residuals: | 96340 | ||
Df Model: | 2 |
coef | std err | z | P>|z| | [0.025 | 0.975] | |
---|---|---|---|---|---|---|
C(is_delayed, Treatment(reference="Delayed"))[T.Missing Delivery Dt] | -0.9020 | 0.178 | -5.061 | 0.000 | -1.251 | -0.553 |
C(is_delayed, Treatment(reference="Delayed"))[T.Not Delayed] | 2.2494 | 0.023 | 96.139 | 0.000 | 2.204 | 2.295 |
1/2 | -0.2899 | 0.022 | -13.254 | 0.000 | -0.333 | -0.247 |
2/3 | -1.0485 | 0.018 | -58.598 | 0.000 | -1.084 | -1.013 |
3/4 | -0.4063 | 0.011 | -37.453 | 0.000 | -0.428 | -0.385 |
4/5 | 0.0153 | 0.007 | 2.248 | 0.025 | 0.002 | 0.029 |
Result:
At the 0.05 significance level, the distribution of order ratings differs between delayed and non-delayed orders.
Moreover, non-delayed orders have statistically significantly higher chances of receiving a higher rating.
Are expensive orders delivered longer?
For each order price category N (except expensive):
\(H_{0}^{N}:\) The mean delivery cost for the expensive price category equals the mean delivery cost for category N.
\(H_{1}^{N}:\) The mean delivery cost for the expensive price category does not equal the mean delivery cost for category N.
df_sales.stats.glm(
formula='delivery_time_days ~ C(order_total_payment_cat, Treatment(reference="Expensive"))'
, family=sm.families.Gamma(link=sm.families.links.Log())
, p_adjust='holm'
)
Variable | VIF |
---|---|
C(order_total_payment_cat, Treatment(reference="Expensive"))[T.Cheap] | 1.0 |
C(order_total_payment_cat, Treatment(reference="Expensive"))[T.Medium] | 1.0 |
Dep. Variable: | delivery_time_days | No. Observations: | 96211 |
---|---|---|---|
Model: | GLM | Df Residuals: | 96208 |
Model Family: | Gamma | Df Model: | 2 |
Link Function: | Log | Scale: | 0.56639 |
Method: | IRLS | Log-Likelihood: | -3.2475e+05 |
Date: | Tue, 05 Aug 2025 | Deviance: | 42404. |
Time: | 11:55:52 | Pearson chi2: | 5.45e+04 |
No. Iterations: | 7 | Pseudo R-squ. (CS): | 0.01226 |
Covariance Type: | HC3 |
coef | std err | t | P>|t| | [0.025 | 0.975] | |
---|---|---|---|---|---|---|
Intercept | 2.6356 | 0.006 | 477.588 | 0.000 | 2.625 | 2.646 |
C(order_total_payment_cat, Treatment(reference="Expensive"))[T.Cheap] | -0.2749 | 0.008 | -34.007 | 0.000 | -0.291 | -0.259 |
C(order_total_payment_cat, Treatment(reference="Expensive"))[T.Medium] | -0.1011 | 0.006 | -16.044 | 0.000 | -0.113 | -0.089 |
coef | p-unc | p-corr | |
---|---|---|---|
Intercept | 2.64 | 0.000 | nan |
C(order_total_payment_cat, Treatment(reference="Expensive"))[T.Cheap] | -0.27 | 0.000 | 0.000 |
C(order_total_payment_cat, Treatment(reference="Expensive"))[T.Medium] | -0.10 | 0.000 | 0.000 |
Result:
At the 0.05 significance level, the mean delivery cost for the high-price order category is statistically significantly different from the mean delivery cost for any other category.
Moreover, the mean delivery cost for the high-price category is statistically significantly higher than for other categories.