Chapter 25 Examples of statistics reporting
In this section I give some examples of how one can describe methods and report results of statistical analyses. These are not “set in stone”. There are certainly other ways to write these up, but these examples will give you a starting point for your own reporting.
All of the outputs below are produced by real R code, so you can run it yourself and check that you get the same numbers.
25.1 General rules
Whatever the analysis, a good results sentence usually does the following:
- Gives the estimate first. Say what you found (a difference between means, a slope, an odds ratio) and how big it is, in the units of the data, with a measure of uncertainty (ideally a 95% confidence interval).
- Then gives the test. Put the test statistic, its degrees of freedom and the p-value in parentheses, e.g. (t = 2.31, d.f. = 18, p = 0.033).
- Rounds sensibly. Two or three significant figures are usually enough. Give p-values to two or three decimal places, and write very small ones as p < 0.001.
- Interprets carefully. A non-significant result means “no clear evidence of an effect”, not “no effect”. A significant result in an observational study shows an association, not necessarily causation.
- Mentions the checks. Say briefly that you checked the model assumptions (e.g. with diagnostic plots), and how, in the methods.
The methods should describe the analysis (what model, which variables, what checks), not the R functions you typed.
25.2 t-test
This example concerns a t-test where the mean heights of plants (in cm) after a set amount of growing time were compared across two groups (control and treatment).
control <- c(6.5, 7.0, 7.2, 7.6, 7.7)
treatment <- c(7.4, 7.9, 8.3, 8.6, 8.8)
results <- t.test(treatment, control, var.equal = TRUE)
results##
## Two Sample t-test
##
## data: treatment and control
## t = 3.0151, df = 8, p-value = 0.01668
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.235185 1.764815
## sample estimates:
## mean of x mean of y
## 8.2 7.2
The methods could be reported like this:
To compare the mean height of plants in the two groups I used a two-sample t-test, assuming equal variances. I checked the assumptions of normality and equal variance by inspecting the data and the residuals.
You might report the results as:
Plants in the treatment group were on average 1.0 cm taller than those in the control group (mean height 8.2 cm vs. 7.2 cm; 95% CI for the difference: 0.24 to 1.76 cm; t = 3.02, d.f. = 8, p = 0.017).
Notice the order: first the biology (how much taller, and how uncertain that estimate is), then the test details in parentheses. If the p-value had been, say, 0.14, you would write something like “there was no clear evidence of a difference in height between the groups (difference = …, 95% CI: …)”. The confidence interval then tells the reader how large a difference is still compatible with the data.
25.3 Simple linear regression model
In this example, the model focuses on the relationship between petal length and sepal length (both in cm) in the iris dataset, which is built into R.
## Analysis of Variance Table
##
## Response: Sepal.Length
## Df Sum Sq Mean Sq F value Pr(>F)
## Petal.Length 1 77.643 77.643 468.55 < 2.2e-16 ***
## Residuals 148 24.525 0.166
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Call:
## lm(formula = Sepal.Length ~ Petal.Length, data = iris)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.24675 -0.29657 -0.01515 0.27676 1.00269
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.30660 0.07839 54.94 <2e-16 ***
## Petal.Length 0.40892 0.01889 21.65 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.4071 on 148 degrees of freedom
## Multiple R-squared: 0.76, Adjusted R-squared: 0.7583
## F-statistic: 468.6 on 1 and 148 DF, p-value: < 2.2e-16
## 2.5 % 97.5 %
## (Intercept) 4.1516972 4.4615096
## Petal.Length 0.3715907 0.4462539
For the methods, I might write something like this:
To investigate the relationship between petal length and sepal length I fitted a linear regression with sepal length as the response variable and petal length as the explanatory variable. I checked the model assumptions using diagnostic plots of the residuals.
You might write the results up like this:
Sepal length increased with petal length: each 1 cm increase in petal length was associated with an increase in sepal length of 0.41 cm (95% CI: 0.37 to 0.45 cm; F = 468.6, d.f. = 1 and 148, p < 0.001). Petal length explained 76% of the variation in sepal length (R2 = 0.76). The fitted line was: sepal length = 4.31 + 0.41 \(\times\) petal length.
Note that the F-test from anova() and the t-test of the slope from summary() give the same p-value for a simple regression (F = t2), so you only need to report one of them.
25.4 A generalised linear model (GLM)
In this example we use the fox.csv data from the GLM chapter to look at the results of a Poisson GLM of the number of offspring produced by arctic foxes in relation to the mother’s weight (in kg). We use a Poisson GLM because these are count data (number of offspring).
fox <- read.csv("CourseData/fox.csv")
mod_fox <- glm(noffspring ~ weight, data = fox, family = poisson)
anova(mod_fox, test = "Chisq")## Analysis of Deviance Table
##
## Model: poisson, link: log
##
## Response: noffspring
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev Pr(>Chi)
## NULL 99 166.84
## weight 1 44.124 98 122.72 3.082e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Call:
## glm(formula = noffspring ~ weight, family = poisson, data = fox)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -0.74981 0.31107 -2.410 0.0159 *
## weight 0.63239 0.09502 6.655 2.83e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for poisson family taken to be 1)
##
## Null deviance: 166.85 on 99 degrees of freedom
## Residual deviance: 122.72 on 98 degrees of freedom
## AIC: 405.56
##
## Number of Fisher Scoring iterations: 5
For the methods, I might write something like this:
To investigate the relationship between maternal weight and the number of offspring, I fitted a generalised linear model (GLM) with Poisson errors and a log link, with maternal weight as the explanatory variable. I tested the effect of weight using a likelihood ratio test, and checked for overdispersion.
The anova() output gives the likelihood ratio test (the drop in deviance when weight is added to the model). The summary() output gives the coefficients, which are on the log scale. Because of the log link, exponentiating the slope gives a multiplicative effect: \(e^{0.63}\) = 1.88, so the expected number of offspring is multiplied by about 1.9 for each extra kg of maternal weight.
The deviances can also be used to calculate how much of the variation the model explains (a kind of pseudo-R2): weight reduces the deviance by 44.1 out of a null deviance of 166.8, which is 26.4%.
So, to put it together:
Heavier mothers produced more offspring (Poisson GLM, likelihood ratio test: \(\chi^2\) = 44.1, d.f. = 1, p < 0.001). The slope on the log scale was 0.63 (95% CI: 0.45 to 0.82), meaning that each additional kg of maternal weight multiplied the expected number of offspring by 1.88 (95% CI: 1.56 to 2.27). Weight explained 26% of the deviance in offspring number. There was no evidence of overdispersion (residual deviance / residual d.f. = 1.25).
A figure showing the data with the fitted line and its confidence band (on the scale of the data) is often the clearest way to present a GLM, and the text can then refer to it.
25.5 A model with two explanatory variables
Things get a little more complicated with more complicated models. With many terms, a table of results is often clearer than text. However, for a model with two terms, something like the following would work.
In this example we use the class data to ask whether height and hand width (both in cm) predict whether a student is male or female. Because the response is binary (male = 1, female = 0) we use a binomial GLM.
classData <- read.csv("CourseData/classData.csv")
classData <- subset(classData, Gender %in% c("Female", "Male"))
classData$Male <- as.numeric(classData$Gender == "Male")
mod_sex <- glm(Male ~ Height + HandWidth, data = classData, family = binomial)
anova(mod_sex, test = "Chisq")## Analysis of Deviance Table
##
## Model: binomial, link: logit
##
## Response: Male
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev Pr(>Chi)
## NULL 103 141.703
## Height 1 80.656 102 61.047 < 2e-16 ***
## HandWidth 1 6.593 101 54.454 0.01024 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Call:
## glm(formula = Male ~ Height + HandWidth, family = binomial, data = classData)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -66.58834 14.08276 -4.728 2.26e-06 ***
## Height 0.32624 0.07475 4.365 1.27e-05 ***
## HandWidth 1.02927 0.44648 2.305 0.0211 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 141.703 on 103 degrees of freedom
## Residual deviance: 54.454 on 101 degrees of freedom
## (2 observations deleted due to missingness)
## AIC: 60.454
##
## Number of Fisher Scoring iterations: 7
Remember that anova() tests the terms sequentially: first height on its own, and then whether hand width explains anything extra once height is already in the model. Because tall people also tend to have wide hands, the order matters, and it should be stated in the methods.
For the methods:
To test whether height and hand width predict sex, I fitted a binomial GLM (logit link) with sex (male or female) as the response, and height and hand width as explanatory variables. I tested the terms sequentially with likelihood ratio tests, adding height first and then hand width.
And the results:
In the 104 students with both measurements, taller students were more likely to be male (likelihood ratio test: \(\chi^2\) = 80.7, d.f. = 1, p < 0.001), and hand width explained additional variation once height had been accounted for (\(\chi^2\) = 6.6, d.f. = 1, p = 0.010). Holding hand width constant, the odds of being male increased by a factor of 1.39 for each extra cm of height (95% CI: 1.20 to 1.60). Holding height constant, they increased by a factor of 2.8 for each extra cm of hand width (95% CI: 1.2 to 6.7). Together, the two variables explained 61.6% of the deviance, most of it due to height.
Note that the odds ratio for hand width is larger than the one for height, but this does not mean hand width is the “more important” variable: a 1 cm difference in hand width is a much bigger difference than 1 cm of height. The deviances tell a clearer story about how much variation each term explains.