The purpose of this analysis is to examine customer churn at a
telecommunications provider and identify customer characteristics
associated with retention. The outcome variable, Churn, is
coded as 1 for a customer who churned and 0 for a customer who
remained.
The analysis includes exploratory data analysis, a simple linear
regression, a multiple linear regression, and management
recommendations. Because Churn is binary, the ordinary
least squares models are interpreted as linear probability
models: their fitted values describe changes in the estimated
probability of churn. A logistic regression would be a natural
alternative for a binary outcome, but the two OLS models are included
here to meet the assignment’s regression requirements.
# File path supplied for this assignment.
data_path <- "C:/Users/Home/Downloads/telecom_customers (1).csv"
# If the file is stored somewhere else, change data_path to its location.
if (!file.exists(data_path)) {
stop(
paste0(
"The CSV file was not found at: ", data_path,
"\nUpdate data_path in this chunk to the location of telecom_customers (1).csv."
)
)
}
telecom <- readr::read_csv(data_path, show_col_types = FALSE)
# Confirm that the expected variables are present.
required_columns <- c("CustomerID", "Tenure", "MonthlyCharge", "SupportCalls", "Churn")
missing_columns <- setdiff(required_columns, names(telecom))
if (length(missing_columns) > 0) {
stop(paste("Missing required column(s):", paste(missing_columns, collapse = ", ")))
}
# Set variable types and remove rows with missing values in the analysis variables.
telecom <- telecom %>%
mutate(
CustomerID = as.character(CustomerID),
Churn = as.integer(Churn)
)
if (any(!na.omit(unique(telecom$Churn)) %in% c(0L, 1L))) {
stop("Churn must be coded as 0 (retained) or 1 (churned).")
}
analysis_data <- telecom %>%
select(CustomerID, Tenure, MonthlyCharge, SupportCalls, Churn) %>%
drop_na()
cat("Rows in original data:", nrow(telecom), "\n")
## Rows in original data: 15
cat("Rows used in analysis:", nrow(analysis_data), "\n")
## Rows used in analysis: 15
cat("Rows excluded for missing values:", nrow(telecom) - nrow(analysis_data), "\n")
## Rows excluded for missing values: 0
The dataset contains customer tenure, monthly charge, number of
support calls, and churn status. CustomerID is an
identifier and is not used as a predictor because it does not represent
a meaningful customer characteristic.
kable(head(analysis_data, 10), caption = "First 10 customer records")
| CustomerID | Tenure | MonthlyCharge | SupportCalls | Churn |
|---|---|---|---|---|
| 1 | 3 | 89 | 8 | 1 |
| 2 | 24 | 65 | 2 | 0 |
| 3 | 5 | 95 | 7 | 1 |
| 4 | 48 | 52 | 1 | 0 |
| 5 | 12 | 80 | 5 | 1 |
| 6 | 60 | 45 | 0 | 0 |
| 7 | 18 | 70 | 3 | 0 |
| 8 | 6 | 92 | 8 | 1 |
| 9 | 36 | 55 | 2 | 0 |
| 10 | 8 | 88 | 6 | 1 |
summary_table <- analysis_data %>%
summarise(
Customers = n(),
Average_Tenure = mean(Tenure),
Median_Tenure = median(Tenure),
Average_Monthly_Charge = mean(MonthlyCharge),
Median_Monthly_Charge = median(MonthlyCharge),
Average_Support_Calls = mean(SupportCalls),
Median_Support_Calls = median(SupportCalls),
Churn_Rate = mean(Churn)
)
kable(
summary_table %>% mutate(across(where(is.numeric), ~ round(.x, 2))),
caption = "Overall descriptive statistics"
)
| Customers | Average_Tenure | Median_Tenure | Average_Monthly_Charge | Median_Monthly_Charge | Average_Support_Calls | Median_Support_Calls | Churn_Rate |
|---|---|---|---|---|---|---|---|
| 15 | 26.33 | 18 | 70.2 | 70 | 3.87 | 3 | 0.4 |
churn_counts <- analysis_data %>%
count(Churn) %>%
mutate(
Status = if_else(Churn == 1, "Churned", "Retained"),
Percent = n / sum(n)
) %>%
select(Status, Customers = n, Percent)
kable(
churn_counts %>% mutate(Percent = percent(Percent, accuracy = 0.1)),
caption = "Customer counts by churn status"
)
| Status | Customers | Percent |
|---|---|---|
| Retained | 9 | 60.0% |
| Churned | 6 | 40.0% |
group_summary <- analysis_data %>%
group_by(Churn) %>%
summarise(
Customers = n(),
Mean_Tenure = mean(Tenure),
Mean_Monthly_Charge = mean(MonthlyCharge),
Mean_Support_Calls = mean(SupportCalls),
.groups = "drop"
) %>%
mutate(Churn_Status = if_else(Churn == 1, "Churned", "Retained")) %>%
select(Churn_Status, everything(), -Churn) %>%
mutate(across(where(is.numeric), ~ round(.x, 2)))
kable(group_summary, caption = "Average customer characteristics by churn status")
| Churn_Status | Customers | Mean_Tenure | Mean_Monthly_Charge | Mean_Support_Calls |
|---|---|---|---|---|
| Retained | 9 | 39.67 | 56.0 | 1.67 |
| Churned | 6 | 6.33 | 91.5 | 7.17 |
Initial interpretation: The group comparison provides a first look at whether churned customers differ from retained customers in tenure, monthly charges, and support calls. These are descriptive differences; they do not by themselves establish that one factor causes churn.
ggplot(analysis_data, aes(x = factor(Churn, levels = c(0, 1),
labels = c("Retained", "Churned")))) +
geom_bar(fill = "#2878A5", width = 0.65) +
labs(
title = "Customer counts by churn status",
x = NULL, y = "Number of customers"
) +
theme_minimal(base_size = 12)
ggplot(analysis_data, aes(x = factor(Churn, levels = c(0, 1),
labels = c("Retained", "Churned")),
y = Tenure, fill = factor(Churn))) +
geom_boxplot(show.legend = FALSE, alpha = 0.8) +
geom_jitter(width = 0.08, alpha = 0.7, size = 2, show.legend = FALSE) +
scale_fill_manual(values = c("#2878A5", "#D97941")) +
labs(
title = "Customer tenure by churn status",
x = NULL, y = "Tenure"
) +
theme_minimal(base_size = 12)
ggplot(analysis_data, aes(x = factor(Churn, levels = c(0, 1),
labels = c("Retained", "Churned")),
y = MonthlyCharge, fill = factor(Churn))) +
geom_boxplot(show.legend = FALSE, alpha = 0.8) +
geom_jitter(width = 0.08, alpha = 0.7, size = 2, show.legend = FALSE) +
scale_fill_manual(values = c("#2878A5", "#D97941")) +
labs(
title = "Monthly charge by churn status",
x = NULL, y = "Monthly charge"
) +
theme_minimal(base_size = 12)
ggplot(analysis_data, aes(x = factor(Churn, levels = c(0, 1),
labels = c("Retained", "Churned")),
y = SupportCalls, fill = factor(Churn))) +
geom_boxplot(show.legend = FALSE, alpha = 0.8) +
geom_jitter(width = 0.08, alpha = 0.7, size = 2, show.legend = FALSE) +
scale_fill_manual(values = c("#2878A5", "#D97941")) +
labs(
title = "Number of support calls by churn status",
x = NULL, y = "Support calls"
) +
theme_minimal(base_size = 12)
plot_data <- analysis_data %>%
pivot_longer(
cols = c(Tenure, MonthlyCharge, SupportCalls),
names_to = "Predictor",
values_to = "Value"
)
ggplot(plot_data, aes(x = Value, y = Churn)) +
geom_jitter(height = 0.06, width = 0, alpha = 0.7,
color = "#2878A5", size = 2) +
geom_smooth(method = "lm", se = TRUE, color = "#D97941") +
facet_wrap(~ Predictor, scales = "free_x") +
scale_y_continuous(breaks = c(0, 1), labels = c("Retained (0)", "Churned (1)")) +
labs(
title = "Customer characteristics in relation to churn",
x = "Predictor value", y = "Churn status"
) +
theme_minimal(base_size = 11)
predictor_correlations <- analysis_data %>%
select(Tenure, MonthlyCharge, SupportCalls) %>%
cor(use = "complete.obs")
knitr::kable(round(predictor_correlations, 2),
caption = "Correlation matrix for numeric predictors")
| Tenure | MonthlyCharge | SupportCalls | |
|---|---|---|---|
| Tenure | 1.00 | -0.94 | -0.90 |
| MonthlyCharge | -0.94 | 1.00 | 0.97 |
| SupportCalls | -0.90 | 0.97 | 1.00 |
cor_long <- as.data.frame(as.table(predictor_correlations)) %>%
rename(Variable_1 = Var1, Variable_2 = Var2, Correlation = Freq)
ggplot(cor_long, aes(Variable_1, Variable_2, fill = Correlation)) +
geom_tile(color = "white") +
geom_text(aes(label = round(Correlation, 2)), size = 4) +
scale_fill_gradient2(low = "#B65C4A", mid = "white", high = "#2878A5",
midpoint = 0, limits = c(-1, 1)) +
labs(title = "Correlations among customer predictors",
x = NULL, y = NULL, fill = "Correlation") +
theme_minimal(base_size = 11)
The churn-group summary and graphics should be considered together. In this sample, churned customers have substantially shorter tenure, higher monthly charges, and more support calls on average than retained customers. These patterns suggest that customer experience, service usage, and price may all be relevant to retention. The sample is small, so these patterns should be treated as preliminary.
The simple model uses Tenure as the sole predictor of churn. Tenure is selected because the exploratory analysis suggests a clear difference in tenure between retained and churned customers.
The model is:
\[ Churn_i = \beta_0 + \beta_1 Tenure_i + \epsilon_i \]
simple_model <- lm(Churn ~ Tenure, data = analysis_data)
summary(simple_model)
##
## Call:
## lm(formula = Churn ~ Tenure, data = analysis_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.5884 -0.2892 0.1598 0.2536 0.3617
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.837835 0.141741 5.911 5.14e-05 ***
## Tenure -0.016627 0.004136 -4.020 0.00146 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.3513 on 13 degrees of freedom
## Multiple R-squared: 0.5542, Adjusted R-squared: 0.5199
## F-statistic: 16.16 on 1 and 13 DF, p-value: 0.001456
simple_tidy <- tidy(simple_model, conf.int = TRUE) %>%
mutate(across(where(is.numeric), ~ round(.x, 4)))
kable(simple_tidy, caption = "Simple regression coefficient estimates")
| term | estimate | std.error | statistic | p.value | conf.low | conf.high |
|---|---|---|---|---|---|---|
| (Intercept) | 0.8378 | 0.1417 | 5.9110 | 0.0001 | 0.5316 | 1.1440 |
| Tenure | -0.0166 | 0.0041 | -4.0203 | 0.0015 | -0.0256 | -0.0077 |
simple_fit <- glance(simple_model) %>%
select(r.squared, adj.r.squared, statistic, p.value, AIC, BIC) %>%
mutate(across(everything(), ~ round(.x, 4)))
kable(simple_fit, caption = "Simple regression model fit")
| r.squared | adj.r.squared | statistic | p.value | AIC | BIC |
|---|---|---|---|---|---|
| 0.5542 | 0.5199 | 16.1625 | 0.0015 | 15.0424 | 17.1666 |
Interpretation: The intercept is the model’s estimated churn probability when tenure equals zero. The tenure coefficient estimates the change in the fitted churn probability associated with one additional unit of tenure. A negative coefficient indicates that longer-tenured customers tend to have a lower estimated probability of churn. The p-value tests whether the tenure coefficient differs statistically from zero. The R-squared value describes the proportion of variation in the binary outcome accounted for by this simple model.
ggplot(analysis_data, aes(x = Tenure, y = Churn)) +
geom_jitter(height = 0.05, width = 0, alpha = 0.75,
color = "#2878A5", size = 2) +
geom_smooth(method = "lm", se = TRUE, color = "#D97941") +
scale_y_continuous(breaks = c(0, 1), limits = c(-0.08, 1.08)) +
labs(title = "Simple linear regression: tenure and churn",
x = "Tenure", y = "Churn (0 = retained, 1 = churned)") +
theme_minimal(base_size = 12)
The multiple model includes all three customer characteristics:
TenureMonthlyChargeSupportCallsThe model is:
\[ Churn_i = \beta_0 + \beta_1 Tenure_i + \beta_2 MonthlyCharge_i + \beta_3 SupportCalls_i + \epsilon_i \]
multiple_model <- lm(
Churn ~ Tenure + MonthlyCharge + SupportCalls,
data = analysis_data
)
summary(multiple_model)
##
## Call:
## lm(formula = Churn ~ Tenure + MonthlyCharge + SupportCalls, data = analysis_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.34565 -0.06439 -0.00817 0.05119 0.48261
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.028584 1.126751 -0.913 0.3809
## Tenure 0.009944 0.008564 1.161 0.2702
## MonthlyCharge 0.007614 0.017098 0.445 0.6647
## SupportCalls 0.163501 0.085468 1.913 0.0821 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2302 on 11 degrees of freedom
## Multiple R-squared: 0.8381, Adjusted R-squared: 0.7939
## F-statistic: 18.98 on 3 and 11 DF, p-value: 0.0001173
multiple_tidy <- tidy(multiple_model, conf.int = TRUE) %>%
mutate(across(where(is.numeric), ~ round(.x, 4)))
kable(multiple_tidy, caption = "Multiple regression coefficient estimates")
| term | estimate | std.error | statistic | p.value | conf.low | conf.high |
|---|---|---|---|---|---|---|
| (Intercept) | -1.0286 | 1.1268 | -0.9129 | 0.3809 | -3.5085 | 1.4514 |
| Tenure | 0.0099 | 0.0086 | 1.1612 | 0.2702 | -0.0089 | 0.0288 |
| MonthlyCharge | 0.0076 | 0.0171 | 0.4453 | 0.6647 | -0.0300 | 0.0452 |
| SupportCalls | 0.1635 | 0.0855 | 1.9130 | 0.0821 | -0.0246 | 0.3516 |
multiple_fit <- glance(multiple_model) %>%
select(r.squared, adj.r.squared, statistic, p.value, AIC, BIC) %>%
mutate(across(everything(), ~ round(.x, 4)))
kable(multiple_fit, caption = "Multiple regression model fit")
| r.squared | adj.r.squared | statistic | p.value | AIC | BIC |
|---|---|---|---|---|---|
| 0.8381 | 0.7939 | 18.9811 | 1e-04 | 3.8497 | 7.39 |
Interpreting the coefficients: Each slope represents the association between that predictor and the fitted probability of churn, holding the other predictors constant. A positive coefficient indicates a higher fitted churn probability as the predictor increases; a negative coefficient indicates a lower fitted churn probability. Statistical significance is assessed using the coefficient p-values and confidence intervals. A p-value below 0.05 is commonly treated as evidence of a statistically significant association, although the small sample makes estimates uncertain.
Goodness of fit: R-squared measures the share of variation in churn accounted for by the predictors. Adjusted R-squared accounts for the number of predictors in the model. The overall F-test evaluates whether the predictors, taken together, improve on an intercept-only model. A significant overall F-test does not mean every individual coefficient is statistically significant.
model_comparison <- bind_rows(
glance(simple_model) %>% mutate(Model = "Simple: Tenure only"),
glance(multiple_model) %>% mutate(Model = "Multiple: all predictors")
) %>%
select(Model, nobs, r.squared, adj.r.squared, statistic, p.value) %>%
mutate(across(where(is.numeric), ~ round(.x, 4)))
kable(model_comparison, caption = "Comparison of regression model fit")
| Model | nobs | r.squared | adj.r.squared | statistic | p.value |
|---|---|---|---|---|---|
| Simple: Tenure only | 15 | 0.5542 | 0.5199 | 16.1625 | 0.0015 |
| Multiple: all predictors | 15 | 0.8381 | 0.7939 | 18.9811 | 0.0001 |
The multiple model can explain more variation because it includes additional predictors. However, with only 15 customers, adding predictors can make estimates unstable. Adjusted R-squared and the individual coefficient results should therefore be considered alongside ordinary R-squared.
par(mfrow = c(2, 2))
plot(multiple_model)
par(mfrow = c(1, 1))
The diagnostic plots help assess linearity, residual patterns, influential observations, and the distribution of residuals. The linear probability model also has limitations: fitted values can fall below 0 or above 1, and the error variance is not constant by construction when the outcome is binary. In addition, this dataset contains only 15 observations, which is too small for strong generalizations or reliable causal conclusions. The regression results describe associations, not proof that a predictor causes churn.
In the observed sample, churn is associated descriptively with shorter customer tenure, higher monthly charges, and more support calls. The simple regression quantifies the relationship between tenure and churn. The multiple regression assesses the three predictors simultaneously, so its coefficients represent adjusted associations.
The exploratory comparisons indicate that all three characteristics differ between churned and retained customers. The regression coefficient table should be used to distinguish the size and direction of adjusted associations from statistical significance. Because the sample is very small and the predictors may overlap in the information they provide, the multiple-model estimates are uncertain. A predictor with the largest raw coefficient is not automatically the most important because the predictors use different units.
The available data suggest that customers who leave tend to have shorter tenure, higher monthly charges, and more support calls. These findings point to onboarding, service quality, and perceived value as practical areas for retention efforts. However, only 15 customer records are available, so the results are exploratory and should not be treated as definitive evidence. Management should validate these patterns using a larger, more representative dataset before making major policy or pricing decisions.
All data preparation, tables, visualizations, models, and interpretations are included in this R Markdown file. The CSV path is defined in the Load the data section. Update that single path if the file is stored in a different folder, then knit the document to HTML to produce a report containing the code and its outputs.