Choosing the right test EN - pdmoerland/wiki-biostatistiek-bilingual GitHub Wiki
Deze pagina lezen in het Nederlands.
This page was translated from the Dutch-language original using AI and has not been fully reviewed. Where the two differ, the Dutch version takes precedence.
- Overview: which test for which comparison
- Overview: which analysis for which association
- What type is my data?
- Do I have paired or unpaired data?
- How do I assess the normality of my data?
-
How can I transform my data in SPSS?
- I have a problem with log transformation because of zeros in the data
- What is better: a Mann-Whitney U test on non-normally distributed data, or an unpaired t-test on the log scale of this data, which is normally distributed?
- No normality after log transformation, what now?
- How do I create a rank order of my skewed data in SPSS?
- References
| type of comparison | |||||||
|---|---|---|---|---|---|---|---|
| 1 group | 2 groups | >2 groups | |||||
| vs. reference | paired | unpaired | paired | unpaired | |||
| type of data | numeric (continuous) | normally distributed | 1-sample t-test | paired t-test | unpaired t-test | linear mixed models | One-way ANOVA |
| not normally distributed | sign test | Wilcoxon signed-rank test | Mann-Whitney U test | Friedman test | Kruskal Wallis | ||
| categorical (discrete) | binary | test for a single proportion | McNemar's test | Chi-square test/ Fisher's exact test | Cochran's Q test | Chi-square test/Fisher-Freeman-Halton exact test | |
| nominal / ordinal | x | McNemar's test / Wilcoxon signed-rank test | Chi-square test (trend) | GLMM / GEE | Chi-square test (trend) | ||
| type of association | ||||||
|---|---|---|---|---|---|---|
| cross-sectional | longitudinal | |||||
| one independent variable | multiple independent variables | one independent variable | multiple independent variables | |||
| type of data | numeric (continuous) | normally distributed | Pearson's rho/simple linear regression | multiple linear regression | repeated measures | |
| not normally distributed | Spearman's rho | x | ||||
| censored numeric | | | Kaplan-Meier analysis | Cox regression | |||
| categorical (discrete) | binary | OR/ RR/ RRR / ARR / NNT | logistic regression | GLMM / GEE | ||
| nominal /ordinal | x | multinomial / ordinal logistic regression | ||||
The most important distinction in data type is that between continuous and discrete variables. A continuous variable can take any value within a given interval. Height, weight and temperature are continuous variables (for example 37.3 degrees Celsius).
For discrete variables, a distinction is made between qualitative and quantitative variables. The values that qualitative variables can take are not numbers but characteristics. These are also referred to as categorical variables. Qualitative variables are by definition discrete variables. An example of a qualitative variable is the determination of blood groups A, B, AB and O.
Quantitative discrete variables are whole numbers. A count of the number of outpatient visits made by a patient is, for example, a quantitative discrete variable. When quantitative discrete variables have many different possible values (for example the number of CD4+ T cells), they are often analyzed as continuous variables (this is sometimes referred to as semi-continuous data). If, on the other hand, there are only a limited number of outcome values, other analysis techniques are required.
For the statistical analysis of qualitative data and of quantitative discrete variables with a limited number of outcome values, a distinction is made between binary, nominal and ordinal discrete variables.
A binary (or dichotomous) outcome has only 2 possible outcomes or values. Examples are sex (male or female), survival (dead or alive) or recovery (yes or no).
Variables measured on a nominal level are qualitative variables whose categories cannot be placed in a fixed or meaningful order. Example: 'Blood group' with values A, B, AB and O, or 'Treated vessel' with values LAD, LM, RCA and RCx.
Variables measured on an ordinal level are qualitative variables whose categories can be placed in a fixed and meaningful order. For example, a statement in a questionnaire such as 'lately I have often had gloomy thoughts', with response categories: 'strongly agree', 'agree', 'no opinion', 'disagree' and 'strongly disagree'. (Discrete) numeric variables are by definition ordinal (because of their numeric nature there is an ordering in the numbers).
Data are paired if a measurement has been taken twice (or more) in the same individuals. If there are separate, independent groups, the data are unpaired.
-
Example 1 We induced a disease in pigs. We then performed an intervention EARLY in one group, and an intervention LATE in another group. Which statistical test should I use if I want to: 1. Test the difference between BEFORE and AFTER the intervention within a group? 2. Test the difference between the 2 groups (after the intervention)? -> In the first case a paired test should be used, in the second case an unpaired test.
-
Example 2 A new device has come onto the market that can measure blood pressure. We want to compare this device with the current gold standard for blood pressure measurement using a blood pressure cuff. We measured blood pressure in 30 patients, simultaneously with the new device and with the standard blood pressure cuff. I want to compare the means of these two measurements, from the same 30 patients, with each other. Can this be done with an unpaired test? Are these actually independent measurements? -> If the measurements from the device and the gold standard cuff relate to the same patients (and to the same moment), then they are not independent measurements. In that case you have paired measurements, and if you want to compare the difference in mean values you will need to use a paired test.
I am comparing the outcomes of quality indicators in two different data sources. My patients have a "partial overlap": some I could match in both data sources, and some appear in only one of the two sources. So they are neither "paired" nor "unpaired". How can I compare the quality indicators (binary variables) with each other?
The patients who appear in both sources can be compared using a paired McNemar's test. The patients who appear in only one of the two sources can be compared using an unpaired Chi-square test. There are also methods to compare both patient groups simultaneously. See the following references for this:
- Thomson PC. A hybrid paired and unpaired analysis for the comparison of proportions. Stat Med. 1995 Jul 15;14(13):1463-70
- Comparing proportions in overlapping samples. An unpublished paper by J Martin Bland and Barbara K Butland
You can assess whether the study sample could originate from a normally distributed population by looking at the histogram and the normality plot. A formal test can also be performed, for example the Kolmogorov-Smirnov test or the Shapiro-Wilk test (in SPSS 16: Analyze->Descriptive Statistics->Explore, under the "Plots" heading check 'Histogram' and 'Normality plots with tests', and if applicable specify the grouping variable under "Factor List"). Note, however, that with large sample sizes these tests can already flag a small (and for the intended analysis possibly irrelevant) deviation from normality as significant, while with small sample sizes gross deviations from normality may not turn out to be statistically significant. So never base your assessment on these tests alone; also make a graphical assessment and take the sample size into account.
For datasets with >25 observations, parametric tests such as the t-test can still be used even with a somewhat skewed distribution; see a clear explanation in this article [1].
I thought that a Shapiro-Wilk test with p<0.05 meant that the data are not normally distributed. Now I have looked at a colleague's syntax where a threshold of 0.9 is used. What is actually correct?
Formally, with a p<0.05 you must reject the null hypothesis. In your case, you would therefore have to conclude based on the p-value that the data are not normal. However, when you have enough data, you can find even an irrelevant but statistically significant deviation from the normal distribution. The test statistic W of the Shapiro-Wilk test ranges from 0 to 1, where 1 means that the data are perfectly normally distributed. This value is often looked at more than the p-value, using a lower bound of 0.90 for W. If the test statistic W is greater than 0.90, the data can be considered normally distributed. (There are many examples where W > 0.99 while p < 0.05.) It is therefore sometimes recommended to use the Kolmogorov-Smirnov test instead of the Shapiro-Wilk test for large samples.
The Kolmogorov-Smirnov test from the Explore function does not give the same answer as the one from the 'Nonparametric Tests' menu.
The Kolmogorov-Smirnov test appears to be available in two ways via SPSS, namely via Explore -> Normality plots with tests or via Nonparametric tests ->1 sample K-S. These two methods appear to give 'opposite' results for my data.
Well spotted that the two K-S tests do not lead to the same conclusion. I quote from the SPSS help accompanying the non-parametric command:
"The power of the test to detect departures from the hypothesized distribution may be seriously diminished. For testing against a normal distribution with estimated parameters, consider the adjusted K-S Lilliefors test (available in the Explore procedure)."
Apparently the 'regular' K-S test (under the non-parametric options) is not well able to detect a deviation from normality in small samples. There is a correction to the test that is implemented under the Explore function. (see e.g. http://en.wikipedia.org/wiki/Lilliefors_test for details).
So do not use the K-S test from the nonparametric tests options. Better still: for relatively small samples, use the Shapiro-Wilk test, as this will be the first to detect a deviation from normality.
For an article I am writing I need to perform several statistical analyses, and it is unclear to me how to assess whether the data to be used are normally distributed or not. It concerns small numbers of subjects (<10 patients with before and after measurements, given a rare condition). This involves general things such as body weight and cholesterol intake, as well as more specific things such as results of PET/CT and MRI scans. I think a plot or histogram doesn't tell you all that much here (it looks non-normal, but weight in the population, for example, actually is normally distributed). Can you tell me how I can assess with this kind of numbers whether something is normally distributed or not? Is there a rule of thumb for this with small numbers?
In general, when in doubt about whether a normal distribution may be assumed, knowledge about the distribution in the overall population can indeed be decisive. In the case of small numbers, however, a different problem arises. With small numbers, no reliable estimate can be made of the mean and the standard deviation. So even if there is an underlying normal distribution, the parameters of that distribution cannot be well estimated from the available data. For this reason, when in doubt about normality with (really) small numbers, it is advisable not to assume normality and to use non-parametric tests instead. By really small you can think of <25, see also this article [1].
I would like to transform my outcome measure to see whether it is then normally distributed. How do I do that in SPSS?
This can be done under Transform -> Compute Variable. Here you can create a new variable that is a transformation of an existing variable. Under 'Target Variable' you type the name of the new variable to be created, and under 'Numeric Expression' you type how the variable should be computed. For example Lg10(VAROUD), to take the base-10 log of the variable VAROUD.
There is something else I'm struggling with in the log transformations of my non-normally distributed continuous outcome measures (a number of scales for psychological complaints). When 'computing' the log variables, SPSS says something like: "The argument for the Logbase 10 function is less or equal to 10 on the indicate command. The result has been set to the system missing value." So I understand that all 0 values from the original variable cannot be transformed and therefore get no value in the transformed variable. Is there something that can be done about this?
The log of 0 is indeed impossible to compute (minus infinity). What is usually done is that, prior to the transformation, a fixed number is added to all values (including those that are not zero) - for example 1. This way you avoid the computational problems with log 0 while preserving the distances between the values. The transformation you then use is effectively log(x+1).
What is better: a Mann-Whitney U test on non-normally distributed data, or an unpaired t-test on the log scale of this data, which is normally distributed?
Or does it not matter which one you choose? The difference is small (4 decimal places), but the t-test comes out slightly more significant.
It is always nice when the analysis method does not influence the result, so that the same outcome is obtained either way. A difference in p-value at the 4th decimal place is completely irrelevant (paying attention to that feigns a precision that you generally do not have). The pros/cons in general are:
-Mann-Whitney U test: result not dependent on assumptions; non-parametric tests are generally regarded as very objective/reliable
-t-test: with normally distributed data (or data that is normally distributed after transformation) there is in theory more power to detect something as significant
Furthermore, I would pay attention to consistency within the manuscript. If in other analyses you do rely on the normality of the log-transformed data (for example because you are also performing multivariable analyses), it is advisable to maintain that same approach.
My data are not normally distributed. After a logarithmic transformation, it turns out that the data are still not normally distributed. Is it the case that one performs a logarithmic transformation in order to be able to run tests for normally distributed data? If so, does it still make sense in my case to perform a logarithmic transformation and work with those numbers, while I still have to use tests for non-normally distributed data?
Indeed, the transformation is generally applied in order to be able to use tests/analyses that require normally distributed data. If the logarithmic transformation does not produce an improvement in the distribution, then there is no point in using it. If you end up planning to use non-parametric variants (which do not require a normal distribution), then I would simply use the untransformed data. If normality is required for your purposes (for example multivariable analysis) then you could use a transformation other than the log transformation.
To create a new variable that contains the rank numbers of the values of a skewed variable, you can use the 'Rank Cases' procedure in the 'Transform' menu.
- le Cessie S, Goeman JJ, Dekkers OM. Who is afraid of non-normal data? Choosing between parametric and non-parametric tests. European Journal of Endocrinology (2020) 182, E1–E3. https://doi.org/10.1530/EJE-19-0922
- Statistics Notes: The use of transformation when comparing two means. MJ Bland, DG Altman. BMJ 1996;312:1153. http://www.bmj.com/content/312/7039/1153
Done reading? You can go to the OVERVIEW of all statistical topics on this wiki. Or go back to the homepage. Want to learn more about biostatistics? Then take the AMC e-learning Practical Biostatistics. Do you find something on these pages that isn't right, a link that doesn't work, or would you like to contribute to the wiki? Then get in touch with us.
The biostatistics wiki is an initiative of the former statistics helpdesk of Amsterdam UMC, location AMC. Staff of Amsterdam UMC can request statistical support via the intranet.