D:SDATA with STATA

Applied Research
Walkthroughs.

Short teaching examples connect a substantive question to the data structure, statistical method, STATA syntax and interpretation.

QUESTION · METHOD · CODE · INTERPRETATION

Follow the analytical decisions.

These examples are inspired by common questions in applied research. They use generic variable names rather than confidential or restricted research data.

PUBLIC HEALTH · SURVEY DATA

Access to healthcare

Estimate inequities in unmet healthcare need using a complex population survey.

Open walkthrough

Research question

Does the prevalence of unmet need differ by income after accounting for age, gender and region?

Why this method?

The outcome is binary and the survey design includes weights, strata and clusters.

svyset psu [pweight=weight], strata(stratum) svy: logistic unmet_need i.income age i.gender i.region margins income

Interpretation focus

Report adjusted probabilities or contrasts alongside odds ratios, and retain the survey design in variance estimation.

EPIDEMIOLOGY · BINARY OUTCOME

A binary health outcome

Examine whether an exposure is associated with a yes-or-no health outcome.

Open walkthrough

Research question

Is exposure associated with the outcome after adjustment for pre-specified confounders?

Why this method?

Logistic regression respects the binary outcome and estimates adjusted odds.

logistic outcome i.exposure age i.gender comorbidity margins exposure marginsplot

Interpretation focus

An odds ratio is not a risk ratio. Predicted probabilities often make the magnitude easier to understand.

HEALTH EQUITY · COUNT OUTCOME

Counts of adverse experiences

Model the number of adverse experiences reported by each participant.

Open walkthrough

Research question

How does the expected count vary across social or demographic groups?

Why this method?

Poisson regression models non-negative counts; negative binomial regression may be preferable with substantial overdispersion.

summarize adverse_count, detail poisson adverse_count i.group covariates, irr vce(robust) nbreg adverse_count i.group covariates, irr

Interpretation focus

Translate the incidence-rate ratio into a percentage difference in the expected rate, conditional on the model.

BIOSTATISTICS · MEASUREMENT

Building a multi-item scale

Evaluate whether several survey items can support a coherent summary measure.

Open walkthrough

Research question

Do the items measure a sufficiently coherent construct, and how should the score be created?

Why this method?

Item distributions, inter-item relationships and reliability should be examined before constructing the scale.

tab1 item1-item6, missing alpha item1-item6, item std egen scale_mean = rowmean(item1-item6)

Interpretation focus

Cronbach’s alpha is evidence about internal consistency, not proof of unidimensionality or validity.

HEALTH EQUITY · INTERACTION

Differences in an exposure effect

Assess whether an adjusted association differs across population groups.

Open walkthrough

Research question

Does the relationship between exposure and outcome vary by group?

Why this method?

An interaction term represents effect modification on the model’s chosen scale.

logistic outcome i.exposure##i.group covariates margins group, at(exposure=(0 1)) margins group, dydx(exposure)

Interpretation focus

Interpret predicted probabilities and contrasts. The interaction coefficient alone rarely communicates the substantive pattern clearly.

ECONOMICS · PANEL DATA

Trade or policy change over time

Use repeated observations to examine within-unit changes in an economic outcome.

Open walkthrough

Research question

How is a policy change associated with an outcome within countries, industries or firms over time?

Why this method?

Fixed effects account for stable unit characteristics while time indicators absorb common period shocks.

xtset unit year xtreg outcome policy controls i.year, fe vce(cluster unit) estimates store fixed_effects

Interpretation focus

The coefficient is identified by within-unit change. A causal claim still depends on the policy design and identifying assumptions.

Move from estimates to substantive language.

Open the interpretation guide →