ASSIGNMENT DATA (DT2)

Author

Uzoma

Quarto

Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see https://quarto.org.

Running Code

When you click the Render button a document will be generated that includes both content and the output of embedded code. You can embed code like this:

1 + 1
[1] 2

You can add options to executable code like this

[1] 4

The echo: false option disables the printing of code (only output is displayed).

## 1. Problem Statement

Swiss transport planners want to determine whether people use the tram more frequently than the Bus Rapid Transit (BRT). Understanding this difference helps guide infrastructure investment and sustainable transport policy decisions.



## 2. Hypotheses

- **Null Hypothesis (H₀):** There is no difference in average daily trips between tram and BRT users.
- **Alternative Hypothesis (H₁):** Tram users make more daily trips than BRT users.

## 3 Description of the Data

Sample data of daily trips per person:

| Mode | Trips per person |
|——|—————-|
| Tram | 5, 6, 5, 8, 7, 6, 4 |
| BRT | 4, 3, 5, 4, 3, 4, 6 |

- **Variable:** `trips` (numeric)
- **Groups:** `mode` (tram, BRT)
- **Sample size:** 7 for each mode


## 4 Justification of the Chosen Test

- Two independent groups (tram vs BRT)
- Numeric outcome variable (`trips`)
- **Two-sample t-test** is appropriate to compare means
- Assumptions:
- Approximately normally distributed (Shapiro-Wilk test)
- Equal variance (var.equal = TRUE)
- If assumptions fail → non-parametric alternative: Mann-Whitney U test


## R Code Implementation

```{r}
# Load necessary package for effect size (optional)
# install.packages(“effsize”) # Run only if not installed
library(effsize)

# Create the sample data
tram <- c(5, 6, 5, 8, 7, 6, 4)
brt <- c(4, 3, 5, 4, 3, 4, 6)

# Check normality assumption
shapiro.test(tram) # p > 0.05 → approximately normal
shapiro.test(brt) # p > 0.05 → approximately normal

# Conduct two-sample t-test (tram > BRT)
t_test_result <- t.test(tram, brt, alternative = “greater”, var.equal = TRUE)
t_test_result

# Calculate group means
mean(tram)
mean(brt)

# Calculate effect size (Cohen’s d) manually
mean_tram <- mean(tram)
mean_brt <- mean(brt)

sd_pooled <- sqrt(((length(tram)-1)*var(tram) +
(length(brt)-1)*var(brt)) /
(length(tram)+length(brt)-2))

cohens_d <- (mean_tram - mean_brt) / sd_pooled
cohens_d

Business Conclusion

The results indicate that tram services are used more frequently than BRT in Switzerland. From a practical perspective, this suggests that tram infrastructure may provide greater value to commuters, possibly due to higher reliability, coverage, or convenience.

Transport planners can use this information to:

  • Prioritize maintenance or expansion of tram networks

  • Investigate ways to increase BRT usage (e.g., improve coverage, frequency, or connectivity)

  • Make data-driven decisions for sustainable transport planning and resource allocation

Overall, the evidence supports focusing investment on modes that maximize commuter benefit while identifying opportunities to improve underused services.