Applied Data Science Lab

by Daniel Jordan Viray

Intuitive explanations of data science techniques used in the real world, written for practitioners. Focused on applications in healthcare and biology.

14 playbooks5 topicsRigorous, but readable

πŸ₯Ό Experimentation

The Practical A/B Testing Playbook

A getting-started guide to running A/B tests in the real world: locking in design parameters, calculating power and sample size, the pitfalls that fake a win (multiple variants, multiple metrics, sample ratio mismatch), ratio metrics and the Delta Method β€” with an interactive power diagram.

➑️ Causal Inference

Active-Comparator, New-User Cohort Study with Difference-in-Differences

Does Ozempic lower the cost of obesity care? A study design using claims and enrollment data, explained end to end

Difference-in-Differences

Did the program work? A state launches job training, a neighbor doesn’t β€” learn the 2Γ—2 intuition, the regression you’d run at work, and the checks that keep you honest.

Inverse Probability of Treatment Weighting (IPTW)

When you can’t randomize, reweight instead: build a pseudo-population where treatment looks assigned by coin flip, check balance with SMDs and a Love plot, tame extreme weights, and fit marginal structural models β€” plus doubly robust estimators and a two-year time-varying example you can check by hand.

Matching and Propensity Score Matching

When you can’t randomize, rebuild a fair comparison: pair treated patients with similar controls, check balance with SMDs and a Love plot, analyze the matched pairs, and stress-test hidden bias β€” then do it all again with propensity scores. One diabetes example (metformin vs. an SGLT2 inhibitor) carries the whole playbook, with interactive charts and simulations.

Staggered Difference-in-Differences

CRISPR centers open in different regions in different months, so there is no single before and after. A four-region toy example shows the staggered fix: one clean DiD per wave - against a holdout or not-yet-treated regions - then pool them into one number.

5 posts β€” all in this box, scroll for more

See all →

πŸ€– Machine Learning

Linear and Logistic Regression Explained

A one-page method bank: fitting OLS in Python, transformations and back-transformations, the fit-metric family (R², RSE, RMSE, MAE, MAPE), diagnostic plots, outliers vs leverage vs influence, logistic regression, and the confusion matrix.

🎲 Statistics & Probability

Practitioner's Guide to Statistical Tests

A one-page method bank: z-tests, t-tests, ANOVA, chi-squared, proportions, and the rank tests β€” when to use each, a healthcare example with real output, the assumptions, the fallback, and the Python code.

Sampling & Bootstrapping

Population, samples, the sampling distribution, standard error, and bootstrapping β€” one connected story about a town's blood pressure, with interactive labs.

Statistical Significance, Visualized

An interactive playground: run experiments, move the sliders, and see what p-values and statistical power actually mean. No math degree required.

3 posts β€” all shown

See all →

πŸ—„οΈ SQL (Advanced)

COALESCE and NULLIF

Tame NULLs and placeholder zeros: defaults for display, honest averages, and division without the divide-by-zero.

CTEs and Subqueries

Same question, two shapes: name your intermediate steps with WITH, or nest them inline. Readability is the difference.

Date Spines and CROSS JOINs

No row for quiet days? Build a calendar spine, cross it with your categories, and LEFT JOIN the events on β€” zeros included.

EXISTS vs IN / NOT IN

Three ways to ask β€˜who has a matching row?’ β€” plus the NULL trap that makes NOT IN silently return nothing.

Window Functions

ROW_NUMBER, RANK, LAG/LEAD, rolling averages and running totals β€” per patient, per category β€” without collapsing rows.

5 posts β€” all in this box, scroll for more

See all →

No topics match that filter.