RMResearch Metrics AfricaTransparent methods library

DEMONSTRATION CASE USING SYNTHETIC DATA · SYNTHETIC CASE STUDY · R

From a binary outcome to
an honest adjusted model.

A reproducible demonstration of how a public-health question becomes a logistic-regression workflow—with recoding, missingness, diagnostics and evidence limits visible.

THE QUESTION

After accounting for age and sex, are smoking and low physical activity associated with elevated blood pressure in this synthetic adult sample?

WORKFLOW

Four decisions before interpretation.

The model is only the middle of the analysis. Coding, missingness and diagnostic decisions determine what its coefficients can mean.

01

Define

Outcome coded 1 for elevated measured blood pressure and 0 otherwise. Predictors were defined before modelling; age was scaled in 10-year units.

02

Audit

Ranges, duplicates and cross-field logic were checked. Seven rows with missing outcome were excluded; predictor missingness was described, not silently imputed.

03

Fit

A pre-specified multivariable logistic model used age, sex, current smoking and low physical activity. No stepwise p-value hunting was used.

04

Check

Linearity in the logit for age, influential observations, variance inflation, calibration and discrimination were reviewed before reporting.

INSPECTABLE R CODE

The method is not hidden behind screenshots.

The downloadable script imports the synthetic CSV, preserves source fields, scales age, fits the declared binomial model and prints adjusted odds ratios with confidence intervals.

Download the complete .R script
fit <- glm(
  elevated_bp ~ age_10_years + sex +
    current_smoker + low_physical_activity,
  data = data,
  family = binomial(link = "logit")
)

exp(cbind(OR = coef(fit), confint.default(fit)))

ILLUSTRATIVE RESULTS

Adjusted estimates, not causal claims.

Values below are synthetic and demonstrate reporting structure. They are not findings about a real population.

PredictorAdjusted OR95% CIp-value
Age, per 10 years1.281.11–1.480.001
Current smoker1.741.10–2.770.019
Low physical activity1.460.94–2.280.090
Female0.920.61–1.390.690
RESPONSIBLE INTERPRETATION

Holding the listed variables constant, synthetic current smokers had estimated odds of elevated blood pressure 1.74 times those of non-smokers (95% CI 1.10–2.77). Because the design is cross-sectional, this association does not establish temporal order or causality. Residual confounding and measurement error remain possible.

MODEL REVIEW

The result passed a reporting gate—not a truth test.

1.18Maximum VIF

No concerning collinearity signal among the included predictors.

0.73Illustrative AUC

Moderate discrimination; not a clinical validation claim.

VisibleCalibration check

Observed-versus-predicted risk was reviewed across probability groups.

RetainedInfluential rows

Sensitivity review did not justify undocumented deletion.

YOUR STUDY WILL NEED ITS OWN MODEL

Use the case study to inspect our thinking—then scope your question.

We will not copy this model onto a different design. Start with objectives, variables, sampling and the decision the analysis must support.

Explore statistical analysis support ↗