A marine ecologist was interested in examining the effects of wave exposure on the abundance of the striped limpet
Siphonaria diemenensis on rocky intertidal shores. To do so, a single quadrat was placed on 10 exposed (to large waves) shores
and 10 sheltered shores. From each quadrat, the number of Siphonaria diemenensis were counted.
The design is clearly a t-test as we are interested in comparing two population means (mean number of striped limpets on exposed and sheltered shores).
Recall that a parametric t-test assumes that the residuals (and populations from which the samples are drawn) are normally distributed and equally varied.
Is there any evidence that these assumptions have been violated?
Show code
> boxplot(Count~Shore,data=limpets)
The assumption of normality has been violated?
The assumption of homogeneity of variance has been violated?
At this point we could transform the data in an attempt to satisfy normality and homogeneity of variance.
However, the analyses are then not on the scale of the data and thus the conclusions also pertain to a different scale. Furthermore,
linear modelling on
transformed count data is generally not as effective as modelling count data with a Poisson distribution.
Lets instead we fit the same model with a Poisson distribution.
$$log(\mu) = \beta_0+\beta1Shore_i+\epsilon_i, \hspace{1cm} \epsilon \sim Poisson(\lambda)$$
And for those who do not suffer a p-value affliction, we can alternatively (or in addition) calculate the confidence intervals for the estimated parameters.
Show code
> library(gmodels)> ci(limpets.glm)
Estimate CI lower CI upper Std. Error p-value
(Intercept) 1.5686 1.265 1.8719 0.1443 1.643e-27
Shoresheltered -0.9268 -1.496 -0.3573 0.2710 6.280e-04
Had we have been concerned about overdispersion, we could have alternatively fit a model against either a quasipoisson or negative binomial distribution.
Call:
glm(formula = Count ~ Shore, family = quasipoisson, data = limpets)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.9494 -0.8832 0.0719 0.5791 2.3662
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.569 0.177 8.87 5.5e-08 ***
Shoresheltered -0.927 0.332 -2.79 0.012 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for quasipoisson family taken to be 1.501)
Null deviance: 41.624 on 19 degrees of freedom
Residual deviance: 28.647 on 18 degrees of freedom
AIC: NA
Number of Fisher Scoring iterations: 5
We once again return to a modified example from Quinn and Keough (2002).
In Exercise 1 of Workshop 9.4a, we introduced an experiment by Day and Quinn (1989) that examined how rock surface type affected the recruitment of barnacles to a rocky shore. The experiment had a single factor, surface type, with 4 treatments or levels: algal species 1 (ALG1), algal species 2 (ALG2), naturally bare surfaces (NB) and artificially scraped bare surfaces (S). There were 5 replicate plots for each surface type and the response (dependent) variable was the number of newly recruited barnacles on each plot after 4 weeks.
We previously analysed these data with via a classic linear model (ANOVA) as the data appeared to conform to the linear model assumptions.
Alternatively, we could analyse these data with a generalized linear model (Poisson error distribution).
Note that as the boxplots were all fairly symmetrical and equally varied, and the sample means are well away from zero (in fact there are no zero's in the data)
we might suspect that whether we fit the model as a linear or generalized linear model is probably not going to be of great consequence.
Nevertheless, it does then provide a good comparison between the two frameworks.
Using boxplots re-examine the assumptions of normality and homogeneity of variance.
Note that when sample sizes are small (as is the case with this data set), these ANOVA assumptions cannot reliably be checked using boxplots since boxplots require at least 5 replicates (and preferably more), from which to calculate the median and quartiles.
As with regression analysis, it is the assumption of homogeneity of variances (and in particular, whether there is a relationship between the mean and variance) that is of most concern for ANOVA.
Show code
> boxplot(BARNACLE~TREAT,data=day)
Fit the generalized linear model (GLM) relating the number of newly recruited barnacles to substrate type.
$$log(\mu) = \beta_0+\beta1Treat_i+\epsilon_i, \hspace{1cm} \epsilon \sim Poisson(\lambda)$$
Although we have now established that there is a statistical difference between the group means,
we do not yet know which group(s) are different from which other(s).
For this data a Tukey's multiple comparison test (to determine which surface
type groups are different from each other, in terms of number of barnacles)
could be appropriate.
To investigate habitat differences in moth abundances, researchers from the Australian National University (ANU) in Canberra
counted the number of individuals of two species of moth (recorded as A and P) along transects throughout a landscape comprising
eight different habitat types ('Bank', 'Disturbed', 'Lowerside', 'NEsoak', 'NWsoak', 'SEsoak', 'SWsoak', 'Upperside').
For the data presented here, one of the habitat types ('Bank') has been ommitted as no moths were encounted in that habitat.
Although each transect was approximately the same length, each transect passed through multiple habitat types. Consequently, each transect was
divided into sections according to habitat and the number of moths observed in each section recorded.
Clearly, the number of observed moths in a section would be related to the length of the transect in that section. Therefore, the
researchers also recorded the length of each habitat section.
The primary focus of this question will be to investigate the effect of habitat on the abundance of moth species A.
To standardize the moth counts for transect section length, we could convert the counts into densities (by dividing the A by METERS.
Create such as variable (DENSITY and explore the usual ANOVA assumptions.
Clearly, the there is an issue with normality and homogeneity of variance. Perhaps it would be worth transforming
density in an attempt to normalize these data. Given that there are densities of zero, a straight logarithmic transformation would not be appropriate.
Alternatives could inlude a square-root transform, a forth-root transform and a log plus 1 transform.
Arguably, non of the above transformations have improved the data's adherence to the linear modelling assumptions.
Count data (such as the abundance of moth species A) is unlikely to follow a normal or even log-normal distribution. Count data
are usually more appropriately modelled via a Poisson distribution. Note, dividing by transect length is unlikely to alter
the underlying nature of the data distribution as it still based on counts.
Fit the generalized linear model (GLM) relating the number of newly recruited barnacles to substrate type.
$$log(\mu) = \beta_0+\beta_1 Habitat_i+\epsilon_i, \hspace{1cm} \epsilon \sim Poisson(\lambda)$$
Actually, the above model fails to account for the length of the section of transect.
We could do this a couple of ways:
Add METERS as a covariate. Note, since we are modelling against a Poission distribution with a log link function,
we should also log the covariate - in order to maintain linearity between the expected value of species A abundance and transect length.
$$log(\mu) = \beta_0+\beta_1 Habitat_i + \beta_2 log(meters) +\epsilon_i, \hspace{1cm} \epsilon \sim Poisson(\lambda)$$
Add METERS as an offset in which case $\beta_2$ is assumed to be 1 (a reasonable assumption in this case).
The advantage is that it does not sacrifice any residual degrees of freedom. Again to maintain linearity, the offset should include
the log of transect length.
$$log(\mu) = \beta_0+\beta_1 Habitat_i + log(meters) +\epsilon_i, \hspace{1cm} \epsilon \sim Poisson(\lambda)$$
The same marine ecologist that featured earlier was also interested in examining the effects of wave exposure on the abundance of another intertidal marine limpet
Cellana tramoserica on rocky intertidal shores. Again, a single quadrat was placed on 10 exposed (to large waves) shores
and 10 sheltered shores. From each quadrat, the number of smooth limpets (Cellana tramoserica) were counted.
We might have initially have been tempted to perform a simple t-test on these data.
However, as the response are counts (and close to zero), lets instead fit the same model with a Poisson distribution.
$$log(\mu) = \beta_0+\beta1Shore_i+\epsilon_i, \hspace{1cm} \epsilon \sim Poisson(\lambda)$$
There is a suggestion that there are more zeros than we should expect given the means of each population.
It may be that these data are zero inflated, however, given that our other diagnostics have suggested that the model itself might be inappropriate, zero inflation is not the primary concern.
Clearly there is an issue of with overdispersion. There are multiple potential reasons for this.
It could be that there are major sources of variability that are not captured within the sampling design.
Alternatively it could be that the data are very clumped.
For example, often species abundances are clumped - individuals are either not present,
or else when they are present they occur in groups.
As part of the routine exploratory data analysis:
Explore the distribution of counts from each population
There does appear to be some clumping which might suggest that there are other unmeasured influences.
There are generally two ways of handling this form of overdispersion.
Fit the model with a quasipoisson distribution in which the dispersion factor (lambda) is not assumed to be 1.
The degree of variability (and how this differs from the mean) is estimated and the dispersion factor is incorporated.
Call:
glm(formula = Count ~ Shore, family = quasipoisson, data = limpets)
Deviance Residuals:
Min 1Q Median 3Q Max
-3.635 -2.630 -0.475 1.045 5.345
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.293 0.253 9.05 4.1e-08 ***
Shoresheltered -0.932 0.477 -1.95 0.066 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for quasipoisson family taken to be 6.358)
Null deviance: 138.18 on 19 degrees of freedom
Residual deviance: 111.20 on 18 degrees of freedom
AIC: NA
Number of Fisher Scoring iterations: 5
Yet again our rather fixated marine ecologist has returned to the rocky shore with an interest in examining the effects of wave exposure on the abundance of yet another intertidal marine limpet
Patelloida latistrigata on rocky intertidal shores.
It would appear that either this ecologist is lazy, is satisfied with the methodology or else suffers from some superstition disorder (that prevents them from deviating too far from a series of tasks), and thus, yet again, a single quadrat was placed on 10 exposed (to large waves) shores
and 10 sheltered shores. From each quadrat, the number of scaley limpets (Patelloida latistrigata) were counted.
Initially, faculty were mildly interested in the research of this ecologist (although lets be honest, most academics usually only display interest in the work of the other members of their school out of politeness - Oh I did not say that did I?).
Nevertheless, after years of attending seminars by this ecologist in which the only difference is the target species, faculty have started to display more disturbing levels of animosity towards our ecologist.
In fact, only last week, the members of the school's internal ARC review panel (when presented with yet another wave exposure proposal)
were rumored to take great pleasure in concocting up numerous bogus applications involving hedgehogs and balloons just so they could rank our ecologist proposal outside of the top 50 prospects and ... Actually, I may just have digressed!
Interestingly, did you notice that whilst this particular marine ecologists' imagination for design seems somewhat limited, they clearly have a reasonably large statistical tool bag.
Log-linear modelling
Roberts (1993) was intested in examining the interaction between the presence of dead coolibah trees and the position of quadrats along a transect.
COOLIBAH POSITION COUNT
1 WITH BOTTOM 15
2 WITH MIDDLE 4
3 WITH TOP 0
4 WITHOUT BOTTOM 13
5 WITHOUT MIDDLE 8
6 WITHOUT TOP 17
Fit a log-linear model to examine the interaction between presence of dead coolibah trees and position along
transect HINT) by first fitting a reduced model (one without the interaction,
HINT),
then fitting the full model (one with the interaction,
HINT)
and finally comparing the reduced model to the full model via analysis of deviance (HINT).
Show code
> #Reduced model> roberts.glmR<-glm(COUNT~POSITION+COOLIBAH,family=poisson,data=roberts)> #Full model> roberts.glmF<-glm(COUNT~POSITION*COOLIBAH,family=poisson,data=roberts)> #Compare the two models> anova(roberts.glmR,roberts.glmF,test='Chisq')
Analysis of Deviance Table
Model 1: COUNT ~ POSITION + COOLIBAH
Model 2: COUNT ~ POSITION * COOLIBAH
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 2 18.6
2 0 0.0 2 18.6 9.1e-05 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Alternatively, we can just generate an ANOVA (deviance) table from the full model and ignore the non-interaction terms
(HINT).
Perhaps to help provide more insights into the drivers of the significant association between the coolibah mortality and position along the transect,
we could explore the odds ratios. Recall that for logit models, the slope terms are expressed on the log odds-ratio scale and thus
can be simply translated into odds-ratios. That said, again it is only the interaction terms that are of interest.
Nevertheless, as one of the observed counts is 0, the slope terms for any interactions involving this cell will be very large (and the exponent likely to be infinite).
One possible remedy is to refit the model after adding a small constant (such as 0.5) to all the observed counts and then calculate the odds ratios.
An additional issue that no doubt you noticed is that as the model is fitted as an 'effects' parameterization, not all pairwise calculations
are defined. For example, the interaction terms define the (log) odds ratios for with and without coolibah trees in the bottom of the transect versus
the middle and versus the top. Hence we only have odds ratios for two of the three comparisons (we don't have middle vs top)
We could derive this other odds ratio by either redefining the model contrasts. Alternatively, we could just calculate the pairwise
odds ratios from a cross table representation of the frequency data (again adding a constant of 0.5).
Sinclair investigated the association between sex, health and cause of death in wildebeest.
To do so, they recorded the sex and cause of death (predator or not) of wildebeest carcasses along with a classification of a bone marrow sample.
The color and consistency of bone marrow is apparently a reasonably good indication of the health status of an animal (even after death).
SEX MARROW DEATH COUNT
1 FEMALE SWF PRED 26
2 MALE SWF PRED 14
3 FEMALE OG PRED 32
4 MALE OG PRED 43
5 FEMALE TG PRED 8
6 MALE TG PRED 10
What is the null hypothesis of interest?
Log-linear models for three way tables have a greater number of interactions and therefore a greater number of combinations of terms that should be tested. As with ANOVA, it is the higher level interactions (three way) interaction that is of initial interest, followed by the various two way interactions.
Test the null hypothesis that there is no three way interaction (the cause of death is independent of sex and bone marrow type).
First fit a reduced model (one that contains all two way interactions as well as individual effects but without the three way interaction,
HINT),
then fitting the full model (one with the interaction and all other terms,
HINT)
and finally comparing the reduced model to the full model (HINT).
We would clearly reject the null hypothesis of no three way interaction.
As with ANOVA, following a significant interaction it is necessary to slip the data up according to the levels of one of the factors and explore the
patterns further within the multiple subsets.
Sinclair and Arcese (1995) might have been interesting in investigating the associations between cause of death and marrow type separately for each sex.
Split the sinclair data set up by sex. (HINT)
$FEMALE
SEX MARROW DEATH COUNT
1 FEMALE SWF PRED 26
3 FEMALE OG PRED 32
5 FEMALE TG PRED 8
7 FEMALE SWF NPRED 6
9 FEMALE OG NPRED 26
11 FEMALE TG NPRED 16
$MALE
SEX MARROW DEATH COUNT
2 MALE SWF PRED 14
4 MALE OG PRED 43
6 MALE TG PRED 10
8 MALE SWF NPRED 7
10 MALE OG NPRED 12
12 MALE TG NPRED 26
Perform the log-linear modelling for the associations between cause of death and marrow type separately for each sex.
Analysis of Deviance Table
Model 1: COUNT ~ DEATH + MARROW
Model 2: COUNT ~ DEATH * MARROW
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 2 14
2 0 0 2 14 0.00093 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
> #Alternatively, the splitting and subsetting can be performed inline> #I shall illustrate this with the MALE data> sinclair.glmR<-glm(COUNT~DEATH+MARROW,family=poisson,data=sinclair,subset=sinclair$SEX=="MALE")> sinclair.glmF<-glm(COUNT~DEATH*MARROW,family=poisson,data=sinclair,subset=sinclair$SEX=="MALE")> anova(sinclair.glmR, sinclair.glmF,test="Chisq")
Analysis of Deviance Table
Model 1: COUNT ~ DEATH + MARROW
Model 2: COUNT ~ DEATH * MARROW
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 2 23.9
2 0 0.0 2 23.9 6.3e-06 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
 
G2
df
P
Females - MARROW:DEATH
Males - MARROW:DEATH
It appears that there are significant interactions between cause of death and bone marrow type for both females and males.
Given that there was a significant interaction between cause of death and sex and bone marrow type, it is likely that the nature of the two way interactions in females is different to the two way interactions in males.
To explore this further, we will examine the odds ratios for each pairwise comparison of bone marrow type with respect to predation level (for each sex)!. Calculate the odds ratios for wildebeest killed by predation for each pair of marrow types separately for males and females
.