Every analysis
Each entry says when to use the analysis, what data it needs, what aStat reports, and the SAS procedure and R functions it matches.
- Summary statistics
- One-sample t-test
- Two-sample t-test
- Paired t-test
- One-way ANOVA
- Randomized complete block design
- Two-factor ANOVA
- ANCOVA
- Latin square
- Balanced incomplete block design
- Linear regression
- Correlation
- Split-plot
- Repeated measures
- Crossover
- Repeatability
- Random coefficients
- Sire evaluation (BLUP)
- One proportion
- Two-way table
- Logistic or probit model
- Count model
- Ordinal scores
- MANOVA
- Power and sample size
Summary statistics
- Use when
- You want a first look at any sheet, or a table of means for a report.
- Data
- One or more measurement columns, optionally split by a grouping column.
- You get
- n, mean, SD, SE, median, quartiles, minimum, maximum, and coefficient of variation; box plots or mean bars.
- Matches
- SAS PROC MEANS (quartiles use the same definition, R's type 2).
One-sample t-test
- Use when
- You compare one group's mean with a target value, such as a breed standard.
- Data
- One measurement column and the target value.
- You get
- The t-test with a confidence interval, Cohen's d, a normality check, and the Wilcoxon signed-rank test as a backup.
- Matches
- SAS PROC TTEST with H0=; R
t.test().
Two-sample t-test
- Use when
- Two groups of different animals, such as treated and control.
- Data
- A measurement column and a group column with exactly two values.
- You get
- The pooled and Welch t-tests (Welch does not assume equal spread), the folded F test of equal variances, Cohen's d, and the Wilcoxon rank-sum test.
- Matches
- SAS PROC TTEST; R
t.test()andwilcox.test().
Paired t-test
- Use when
- The same animals were measured twice, such as before and after weaning.
- Data
- Two measurement columns, one row per animal.
- You get
- The paired t-test on the differences, Cohen's dz, and the Wilcoxon signed-rank test.
- Matches
- SAS PROC TTEST with PAIRED; R
t.test(paired = TRUE).
One-way ANOVA
- Use when
- Three or more groups of different animals in a completely randomized design.
- Data
- A measurement column and a group column.
- You get
- The ANOVA table, eta squared, Tukey comparisons of every pair with confidence intervals, Levene's test of equal spread, and Welch's ANOVA and the Kruskal–Wallis test as backups.
- Matches
- SAS PROC GLM with LSMEANS / ADJUST=TUKEY; R
lm()andemmeans.
Randomized complete block design (RCBD)
- Use when
- Animals or plots were grouped into blocks (barns, litters, fields, years) and every treatment appears in every block.
- Data
- A measurement, a treatment, and a block column.
- You get
- Type III tests for block and treatment, the relative efficiency of blocking (how many more animals a completely randomized design would have needed), treatment means adjusted for blocks with Tukey comparisons, and the Friedman test when each block holds one animal per treatment.
- Matches
- SAS PROC GLM, MODEL y = block trt.
Two-factor ANOVA (factorial)
- Use when
- Two treatment factors were crossed, such as fertilizer by variety.
- Data
- A measurement and two factor columns. Testing the interaction needs every combination, with replication.
- You get
- Type III tests for both factors and their interaction, means of every combination, an interaction plot, Tukey comparisons, and simple effects (one factor within each level of the other) when the interaction matters.
- Matches
- SAS PROC GLM with SS3, MODEL y = A|B.
ANCOVA
- Use when
- Groups differ in a measurement taken before treatment, such as starting weight, and you want a fairer comparison.
- Data
- A measurement, a group column, and a covariate measured before treatment could affect it.
- You get
- A test that the covariate's slope is the same in every group, Type III tests, the common slope, group means adjusted to the average covariate, and Tukey comparisons.
- Matches
- SAS PROC GLM, MODEL y = trt x.
Latin square
- Use when
- Treatments were blocked in two directions, such as row and column in a poultry house, with each treatment once in every row and column.
- Data
- A measurement, a treatment, a row, and a column column.
- You get
- Type III tests for rows, columns, and treatments, the relative efficiency compared with a completely randomized design (for a standard t × t square), adjusted means, and Tukey comparisons. A 3 × 3 square leaves only 2 error degrees of freedom; aStat warns when error df are few.
- Matches
- SAS PROC GLM, MODEL y = row col trt.
Balanced incomplete block design (BIBD)
- Use when
- Blocks are too small to hold every treatment, such as litters of three piglets testing four creep feeds.
- Data
- A measurement, a treatment, and a block column. Each treatment appears at most once per block.
- You get
- Treatment tests within blocks (the intra-block analysis), the design constants (block size k, replications r, and how often each pair shares a block, λ), the efficiency factor, and means adjusted for blocks with Tukey comparisons. Raw means are biased in these designs, so aStat reports adjusted ones.
- Matches
- SAS PROC GLM, MODEL y = block trt, with LSMEANS.
Linear regression
- Use when
- You want to predict or explain one measurement from one or more others, such as body weight from heart girth.
- Data
- An outcome and 1 to 10 predictor columns, all numeric.
- You get
- Coefficients with confidence intervals, R² and adjusted R², the overall F test, a check for influential points (Cook's distance), and variance inflation factors when predictors overlap.
- Matches
- SAS PROC REG; R
lm().
Correlation
- Use when
- You want to know which measurements rise and fall together, without choosing an outcome.
- Data
- 2 to 20 numeric columns. Rows missing a value are left out pair by pair.
- You get
- Pearson, Spearman, and Kendall correlations with p-values, described as weak to very strong.
- Matches
- SAS PROC CORR (PEARSON, SPEARMAN, KENDALL).
Split-plot
- Use when
- One factor was applied to whole units and a second within them, such as ration fed to each steer and aging time applied to cuts from that steer.
- Data
- A measurement, the whole-plot factor, the sub-plot factor, and the whole-plot unit (or block) column.
- You get
- Type III F tests with Satterthwaite degrees of freedom, so the whole-plot factor is tested against the variation between whole plots and the sub-plot factor against the smaller variation within them; variance components; means; and comparisons within each whole-plot level.
- Matches
- SAS PROC MIXED with RANDOM unit(A) and DDFM=SATTERTH; R
lme4andlmerTest.
Repeated measures
- Use when
- Each animal stays on one treatment and is measured several times, such as body weight every two weeks.
- Data
- One row per animal per time: a measurement, a treatment, a time, and an animal ID column (up to 20 times).
- You get
- Tests for treatment, time, and their interaction with Kenward–Roger degrees of freedom; four covariance structures (unstructured, AR(1), compound symmetry, Toeplitz) compared by AIC, or the one you choose; means over time; and treatment differences at each time.
- Matches
- SAS PROC MIXED with REPEATED / TYPE= and DDFM=KR (aStat uses the linear form of Kenward–Roger that SAS uses); R
mmrm.
Crossover
- Use when
- Each animal received the treatments in turn over periods, with a washout between them.
- Data
- One row per animal per period: a measurement, a treatment, a period, and an animal ID column. aStat finds each animal's sequence from the data.
- You get
- Tests for sequence, period, and treatment, with animals as a random effect; an optional carryover test (3 or more periods); variance components; and treatment means with Tukey comparisons. In a two-period design, a significant sequence effect can signal carryover.
- Matches
- SAS PROC MIXED, MODEL y = sequence period trt; RANDOM animal(sequence).
Repeatability (variance components)
- Use when
- Each animal (or herd, or pen) has several records and you want to know how much of the variation is lasting differences between them, such as litter size over several farrowings.
- Data
- A measurement and a group column with at least 3 groups.
- You get
- REML variance components, repeatability (the intraclass correlation), a likelihood ratio test of the group variance, the overall mean, and each group's predicted (BLUP) mean beside its raw mean.
- Matches
- SAS PROC MIXED with RANDOM group.
Random coefficients
- Use when
- You want the average growth line, and how much animals or pens differ in their own slopes.
- Data
- A measurement, a numeric predictor (such as day), and a group column, with each group measured at 2 or more predictor values.
- You get
- The average intercept and slope, the variances of intercepts and slopes and their correlation, a test of whether slopes differ, and each group's own line.
- Matches
- SAS PROC MIXED, RANDOM intercept x / SUBJECT=group TYPE=UN.
Sire evaluation (BLUP)
- Use when
- You have progeny records by sire, and possibly dam, and want heritability and a ranking of sires.
- Data
- A measurement, a sire column, and optionally a dam column (dams within sires). One row per offspring.
- You get
- Variance components, heritability (four times the sire share of variance), and each sire's EPD (half his breeding value), breeding value, predicted progeny mean with its standard error, and accuracy, best sires first. Predictions come from Henderson's mixed model equations.
- Matches
- SAS PROC MIXED, RANDOM sire dam(sire).
Heritability from fewer than about 20 sires is very imprecise; aStat warns when there are fewer.
One proportion
- Use when
- You want a rate, such as the dystocia rate in a herd, with a confidence interval, or to compare it with a target rate.
- Data
- A column of outcomes, and which value counts as the event.
- You get
- The proportion, the exact (Clopper–Pearson) and Wald intervals, an exact test against the target if you give one, and a frequency table.
- Matches
- SAS PROC FREQ with BINOMIAL.
Two-way table
- Use when
- You want to know whether two categorical columns are related, such as dystocia by sire breed, without fitting a model.
- Data
- Two columns with 2 to 20 values each.
- You get
- Counts with row percentages, Pearson's chi-square, and Fisher's exact test (which the answer uses when expected counts are small). For a 2 × 2 table, the risk in each row, risk difference, relative risk, and odds ratio with its confidence interval.
- Matches
- SAS PROC FREQ with CHISQ, EXACT, and MEASURES.
Logistic or probit model
- Use when
- The outcome is yes or no (pregnant or open, cleared or not) and you have treatments, blocks, or a dose.
- Data
- Either one row per animal with a yes/no column, or rows of events out of trials (lambs cleared out of lambs dosed). Add a treatment, a covariate, or both, and optionally a block, fixed or random.
- You get
- Likelihood ratio tests for each term, the estimated chance of the event in each group, odds ratios between groups (logit) or differences in probability (probit), the effect of each unit of the covariate, a test of equal slopes, and, for a dose alone, the dose at which half respond (ED50). Checks cover all-or-none groups, few events, and overdispersion.
- Matches
- SAS PROC GENMOD (fixed blocks) or PROC GLIMMIX (random blocks) with DIST=BINOMIAL; R
glm()orlme4::glmer().
Count model
- Use when
- The outcome is a count: fecal egg counts, lesions, piglets born alive.
- Data
- A column of whole numbers of 0 or more, plus a treatment, a covariate, or both, and optionally a block.
- You get
- Poisson and negative binomial fits compared by AIC (or the one you choose), likelihood ratio tests, estimated mean counts, ratios between groups, and an overdispersion check. Negative binomial tests refit the spread parameter for each smaller model.
- Matches
- SAS PROC GENMOD with DIST=POISSON or DIST=NEGBIN; R
glm()andMASS::glm.nb().
Ordinal scores
- Use when
- The outcome is an ordered score, such as locomotion 1 (sound) to 5 (severely lame), where the steps between scores need not be equal.
- Data
- Numeric scores with 3 to 10 values (code text categories as numbers in order first), plus a treatment, a covariate, or both, and optionally a fixed block.
- You get
- Likelihood ratio tests, the expected mean score in each group, the chance of each score in each group, and odds ratios of a higher score between groups.
- Matches
- SAS PROC GENMOD with DIST=MULTINOMIAL LINK=CUMLOGIT; R
MASS::polr().
MANOVA
- Use when
- You measured several traits on each animal, such as milk yield, fat, and protein, and want to test them together.
- Data
- 2 to 10 measurement columns and one or two factors.
- You get
- Wilks' lambda, Pillai's trace, the Hotelling–Lawley trace, and Roy's greatest root with Type III tests; each trait's own F test; means; and how strongly the traits are related within groups. The answer leads with Pillai's trace, which holds up best when assumptions are not quite met.
- Matches
- SAS PROC GLM with MANOVA H=; R
summary.manova()F approximations.
Power and sample size
- Use when
- You are planning a study: how many animals do you need, or what chance does a planned study have of finding the effect?
- Data
- None. Choose the design (one sample, paired, two groups, three or more groups, or two rates), then enter the effect you expect and its standard deviation (or the expected rates).
- You get
- The number of animals needed (rounded up) or the power, the standardized effect size, and a power curve over study sizes.
- Matches
- SAS PROC POWER (two-sided t power counts both tails, as SAS does); R
power.t.test(),power.anova.test(), andpower.prop.test().