Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

The hardest part of inference is usually choosing the procedure, not running it. This guide walks you from a description of your data to the exact test — and to the mosaic/BSDA function that performs it. It uses the same formula interface, goal(y ~ x, data = D), as the rest of the course, so once the guide names your test you already know how to call it.


11. The master decision table

Response# groupsPaired?ProcedureR function (mosaic / BSDA)
Categorical (binary)1One proportion (z)prop.test(x, n, p = ) (or binom.test)
Categorical (3+ categories)1Chi-square goodness of fitchisq.test(tally(~ var, data = D), p = ...)
Categorical (binary)2Two proportions (z)prop.test(c(x1, x2), c(n1, n2))
Categorical × categorical2 varsChi-square independencexchisq.test(tally(~ y + x, data = D))
Numerical1One-sample tt.test(~ y, data = D, mu = ) — or tsum.test() from summary stats
Numerical2NoTwo-sample (independent) tt.test(y ~ group, data = D)
Numerical2YesPaired tt.test(after, before, paired = TRUE)
Numerical3+One-way ANOVA (F)anova(aov(y ~ group, data = D))
Two numerical (association)Correlation / linear regressioncor(y ~ x, data = D) / lm(y ~ x, data = D)

Reading the whole table top to bottom is itself the decision procedure: find the row that matches your response type, number of groups, and pairing, and the last column is the call to make.


22. Decision flow, in words

Follow the branches in order.

Step 1 — Response type?

Step 2A — Numerical: how many groups?

Step 2B — Categorical: how many variables/groups?


33. Confidence interval, test, or both?

The table picks the procedure; you still decide what you want from it:

The t.test, prop.test, and BSDA *sum.test functions report both by default — the printout gives you the test decision and the matching interval. For a regression or ANOVA model, read the interval with confint(model).


44. Worked routing examples


55. Before you trust any result — check the conditions

Every procedure assumes something. Here is the short version; the chapter that introduces each test lists the exact conditions for your case.

ProcedureKey conditions
One / two proportionsIndependence; success–failure (≥ 10 successes and ≥ 10 failures, in each group)
Goodness of fit / independenceIndependence; every expected count ≥ 5
One / two / paired means (t)Independence; population roughly Normal or n30n \ge 30 (for paired, the differences are Normal)
ANOVA (F)Independence; roughly Normal within groups; comparable spreads (largest SD < ~2× smallest)
Correlation / regressionLinearity; independent, roughly Normal residuals with constant spread

If a condition fails, the result may be misleading. The chapter that introduces each test explains what to do (for example, a randomization or bootstrap approach when Normality is doubtful — see Ch. 7 and Ch. 8).