Project 001: ED-to-Inpatient Pathways

Who is admitted from the emergency department, how long do they stay, and what changes with asthma?

From Emergency Department to Inpatient Care: Admission, Length of Stay and Asthma-Related Risk in Simulated Alberta Administrative Data.

An end-to-end health data science project on one shared synthetic dataset: 30,000 Alberta-style emergency visits (NACRS) and 60,000 inpatient abstracts (DAD) across 30 hospitals.

Ten memos take it from raw extract to answers. They ask what is linked to admission, link admitted visits to their inpatient stays to ask what is linked to length of stay, then build a fair comparison for adults with asthma, by hospital and by region, using propensity-score matching, outcome regression and mixed models. Because the true effects are built into the data, the project also checks whether those methods recover them.

Every patient record is simulated. The 30 hospital names are real Alberta emergency departments used as reference labels only; no result describes how those hospitals actually perform.

A01 30,000 ED visits at 30 hospitals (NACRS-style)
24,190 not admitted: 23,585 sent home, 605 left without being seen
A03 5,810 admitted to hospital (19.4%)
1,177 not linked: 888 with a missing or mistyped ID, 289 admitted more than 6 hours after ED discharge
A04 4,633 linked to a DAD inpatient stay (79.7%)
Searched across 60,000 DAD inpatient abstracts (A02): same PHN, admitted within 6 hours of ED discharge
A05 4 days median inpatient stay (mean 4.79), modelled on ED time and CTAS

Adult asthma extension, from the same 30,000 visits

24,926adult ED visits at 30 hospitals
8,170main diagnosis asthma, vs 16,756 other adult visits
A067,700matched pairs within hospital (94.2%)
A08All adultsregional GLMM: Calgary, Edmonton, Other
470 asthma visits not matched: 373 with no control in the caliper, 97 outside common support
A07Same pairsoutcome regression and standardized risk
Cohort flow for the shared synthetic dataset. Counts come from memos A01–A08.

Four questions, four answers

Headline results from the project summary, Memo A09. Every figure comes from simulated data.

Full project overview

Q1 · Admission · A03

Triage level drives admission

The adjusted odds of admission fall at every CTAS level, to an odds ratio of 0.056 at CTAS 5 versus CTAS 1. Time before the disposition decision adds little: OR 1.024 per 60 minutes (95% CI 1.003 to 1.045).

Q2 · Stay in hospital · A04–A05

ED time does not predict inpatient stay

4,633 of 5,810 admitted visits (79.7%) link to an inpatient stay. Once CTAS is included, ED stay is unrelated to inpatient stay (−0.011 days per 60 minutes, 95% CI −0.056 to 0.034). Stays after a CTAS 5 visit are 2.78 days shorter than after CTAS 1.

Q3 · Asthma · A06–A07

Asthma adds about 10 points of admission risk

Across 7,700 within-hospital matched pairs, admission is 31.8% versus 21.8%: +10.00 points (95% CI 7.59 to 12.41). Outcome regression on the same pairs gives +9.54 points (8.47 to 10.61). The value built into the simulation is 10.38.

Q4 · Regions · A08

The asthma gap differs by region

With a common patient mix, Edmonton-region hospitals admit adult asthma visits more often than Other (+7.23 points, 95% CI 2.16 to 12.99); Calgary's −5.72 points is not established. The asthma gap differs by region (χ² = 78.0 on 2 df, p < 0.001).

Do the methods work? Across repeated simulations with a known truth, the asthma estimators are biased by at most 0.61 points, 95% intervals cover the truth 92%–98% of the time, and false-positive rates are 3%–4% when there is no effect. Read the A09 summary

From raw extract to model, in ten memos

The project is written the way a consulting analysis would be: one memo per step, each reading the output of the one before it.

Source on GitHub

Build the data

Import, derive and profile.

  1. A00Import both workbooks and derive the research variablesData preparation
  2. A01Profile the emergency cohort: coverage, distributions, quality checksDescriptive statistics
  3. A02Profile the inpatient cohortDescriptive statistics

Admission and length of stay

The two original questions.

  1. A03Are ED time before the disposition decision and triage level linked to admission?Logistic regression
  2. A04Link admitted ED visits to inpatient staysDeterministic record linkage, 6-hour window
  3. A05How do ED stay and acuity relate to inpatient length of stay?Linear regression, acute-stay sensitivity

Adult asthma

Matching, outcome regression and regional models.

  1. A06Admission risk for asthma vs. similar patients at the same hospitalWithin-hospital propensity-score matching
  2. A07Standardized admission risk on A06's fixed pairsOutcome regression, hospital fixed effects
  3. A08Do asthma admissions, and the asthma gap, differ across Calgary, Edmonton and other regions?Logistic GLMM, hospital random intercepts
A09Project summary. The questions, data, methods and results of A00–A08 in one memo, including the simulation checks.Start here for the whole project

Project 002: Calgary Housing Observatory

What does Calgary's housing market look like, community by community?

An interactive R Shiny dashboard on 21,279 Calgary residential listings, matched to the City of Calgary's official community boundaries. Filter by price, home type, bedrooms and year built, and the community map, charts and table all update together.

The spread is far wider between communities than between sectors: among communities with at least 50 listings, median list prices run from about $272,000 in Lincoln Park to $2.26 million in Elbow Park.

Listings
21,279
in 220 communities
Median list price
$575,000
$393 per square foot
Median days on market
28
24 for houses, 39 for apartments
Highest sector median
West
$743,000, against $440,000 in the East

Community-level summaries of one MLS listings extract: no addresses, MLS numbers or listing-level records are published. Figures are list prices, not sales or valuations.

A notebook for data analysis

I'm Miss V, a data analysis enthusiast with wide interests and one main pull: large data, the kind that lives in administrative records and big tables, and only becomes useful after careful cleaning, linkage and modelling. Healthcare administrative data is the area I care about most. The V Lab is where I learn each method properly, write it up as a long-form guide, and then put it to work in a project.

Projects use synthetic, public or community-level data only. The health projects follow the official documentation for datasets like NACRS and DAD, and the learning guides are open on GitHub.

How the lab works

Methods
Regression for binary and count outcomes, survival analysis, multilevel models, propensity scores, causal inference, meta-analysis
Data
Healthcare administrative data (NACRS, DAD, PIN, practitioner claims, lab and vital statistics), housing listings, record linkage and cohort design
Tools
R, R Markdown, Shiny, renv, lme4, ggplot2, Plotly, Snowflake SQL, ArcGIS, and my own R package, VLabR

Recently updated