Projects

Applied data science in Alberta: a health-services project on simulated administrative data, and a community-level look at Calgary housing.

Project 001: ED-to-Inpatient Pathways

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

Project 001 follows patients along one care pathway using a single shared synthetic dataset of Alberta-style NACRS and DAD records. It asks which factors are linked to being admitted and to how long patients then stay, and goes on to study admission risk and regional differences for adults who come to the emergency department with asthma.

It tackles two kinds of problem at once: health services research questions, and the methods question of how to answer them credibly and reproducibly. Memos A00–A09 connect data preparation, record linkage, statistical analysis and simulation checks into one complete workflow, and A09 summarizes the whole project.

Project 001 cover: ED-to-Inpatient Pathways

One patient pathway, two data sources

  1. Emergency visitDiagnosis, triage acuity, timing and hospital
  2. Admitted or notThe disposition at the end of the ED visit
  3. Length of stayHow long the inpatient stay lasts
NACRS
One record per emergency visit: main diagnosis, triage level (CTAS), visit times, hospital and whether the patient was admitted. 30,000 ED visits, 50 analytic variables.
DAD
One record per inpatient stay: admission, discharge and length of stay. 60,000 inpatient records, 64 analytic variables.

Each of the 30,000 ED visits is a different patient. The 5,810 admitted visits each continue as one DAD abstract at the same hospital, and the other 54,190 DAD abstracts are inpatients from outside the ED extract, so the 90,000 rows are not 90,000 independent patients. Every memo draws on these two sources.

Four research questions

QuestionWhy it mattersMethods and memos
How are ED time before the disposition decision and triage acuity related to the chance of admission?Understanding admission need among ED patients, and how time-based measures should be readA03 logistic regression, built on data preparation and profiling in A00–A02
Among admitted visits that link to an inpatient abstract, is time spent in the ED related to how long patients then stay in hospital?Treats the ED visit and the inpatient stay as one continuous episode of careA04 links NACRS to DAD, A05 linear regression on the linked stays
Are adults who come to the ED with asthma more likely to be admitted than patients with other reasons for their visit?Separates differences in patient background from admission risk associated with asthmaA06 within-hospital propensity-score matching, A07 outcome regression on those fixed pairs
Does asthma admission, and the asthma gap, differ between Calgary, Edmonton and other regions?Asks whether region matters beyond patient mix and hospital differencesA08 logistic GLMM with a hospital random intercept, on all adult visits

The first two questions are the project's original focus. The link between ED time and admission cannot be read as "the longer you wait, the more likely you are to be admitted": how complex the case is, the tests it needs and bed availability all shape that time. Waiting after the decision to admit, in particular, cannot be a cause of a decision that came before it. A03's main analysis therefore uses ED time up to the disposition decision, and both A03 and A05 are associational analyses.

What the original questions found

Admission (A03)

Triage level dominates. Compared with CTAS 1, the adjusted odds of admission fall at every level, to an odds ratio of 0.056 at CTAS 5. Time before the disposition decision has only a small adjusted association: OR 1.024 per 60 minutes (95% CI 1.003 to 1.045).

Linkage (A04)

4,633 of 5,810 admitted visits (79.7%) link to exactly one DAD abstract under the rule "same PHN, admitted within 6 hours of ED discharge". Every unlinked visit traces to a defect built into the simulation: 888 missing or mistyped identifiers and 289 late admissions.

Length of stay (A05)

On its own, a longer ED stay looks linked to a longer inpatient stay (+0.147 days per 60 minutes), but the association disappears once CTAS is included: −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.

Linked inpatient stays average 4.79 days (median 4). Acute stay, which excludes alternate-level-of-care days, gives the same picture. These are associations in simulated data, not causal effects.

Adult asthma: building a fairer comparison

The asthma study moves the project from describing associations to designing a fair comparison. From NACRS it selects visits by patients aged 18 or over whose main diagnosis for that visit is in the asthma J45 family. The study population is people who came to the ED because of asthma this time, not everyone with a history of asthma and not everyone presenting with shortness of breath. The shared data hold 24,926 adult ED visits, of which 8,170 have asthma as the main diagnosis.

A straight comparison of admission rates would be unfair, because the asthma group may differ in age, smoking, obesity, medical history and past ED use. A06 therefore uses propensity scores to find non-asthma patients with similar backgrounds at the same hospital, producing 7,700 matched pairs. After matching, admission is 31.8% in the asthma group and 21.8% in the controls: a risk difference of 10.00 points (95% CI 7.59 to 12.41). A07 keeps those same pairs and standardizes predicted risks with a logistic outcome model.

A07 standardized results on the matched pairs
Adjusted admission probability, asthma31.8%
Adjusted admission probability, matched controls22.2%
Risk difference+9.54 points
95% CI 8.47 to 10.61
Risk ratio1.43
95% CI 1.37 to 1.49

These estimates apply to the asthma visits that were successfully matched. Matching improves comparability on measured background factors, but it does not remove all confounding, and matching alone cannot prove a causal effect in the real world.

Two regional questions

Among asthma patients only

When age, medical history and severity on arrival are comparable, does the probability of admission differ across the three regions?

Asthma versus other visits

Does the extra admission risk associated with asthma differ by region? This is the asthma × region interaction in the model. The two questions are related but mean different things.

The 30 hospitals are split evenly across three study regions. Calgary and Edmonton include hospitals in surrounding towns, and Other is made up of selected hospitals from the Central, North and South zones. Patients are grouped by the region of the hospital they attended, not where they live. A08 fits this on all 24,926 adult visits, not the matched pairs: a logistic GLMM with region as a fixed effect and a random intercept for hospital. In the simulation, adult asthma patients in Edmonton have a higher standardized admission probability than those in other regions (+7.23 points, 95% CI 2.16 to 12.99). Calgary's estimate is lower (−5.72 points, 95% CI −10.53 to 0.25), but that interval includes zero, so the direction is not established. The gap between asthma and other visits does differ clearly by region (joint test χ² = 78.0 on 2 degrees of freedom, p < 0.001). A higher or lower admission rate is not, on its own, a measure of better or worse care.

Can the methods recover the truth?

Because the patient data are simulated, the true effects built into the data are known. The project can therefore generate many datasets with and without an effect and check whether matching, regression and mixed models are biased and whether their confidence intervals can be trusted. That says far more about how a method performs than running one model once and reading off a p-value.

Bias
At most 0.61 percentage points for the asthma estimators in A06 and A07
Interval coverage
92%–98% across A06–A08
False positives
3%–4% when there is no true effect
Main estimates
Both A06 (10.00 points) and A07 (9.54 points) intervals contain the true 10.38 points

Where the project stands

The shared data, memos A00–A09, the main models and the simulation checks are all complete. A09 is the project summary: it restates the design and collects the results from A00 through A08. What the project offers is a reproducible worked example of ED-to-inpatient research, along with a test of the methods used. Whether these effects exist among real Alberta patients is a question only research on real data can answer.

The names of the 30 hospitals come from real public sources, but the patients, admission outcomes and hospital and regional effects are all simulated. None of these results can be used to judge any real hospital.

Project 002: Calgary Housing Observatory

Calgary Housing by Community: Prices, Structure Mix and Spatial Patterns in a Residential Listings Extract

Project 002 turns one extract of Calgary residential listings into an interactive map of the city's housing market. Each listing is matched to its official City of Calgary community, so price, home type, age and how quickly homes sell can be compared community by community and sector by sector.

Where Project 001 is a modelling project on simulated health records, Project 002 is a descriptive, spatial one on a real market extract. Its craft is in the data work: cleaning a raw listings file, joining it to official geography, and building an R Shiny dashboard on top that is safe to publish.

Project 002 cover: Calgary Housing Observatory

One extract, one map

  1. Listings extractPrice, living area, bedrooms, year built, days on market, structure type, subdivision
  2. Official communitiesSubdivision names matched to City of Calgary community boundaries
  3. DashboardFilters, community maps, charts and a community table
Listings
One record per residential listing, from an MLS extract. 21,328 listings, of which 21,279 are priced at $100,000 or more with a known year built and appear in the dashboard's full view.
Boundaries
The City of Calgary Community District Boundaries from the city's open data portal. Listings are matched by community name, with a 99.9% match rate. 220 communities have listings.

Prices here are list prices in one extract, not sale prices or assessed values. Every figure on this page is a median, so a handful of very expensive or very cheap homes cannot pull it far.

Four questions about place

QuestionWhy it mattersHow the dashboard answers it
How much do prices differ across Calgary's communities and city sectors?A citywide median hides a very wide spread between neighbourhoodsCommunity choropleth of median price, median price by sector
How does the mix of home types shape a community's prices?A community of apartments and one of detached houses are not comparable on price aloneStructure mix chart, price per square foot, structure breakdown for any clicked community
Where do homes sell fastest and slowest?Days on market is a simple signal of how much demand meets the supply in an areaMedian days on market by community, in the map and the community table
How do new suburbs compare with established neighbourhoods?Calgary is growing at its edges while inner-city areas redevelopMedian year built per community, filters on year built

What the extract shows

Citywide

Across 21,279 listings, the median list price is $575,000, or $393 per square foot, and the median listing has been on the market for 28 days.

By home type

Houses are just over half the listings (11,219), at a median of $696,000 and 24 days on market. Multi-family homes sit at $485,000, and apartments at $295,000 with the slowest pace, 39 days.

By sector

The West sector has the highest median price ($743,000) and the East the lowest ($440,000). The Centre has the most listings (4,086), led by the Beltline, the single busiest community with 606.

Bedrooms track price closely: a median of $249,000 for one bedroom, $355,000 for two, $568,000 for three, $710,000 for four and $780,000 for five or more.

Community by community

The spread between communities is far larger than the spread between sectors. Among the 157 communities with at least 50 listings, the median list price runs from about $272,000 in Lincoln Park to $2.26 million in Elbow Park, more than eight times as much.

Price per square foot separates location from size. Elbow Park, Lakeview and North Glenmore Park, all established areas close to the Glenmore Reservoir and the Elbow River, top the list at $699 to $859 per square foot. The inner-city apartment markets of the Beltline and the Downtown East Village have low median prices but mid-range or high prices per square foot, because their homes are small.

The fastest communities are established, higher-priced ones, where the median listing has been on the market for 11 to 15 days: Elbow Park, Parkland, Sundance, Oakridge and Lakeview.

Communities with at least 50 listings, median list price
Elbow Park
Centre · 55 listings
$2,260,500
$859/sf · 11 days
Altadore
Centre · 184 listings
$1,182,450
$576/sf · 18 days
Aspen Woods
West · 170 listings
$1,019,950
$451/sf · 26 days
Beltline
Centre · 606 listings
$315,000
$405/sf · 38 days
Lower Mount Royal
Centre · 63 listings
$279,000
$366/sf · 28 days
Lincoln Park
West · 54 listings
$272,250
$347/sf · 27 days

New suburbs and established neighbourhoods

Built in the last few years

In Rangeview, Hotchkiss, Pine Creek, Belvedere and Alpine Park the median home was built in 2025. They list at $326 to $368 per square foot and have the longest median times on market, 46 to 56 days. Some of that is likely new-build stock listed before completion, which this extract cannot separate out.

Built around 1960

In Westgate, Fairview, Kingsland, Forest Lawn and Brentwood the median home dates from 1959 to 1964. Apart from Forest Lawn, they list at $505 to $607 per square foot, well above the new suburbs, mainly because of where they are rather than what was built.

These are descriptive contrasts between community medians, not a price model. Location, lot size, condition and home type all move together, and the dashboard shows them side by side rather than separating their effects.

How it's built

Prepare
An R script parses prices and areas, groups structure types and matches subdivisions to official communities with sf
Summarize
Community medians are recomputed from the filtered listings every time a filter changes
Explore
Shiny with bslib, leaflet and leaflet.extras, plotly and DT, all reading the same filtered data
Deploy
A Docker image based on rocker/shiny, running as a Render web service

Community level by design

The source is an MLS extract, so the public dashboard shows patterns, not properties. Owner names, phone numbers, street addresses, MLS numbers and parcel-level tax and assessment values are never loaded, there is no listing-level table or download, and the density heatmap places each listing at a jittered point around its community's centre rather than at its parcel.

Educational use only. These figures describe one extract at one point in time. They are not an official market report and not a valuation of any property.

Reference guide

Alberta Health Data Atlas

A learning guide to nine commonly used Alberta administrative health datasets and clinical information systems. It is the reference Project 001 was designed from.

  • DAD, NACRS, Practitioner Claims, Lab, PIN, Vital Statistics, Registry, Sunrise Clinical Manager, Connect Care
  • Deep dives on DAD, NACRS and PIN, with field maps and fictional example records
  • Cohort design, linkage notes, access pathways and a responsible-use checklist
Preview of the Alberta Health Data Atlas

Independent educational resources. Not official publications of Alberta Health Services, the University of Calgary, the Government of Alberta or CIHI, and no patient-level data is included.