RainbowStats · Command reference
ANCOVA
Compare group means at a common covariate value and test whether the fitted slopes differ.
Syntax
ANCOVA(C,"outcome","covariate","group")
EX(C,"ancova:outcome:covariate:group")Create C with CROSS_SECTION from a CSV. Use the exact names of three distinct columns. Outcome and covariate must be numeric. The fit uses complete rows from the current selection. Each of at least two groups needs variation in the covariate, and the separate-slopes fit needs positive residual degrees of freedom. ANCOA is an alias.
Try it in the workspace
Cats=CROSS_SECTION("https://cran.r-universe.dev/MASS/data/cats/csv")
Fit=ANCOVA(Cats,"Hwt","Bwt","Sex")
EX(Fit,"slideshow")Each point is one cat. The chart plots heart mass (g) against body weight (kg) and draws each group’s fitted line over its observed range. The interaction F-test compares a common slope with separate slopes under independent, constant-variance errors.
Available extracts
Save the result as Fit, then run an extract such as EX(Fit,"summary").
| Key | Result |
|---|---|
summary | Complete and omitted rows, common slope, interaction F statistic, degrees of freedom and p-value. |
coefficients | Group sizes, observed means, adjusted means at pooled mean X, differences from the first sorted group, and group-specific slopes. |
chart | Grouped scatterplot and separate fitted lines. |
slideshow | Default display with summary, coefficients and chart. |
Reference result
For 144 cats the unadjusted male–female difference is +2.1206 g. With a common slope of 4.07577 g/kg, the adjusted difference is −0.08210 g. The interaction test gives F(1, 140) = 4.00771 and p = 0.04722. When slopes differ, the predicted group difference depends on the body weight used for comparison.