Planned contrasts

Planned contrasts and trend analysis with custom weights

When you knew the hypothesis before collecting the data, testing all pairs is both wasteful and a little dishonest. A planned contrast tests the specific comparison you had in mind, with more power, and a trend analysis asks whether the outcome changes monotonically across ordered groups. Both are in one dialog.

The honest part

What a contrast is, and what the weights mean

A planned contrast is a single linear combination of the group means, defined by a weight for each group. For example, weights of (−1, 1, 0) compare the second group against the first and ignore the third. The estimate L is the weighted sum of the group means, and the test asks whether L differs from zero. A set of contrasts that partition the between-groups variation lets you decompose the overall effect into the specific questions you care about.

The convention is that the weights of a contrast sum to zero (Σ cᵢ = 0); that makes the estimate a genuine comparison in which the grand mean cancels out. Magic Stat accepts weights that do not sum to zero as well, because the estimate is still a legitimate linear combination — but it flags the row and explains that the estimate now includes the grand mean, instead of silently returning a number with a different meaning. It also flags whether the design is balanced for that contrast (Σ nᵢ cᵢ = 0), which is what makes orthogonal contrasts add up to the between-groups sum of squares.

Trend analysis is the special case where the groups are ordered — doses, times, concentrations — and the contrast weights are the polynomial coefficients for linear, quadratic and cubic components. One F and p per degree tell you whether the outcome rises (or falls) linearly, bends, or does both. This is the same decomposition R produces with summary(aov) and a split.

What it does

What Magic Stat gives you for planned contrasts

How it works

Weights in, contrast out

  1. Load your data. the response variable and the grouping factor whose level order defines the group order (first appearance in the data).
  2. Open Statistics → Planned Contrasts & Trend. the dialog holds both modes.
  3. Choose the mode. Custom contrasts, or Trend analysis (ordered groups).
  4. Enter the weights or the degree. one column of weights per contrast, or the maximum polynomial degree (linear = 1, quadratic = 2, cubic = 3…).
  5. Read and export. L, SE, t, df, p and SS per contrast, or one F/p per polynomial degree; then export the report to .docx/.html/.md.
Options

The settings, in the dialog

Custom contrasts: one contrast per column, one weight per factor level; weights that sum to zero are a proper contrast.

Trend analysis: maximum polynomial degree (1 = linear, 2 = quadratic, 3 = cubic…), capped at the number of groups minus one.

Reported per contrast: L (estimate), SE, t, df, p and SS, plus the flags is_contrast and balanced_design and any explanatory notes.

Reported per degree (trend): component name, SS, F, df and p.

Frequently asked

Planned contrast questions, answered honestly

Planned contrasts or post-hoc tests?

Planned contrasts when you specified the comparison before seeing the data — they have more power because they test fewer hypotheses. Post-hoc tests when you need all pairwise differences or did not pre-specify the contrast. Choosing a contrast after inspecting the data and reporting it as planned is the practice pre-specification exists to prevent.

Do the weights have to sum to zero?

Σ cᵢ = 0 is what makes the estimate a contrast in which the grand mean cancels. If the weights do not sum to zero, the estimate is still a valid linear combination but now includes the grand mean, and the app says so in a note rather than refusing — the same behaviour as R and emmeans.

Can I run several contrasts at once?

Yes — one per column. If they are orthogonal, their sums of squares add up to the between-groups sum of squares, which the app reports so you can confirm the decomposition is complete.

Trend or contrasts?

Trend when the groups are ordered (doses, times) and the hypothesis is about the shape of the response — linear, curved, and so on. Custom contrasts when the question is a specific comparison, such as a control against the average of the treatments.

Is my data uploaded somewhere?

No. The computation runs locally; the only automatic signal is an anonymous installation counter.

ANOVA → Post-hoc tests → Power analysis →