Skip to content

kevinlukaixing/response-time-modeling

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Message Response Time Modeling

Python PyMC NumPy Pandas

A Bayesian analysis of real-world message response times using probabilistic cognitive models.

About

This project investigates whether the probability of responding to a message increases, decreases, or remains constant as time elapses. Using 50 real text message response times, I fit three probability distributions (Exponential, Gamma, Weibull) and compared their fit using Bayes Factors.

The core question: When someone receives a message but hasn't replied yet, does the probability they'll respond in the next moment stay constant, build up over time, or decay?

Technical Implementation

Bayesian Model Fitting

Built three probabilistic models in PyMC, each representing a different hypothesis about response behavior:

  • Exponential Model: Assumes constant hazard rate—equally likely to respond at any moment (memoryless process).
  • Gamma Model: Models response time as the sum of α exponentially-distributed sub-events (e.g., noticing message + deciding to respond + typing).
  • Weibull Model: Flexible hazard rate controlled by shape parameter α. When α > 1, response probability increases over time; when α < 1, it decreases.

MCMC Sampling Configuration

NSAMPLES = 10000      # Posterior draws
CHAINS = 4            # Parallel chains
CORES = 8             # CPU cores
PRIOR_SAMPLES = 40000 # Prior predictive samples

Model Comparison via Bayes Factors

Used Sequential Monte Carlo (SMC) sampling to compute marginal likelihoods, then calculated pairwise Bayes Factors:

BF₁₂ = p(data | Model₁) / p(data | Model₂)

Interpretation follows Jeffreys' scale: BF > 10 = strong evidence, BF > 100 = extreme evidence.

Tech

Python, PyMC 5, ArviZ, NumPy, Pandas, Matplotlib. No pre-built statistical templates—all model specifications and prior selections done from scratch.

Data

Metric Value
Sample size 50 messages
Type Text messages
Mean MRT ~44.7 minutes
Median MRT ~32 minutes
Range 1 - 174 minutes

All messages sent to the same recipient. MRT = time in minutes from sending to receiving a reply.

Results

Model Comparison

Comparison Bayes Factor Interpretation
Exponential vs Gamma 3.62 Moderate evidence for Exponential
Exponential vs Weibull 20.64 Strong evidence for Exponential
Gamma vs Weibull 5.70 Moderate evidence for Gamma

Key Finding

The Exponential model provides the best fit to the data, suggesting that message response times follow a constant hazard rate—the probability of responding is roughly the same whether 1 minute or 100 minutes have passed. This implies a "memoryless" process: how long someone has waited doesn't predict when they'll respond.

Ranking: Exponential > Gamma > Weibull


Architecture

Prior Specifications

Model Parameter Prior Rationale
Exponential λ Gamma(2, 100) Weakly informative; allows mean MRT ~50 min
Gamma α Gamma(2, 2/1.1) Centered near 1, allows shape flexibility
Gamma β Gamma(2, 2/0.0245) Scaled to expected MRT range
Weibull α Gamma(2, 0.5) Allows both increasing/decreasing hazard
Weibull β Gamma(2, 2/44) Scaled to observed mean

Key Functions

Function Responsibility
pm.sample() MCMC posterior sampling with NUTS
pm.sample_prior_predictive() Generate predictions before seeing data
pm.sample_posterior_predictive() Generate predictions from fitted model
marginal_llk_smc() Compute log marginal likelihood via SMC
bayes_factor() Compute BF between two models
report_bf() Format and interpret BF results

Output Plots

For each model:

  1. Plot I: Prior vs Posterior distributions for each parameter
  2. Plot II/III: Prior predictive, posterior predictive, and observed data histogram

Project Structure

message-response-time-modeling/
├── README.md
├── requirements.txt
├── data/
│   ├── README.md
│   └── message_response_times.csv
├── src/
│   └── analysis.py
└── results/
    └── figures/

How to Run

# Clone and setup
git clone https://github.com/yourusername/message-response-time-modeling.git
cd message-response-time-modeling
pip install -r requirements.txt

# Run analysis
python src/analysis.py

Course Context

CS134/PSY141: Computational Models in Cognitive Science — Tufts University, Fall 2025

About

Bayesian analysis of message response times using Exponential, Gamma, and Weibull distributions. Compares models via Bayes Factors to determine whether response probability increases, decreases, or stays constant over time.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages