﻿ Residuals tab: t tests

# Residuals tab: t tests

## Why residuals?

Prism 8 introduced the ability to plot residual plots with t tests, provided that you entered raw data and not averaged data as mean, n and SD or SEM.

Many scientists thing of residual as values that are obtained with regression. But the t test is really regression in disguise. It fits a model. One of the assumptions of t tests  is that the residuals from that model are sampled from a Gaussian distribution. A residual plot helps you assess this assumption.

## Which graph to create?

Prism can make three kinds of residual plots. For t tests, since there are only two groups, the first two choices are not super useful, and the QQ plot is the most useful way to plot residuals.

Residual plot. The X axis is the actual value of the value (unpaired tests) or difference (paired test).  The Y axis is the residual. This lets you spot residuals that are much larger or smaller than the rest.

Homoscedasticity plot. The X axis is the actual value of the value (unpaired tests) or difference (paired test).  The Y axis is the absolute value of the residual.This lets you check whether larger values are associated with bigger residuals (larger absolute value).

QQ plot. The X axis is the actual residual. The Y axis is the predicted residual, computed from the percentile of the residual (among all residuals) and assuming sampling from a Gaussian distribution. ANOVA assumes a Gaussian distribution of residuals, and this graph lets you check that assumption.

## Diagnostics for residuals

Are the residuals Gaussian? Prism runs four normality tests on the residuals. The residuals from both groups are pooled and entered into one set of normality tests.

## How residuals are computed

Residuals with  t tests and related tests are simple to understand.

Unpaired t test. A residual is computed for each value. Each residual is the difference between the entered value and the mean of all values for that group. A residual is positive when the corresponding value is greater than the sample mean, and is negative when the value is less than the sample mean.

Mann-Whitney test. A residual is computed for each value. Each residual is the difference between an entered value and the median of all values for that group. A residual is positive when the corresponding value is greater than the sample median, and is negative when the value is less than the sample median.

Paired t test. A residual is calculated for each pair. First a difference is computed for each pair. The residual   equals the actual difference between the pairs minus the mean of all such difference in the data sets.

Ratio t test. A residual is calculated for each pair. A ratio is computed for each pair. The residual equals the logarithm of that ratio minus the mean of the logarithms of all the ratios.

Wilcoxon matched pairs test. A residual is calculated for each pair. First a difference is computed for each pair. The residual  equals the actual difference between the pairs minus the median of all such difference in the data sets.