Sample datasets

Every dataset here comes from published research, exported unaltered from the R packages that ship it — metadat for the meta-analyses, lavaan and psych for the questionnaire data. Nothing is simulated: when you are learning a method, you want to be able to check your answer against the literature.

Each one is chosen to make a specific lesson visible: a hidden moderator, a funnel plot with a hole in it, zero cells that break a ratio measure, a factor model that only fits once you notice the same question was asked twice.

For Confirmatory factor analysis

Mental ability tests in seventh-grade pupils

Beginner

Scores on nine mental-ability tests from 301 pupils at two schools, the dataset every CFA tutorial starts from. Three tests each for visual perception, verbal comprehension and processing speed.

What to try: Fit the three factors as loaded and note that fit is decent but not excellent. Then read the modification indices: they point at x9, which behaves partly like a visual test. Finally test invariance across the two schools to see how far the instrument travels.

Three factorsMeasurement invarianceThe canonical example

Holzinger KJ, Swineford F. A study in factor analysis: the stability of a bi-factor solution. Supplementary Educational Monographs, No. 48. Chicago: University of Chicago; 1939.
Exported verbatim from lavaan::HolzingerSwineford1939 (lavaan 0.6.19).

Industrialisation and political democracy

Advanced

Bollen's 75-country study of industrialisation and democracy. The same four democracy indicators were recorded in 1960 and again in 1965, which is exactly what makes the naive measurement model strain.

What to try: Fit it as loaded and watch the indices disagree: CFI says the model is fine, RMSEA says it is not. Nothing clears the default modification-index threshold of 10, because the misfit is not one big problem but six small ones — switch the model panel to Advanced and drop the threshold to 4, and the repeated measurements of the same indicator appear (y1 with y5, y2 with y6, y6 with y8). Add them one at a time and watch RMSEA come down.

Repeated measuresCorrelated residualsPoor initial fit

Bollen KA. Structural Equations with Latent Variables. New York: Wiley; 1989.
Exported verbatim from lavaan::PoliticalDemocracy (lavaan 0.6.19).

Big Five personality items

Intermediate

Twenty-five personality items answered on a six-point scale by 2,800 respondents to the SAPA project, five items for each of the Big Five traits.

What to try: A realistic questionnaire rather than a tidy textbook one: some items are reverse-keyed and come back with negative loadings, some responses are missing, and the fit of a plain five-factor model is mediocre in the way real personality data always is. Note what mixed-sign loadings do to omega, then reverse-score those items in your spreadsheet and load it again. Leave the invariance test off for a first run — 2,800 respondents means five model fits and several minutes.

Five factors25 itemsLikertReverse-keyed itemsMissing data

Revelle W, Wilt J, Rosenthal A. Personality and cognition: the personality-cognition link. In: Gruszka A et al., eds. Handbook of Individual Differences in Cognition. New York: Springer; 2010.
Exported verbatim from psych::bfi (psych 2.4.12).

For Meta-analysis

BCG vaccine and tuberculosis

Beginner

Thirteen randomised trials of the BCG vaccine against tuberculosis. The textbook example of a meta-analysis where the pooled effect hides a strong moderator.

What to try: Fit a random-effects model and note I-squared above 90%. Then regress the log risk ratio on absolute latitude: most of that heterogeneity is explained by how far the trial was from the equator.

Binary outcomeClinical trialsMeta-regression

Colditz GA, Brewer TF, Berkey CS, et al. Efficacy of BCG vaccine in the prevention of tuberculosis. JAMA. 1994;271(9):698-702.
Exported verbatim from metadat::dat.bcg (metadat 1.4.0).

Specialist vs. generalist inpatient care

Beginner

Nine studies comparing length of hospital stay for stroke patients under specialist versus generalist care.

What to try: A clean continuous-outcome example. Compare the raw mean difference (days) with the standardised mean difference and decide which one you would actually report.

Continuous outcomeHedges' g

Normand SLT. Meta-analysis: formulating, evaluating, combining, and reporting. Statistics in Medicine. 1999;18(3):321-359.
Exported verbatim from metadat::dat.normand1999 (metadat 1.4.0).

Conscientiousness and medication adherence

Intermediate

Sixteen studies correlating the personality trait conscientiousness with how reliably patients take their medication.

What to try: Correlations are pooled after Fisher's r-to-z transform and reported back on the r scale. Try the design subgroup to see prospective versus cross-sectional studies side by side.

CorrelationsFisher's zPsychology

Molloy GJ, O'Carroll RE, Ferguson E. Conscientiousness and medication adherence: a meta-analysis. Annals of Behavioral Medicine. 2014;47(1):92-101.
Exported verbatim from metadat::dat.molloy2014 (metadat 1.4.0).

Writing-to-learn interventions

Advanced

Forty-eight studies of school writing-to-learn programmes, supplied as pre-computed standardised mean differences with eleven study-level moderators.

What to try: The best dataset here for meta-regression and subgroup work: enough studies to actually support moderators, and a near-null pooled effect that only becomes interesting once you model it.

Pre-computedMeta-regressionEducation48 studies

Bangert-Drowns RL, Hurley MM, Wilkinson B. The effects of school-based writing-to-learn interventions on academic achievement. Review of Educational Research. 2004;74(1):29-58.
Exported verbatim from metadat::dat.bangertdrowns2004 (metadat 1.4.0).

Passive smoking and lung cancer

Advanced

Thirty-seven epidemiological studies of lung cancer risk in never-smokers living with a smoker, as log odds ratios.

What to try: The dataset to use when teaching publication bias. Run the funnel plot, Egger's test, trim-and-fill and PET-PEESE together and see how much of the effect survives.

Publication biasLog odds ratio37 studiesEpidemiology

Hackshaw AK, Law MR, Wald NJ. The accumulated evidence on lung cancer and environmental tobacco smoke. BMJ. 1997;315(7114):980-988.
Exported verbatim from metadat::dat.hackshaw1998 (metadat 1.4.0).

Anti-infective catheters and bloodstream infection

Intermediate

Eighteen trials of anti-infective-coated central venous catheters, several with zero events in an arm.

What to try: A rare-event dataset with zero cells. Compare the default continuity correction against the Peto odds ratio and watch the confidence interval change.

Rare eventsZero cellsBinary outcome

Niel-Weise BS, Stijnen T, van den Broek PJ. Anti-infective-treated central venous catheters. Intensive Care Medicine. 2007;33(12):2058-2068.
Exported verbatim from metadat::dat.nielweise2007 (metadat 1.4.0).

Recovery of consciousness after brain injury

Intermediate

Single-arm studies reporting how many patients in a persistent vegetative state regained consciousness.

What to try: There is no control group here — you are pooling proportions, not comparing arms. Compare the logit and Freeman-Tukey transforms and check whether the interval stays inside 0 to 1.

PrevalenceSingle-armLogit

Pritz MB. Rehabilitation of the persistent vegetative state patient. 1997. Reproduced in the metafor package.
Exported verbatim from metadat::dat.pritz1997 (metadat 1.4.0).

For Structural equation modelling

Presumed media influence on sugar buying

Beginner

123 readers saw an article about a sugar shortage on either the front page or an inside page, then reported how much they thought the article would influence others, how important they judged the topic, and how much sugar they intended to buy.

What to try: The cleanest possible mediation model, and the one most papers are really running. Notice first that fit is perfect — every path is present, so the model has nothing left to be wrong about, and the fit indices are meaningless here. Then read the two indirect effects: the route through presumed influence is the one the authors argued for, and its bootstrap interval sits right on the edge of zero, which is a more honest place to start than a textbook example that works.

MediationObserved variables onlyBootstrapTwo mediatorsJust-identified

Tal-Or N, Cohen J, Tsfati Y, Gunther AC. Testing causal direction in the influence of presumed media influence. Communication Research. 2010;37(6):801-824.
Exported verbatim from psych::Tal_Or (psych 2.4.12).

Reactions to a colleague who protests discrimination

Intermediate

129 women read about a female attorney passed over for promotion who either protested the decision or did not, then rated how appropriate her response was and how much they liked her. Their own belief in pervasive sexism was measured beforehand.

What to try: The mediator does almost all of the work here: protesting makes the attorney better liked, but only because it is judged an appropriate response. Fit the model as loaded and compare the direct path with the indirect one. Then remove the two paths from sexism and watch what happens to both — a covariate that predicts the mediator is not decoration, and dropping it changes the effect you are reporting.

MediationCovariateBootstrapExperiment

Garcia DM, Schmitt MT, Branscombe NR, Ellemers N. Women's reactions to ingroup members who protest discriminatory treatment: the importance of beliefs about inequality and response appropriateness. European Journal of Social Psychology. 2010;40(5):733-745.
Exported verbatim from psych::Garcia (psych 2.4.12).

Industrialisation and political democracy

Advanced

Bollen's 75-country study of industrialisation and democracy: three measures of industrialisation in 1960, and four measures of political democracy recorded in both 1960 and 1965. The canonical full structural equation model, with latent variables on both sides of every path.

What to try: Everything the module does, in one model. The measurement part turns eleven noisy indicators into three constructs; the structural part asks whether industrialisation raises democracy directly, or through the level of democracy a country already had. The six correlated residuals are the same indicator measured twice, five years apart — remove them and watch fit collapse, which is the clearest demonstration you will find that a measurement model is an assumption and not a formality.

Latent variablesFull SEMCorrelated residualsIndirect effect75 countries

Bollen KA. Structural Equations with Latent Variables. New York: Wiley; 1989.
Exported verbatim from lavaan::PoliticalDemocracy (lavaan 0.6.19).