You are on page 1of 43

Community Ecology

Analytical Methods Using


R and Excel

Mark Gardener
DATA IN THE WILD SERIES
IeIagic IubIishing + vvv.eIagicubIishing.com
IubIished by IeIagic IubIishing
vvv.eIagicubIishing.com
IO ox 725, Ixeler, IX1 9QU
Communily IcoIogy
AnaIylicaI Melhods Using R and IxceI
ISN 9781907807619 (Ibk)
ISN 9781907807626 (Hbk)
ISN 9781907807633 (eIub)
ISN 9781907807657 (IDI)
ISN 9781907807640 (Mobi)
Coyrighl 2014 Mark Gardener
AII righls reserved. No arl of lhis documenl may be roduced, slored in a relrievaI
syslem, or lransmiued in any form or by any means, eIeclronic, mechanicaI,
holocoying, recording or olhervise vilhoul rior ermission from lhe ubIisher.
WhiIe every eorl has been made in lhe rearalion of lhis book lo ensure lhe accuracy
of lhe informalion resenled, lhe informalion conlained in lhis book is soId vilhoul
varranly, eilher exress or imIied. Neilher lhe aulhor, nor IeIagic IubIishing, ils agenls
and dislribulors viII be heId IiabIe for any damage or Ioss caused or aIIeged lo be caused
direclIy or indireclIy by lhis book.
Windovs, IxceI and Word and are lrademarks of lhe Microsofl Cororalion. Ior more
informalion visil vvv. microsofl.com. OenOce.org is a lrademark of OracIe. Ior
more informalion visil vvv.oenoce.org. LibreOce is a lrademark of The Documenl
Ioundalion. Ior more informalion visil vvv.Iibreoce.org. AIe Macinlosh is a
lrademark of AIe Inc. Ior more informalion visil vvv.aIe.com.
!"#$#%& (#)"*"+ ,*$*-./0#1/ #1 20)-#3*$#.1 4*$*
A calaIogue record for lhis book is avaiIabIe from lhe rilish Library.
Cover image: Over under valer iclure, shoving Iairy assIels (!"#$%&'()*&" ($,&)
amongsl Cabbage CoraI (-$./*'&.*& .#'*01.2*") and lroicaI isIand in lhe background.
Indo Iacihc. David IIeelham/OceanvideImages.com
About the author
Mark Gardener (vvv.gardenersovn.co.uk) is an ecoIogisl, Ieclurer and vriler vorking in
lhe UK. His rimary area of research vas in oIIinalion ecoIogy and he has vorked in lhe
UK and around lhe vorId (rinciaIIy AuslraIia and lhe Uniled Slales). Since his doclor-
ale he has vorked in many areas of ecoIogy, oflen as a leacher and suervisor. He beIieves
lhal ecoIogicaI dala, eseciaIIy communily dala, are lhe mosl comIicaled and iII-behaved
and are consequenlIy lhe mosl fun lo vork vilh. He vas inlroduced lo R by a Iike-minded
edanl vhiIsl vorking in AuslraIia during his doclorale. Learning R vas nol onIy fun bul
oened u a nev avenue, making lhe sludy of communily ecoIogy a vhoIe Iol easier. He
is currenlIy seIf-emIoyed and runs courses in ecoIogy, dala anaIysis and R for a variely of
organisalions. Mark Iives in ruraI Devon vilh his vife Chrisline, a biochemisl vho conse-
quenlIy has IillIe need of slalislics.
Acknowledgements
There are so many eoIe lo lhank lhal il is hard lo knov vhere lo begin. I am sure lhal
I viII Ieave some eoIe oul, so I aoIogise in advance. Thanks lo Richard Rove (}ames
Cook Universily) for insiring me lo use R. Dala vere conlribuled from various sources,
eseciaIIy from MSc sludenls doing ioIogicaI Recording, lhanks eseciaIIy lo Robin Cure,
}essie MacKay, Mark Lalham, }ohn HandIey and Hing Kin Lee for your hard-von dala.
The MSc rogramme heIed me lo see lhe olenliaI of 'roer' bioIogicaI records and
I lhank Sarah WhiId for giving me lhe oorlunily lo underlake some leaching on lhe
course. Thanks aIso lo lhe IieId Sludies CounciI in generaI: many dala examIes have
arisen from fieId courses I've been invoIved vilh.
Software used
SeveraI versions of Microsofl's IxceI

sreadsheel vere used in lhe rearalion of lhis


book. Mosl of lhe examIes resenled shov version 2007 for Microsofl Windovs

aIlhough
olher versions may aIso be iIIuslraled.
The main version of lhe R rogram used vas 2.12.1 for Macinlosh: The R Ioundalion
for SlalislicaI Comuling, Vienna, Auslria, ISN 3-900051-07-0, hll://vvv.R-ro|ecl.org/.
Olher versions vere used in lesling code.
Support material
Iree suorl maleriaI is avaiIabIe on lhe Communily IcoIogy comanion vebsile, vhich
can be accessed via lhe book's resources age: hll://vvv.eIagicubIishing.com/com-
munily-ecoIogy-resources.hlmI
Reader feedback
We veIcome feedback from readers Iease emaiI us al info+eIagicubIishing.com and
leII us vhal you lhoughl aboul lhis book. IIease incIude lhe book lilIe in lhe sub|ecl Iine
of your emaiI.
Publish with Pelagic Publishing
We ubIish scienlific books lo lhe highesl ediloriaI slandards in aII Iife science disciIines,
vilh a arlicuIar focus on ecoIogy, conservalion and environmenl. IeIagic IubIishing ro-
duces books lhal sel nev benchmarks, share advances in research melhods and encourage
and inform viIdIife invesligalion for aII.
If you are inleresled in ubIishing vilh IeIagic Iease conlacl edilor+eIagicubIish-
ing.com vilh a synosis of your book, a brief hislory of your revious vrillen vork and a
slalemenl describing lhe imacl you vouId Iike your book lo have on readers.
Contents
Introduction viii
1. Starting to look at communities 1
1.1 A scienlific aroach 1
1.2 The loics of communily ecoIogy 2
1.3 Gelling dala using a sreadsheel 4
1.4 Aims and hyolheses 5
1.5 Summary 5
1.6 Ixercises 7
2. Software tools for community ecology 8
2.1 IxceI 8
2.2 Olher sreadsheels 9
2.3 The R rogram 10
2.4 Summary 15
2.5 Ixercises 15
3. Recording your data 16
3.1 ioIogicaI dala 16
3.2 Arranging your dala 18
3.3 Summary 19
3.4 Ixercises 19
4. Beginning data exploration: using software tools 20
4.1 eginning lo use R 20
4.2 ManiuIaling dala in a sreadsheel 28
4.3 Gelling dala from IxceI inlo R 60
4.4 Summary 62
4.5 Ixercises 63
5. Exploring data: choosing your analytical method 64
5.1 Calegories of sludy 64
5.2 Hov 'cIassic' hyolhesis lesling can be used in communily sludies 66
vi
|
Contents
5.3 AnaIylicaI melhods for communily sludies 70
5.4 Summary 73
5.5 Ixercises 74
6. Exploring data: getting insights 75
6.1 Irror checking 75
6.2 Adding exlra informalion 78
6.3 Gelling an overviev of your dala 80
6.4 Summary 104
6.5 Ixercises 105
7. Diversity: species richness 106
7.1 Comaring secies richness 108
7.2 CorreIaling secies richness over lime or againsl an
environmenlaI variabIe 119
7.3 Secies richness and samIing efforl 123
7.4 Summary 148
7.5 Ixercises 149
8. Diversity: indices 151
8.1 Simson's index 151
8.2 Shannon index 160
8.3 Olher diversily indices 168
8.4 Summary 194
8.5 Ixercises 195
9. Diversity: comparing 196
9.1 GrahicaI comarison of diversily rofiIes 197
9.2 A lesl for differences in diversily based on lhe !-lesl 199
9.3 GrahicaI summary of lhe !-lesl for Shannon and Simson indices 212
9.4 oolslra comarisons for unreIicaled samIes 227
9.5 Comarisons using reIicaled samIes 252
9.6 Summary 269
9.7 Ixercises 270
10. Diversity: sampling scale 272
10.1 CaIcuIaling "#!$ diversily 272
10.2 Addilive diversily arlilioning 299
10.3 HierarchicaI arlilioning 303
10.4 Grou disersion 306
10.5 Iermulalion melhods 309
10.6 OverIa and simiIarily 315
10.7 &#!$ diversily using aIlernalive dissimiIarily measures 325
10.8 &#!$ diversily comared lo olher variabIes 327
10.9 Summary 331
10.10 Ixercises 333
Contents
|
vii
11. Rank abundance or dominance models 334
11.1 Dominance modeIs 334
11.2 Iisher's Iog-series 358
11.3 Ireslon's IognormaI modeI 360
11.4 Summary 363
11.5 Ixercises 365
12. Similarity and cluster analysis 366
12.1 SimiIarily and dissimiIarily 366
12.2 CIusler anaIysis 382
12.3 Summary 416
12.4 Ixercises 418
13. Association analysis: identifying communities 419
13.1 Area aroach lo idenlifying communilies 420
13.2 Transecl aroach lo idenlifying communilies 428
13.3 Using aIlernalive dissimiIarily measures for idenlifying communilies 431
13.4 Indicalor secies 436
13.5 Summary 444
13.6 Ixercises 445
14. Ordination 446
14.1 Melhods of ordinalion 447
14.2 Indirecl gradienl anaIysis 449
14.3 Direcl gradienl anaIysis 490
14.4 Using ordinalion resuIls 505
14.5 Summary 520
14.6 Ixercises 522
'((#)*+,#- 524
&+".+/01$(23 542
4)*#5 547
Introduction
Inleraclions belveen secies are of fundamenlaI imorlance lo aII Iiving syslems and lhe
framevork ve have for sludying lhese inleraclions is communily ecoIogy. This is imor-
lanl lo our underslanding of lhe Ianel's bioIogicaI diversily and hov secies inleraclions
reIale lo lhe funclioning of ecosyslems al aII scaIes. Secies do nol Iive in isoIalion and lhe
sludy of communily ecoIogy is of raclicaI aIicalion in a vide range of conservalion
issues.
The sludy of ecoIogicaI communily dala invoIves many melhods of anaIysis. In lhis
book you viII Iearn many of lhe mainslays of communily anaIysis incIuding: diversily,
simiIarily and cIusler anaIysis, ordinalion and muIlivariale anaIyses. This book is for
undergraduale and oslgraduale sludenls and researchers seeking a sle-by-sle melh-
odoIogy for anaIysing Ianl and animaI communilies using R and IxceI.
Microsofl's IxceI sreadsheel is virluaIIy ubiquilous and famiIiar lo mosl comuler
users. Il is a robusl rogram lhal makes an exceIIenl slorage and maniuIalion syslem for
many kinds of dala, incIuding communily dala. The R rogram is a overfuI and fIex-
ibIe anaIylicaI syslem abIe lo conducl a huge variely of anaIylicaI melhods, vhich means
lhal lhe user onIy has lo Iearn one rogram lo address many research queslions. Ils olher
advanlage is lhal il is oen source and lherefore free. NoveI anaIylicaI melhods are being
added conslanlIy lo lhe aIready comrehensive suile of looIs avaiIabIe in R.
What you will learn in this book
This book is inlended lo give you some insighls inlo some of lhe anaIylicaI melhods
emIoyed by ecoIogisls in lhe sludy of communilies. The book is nol inlended lo be a malh-
emalicaI or lheorelicaI lrealise bul inevilabIy lhere is some malhs! I've lried lo kee lhis
in lhe background and lo focus on hov lo underlake lhe aroriale anaIysis al lhe righl
lime. There are many ubIished vorks concerning ecoIogicaI lheory, lhis book is inlended
lo suorl lhem by roviding a framevork for Iearning hov lo anaIyse your dala.
The book does nol cover every asecl of communily ecoIogy. There are a fev minor
omissions I hoe lo cover some of lhese in Ialer vorks.
How this book is arranged
There are four main slrands lo scienlific sludy: Ianning, recording, anaIysis and reorl-
ing. The firsl fev chalers deaI vilh lhe Ianning and recording asecls of sludy. You
viII see hov lo use lhe main soflvare looIs, IxceI and R, lo heI you arrange and begin
lo make sense of your dala. Laler chalers deaI more exIicilIy vilh lhe grand lhemes of
communily ecoIogy, vhich are:

6+7#1-+!3 lhe sludy of diversily is sIil inlo severaI chalers covering secies
richness, diversily indices, "#!$ diversily and dominancediversily modeIs.

8+9+.$1+!3 $)* ,.:-!#1+)0 lhis is conlained in one chaler covering simiIarily, hier-
archicaI cIuslering and cIuslering by arlilioning.

'--/,+$!+/) $)$.3-+- lhis shovs hov you can idenlify vhich secies beIong lo
vhich communily by sludying lhe associalions belveen secies. The sludy of
associalions Ieads inlo lhe idenlificalion of indicalor secies.

;1*+)$!+/) lhere is a vide range of melhods of ordinalion and lhey aII have simiIar
aims, lo reresenl comIicaled secies communily dala in a more simIified form.
The reorling eIemenl is nol covered exIicilIy, hovever lhe resenlalion of resuIls is
shovn lhroughoul lhe book. A more dedicaled coverage of slalislicaI and scienlific reorl-
ing can be found in my revious vork, 8!$!+-!+,- </1 =,/./0+-!- >-+)0 ? $)* =5,#..
Throughoul lhe book you viII see examIe exercises lhal are inlended for you lo lry
oul. In facl lhey are exressIy aimed al heIing you on a raclicaI IeveI reading hov lo
do somelhing is fine bul you need lo do il for yourseIf lo Iearn il roerIy. The @$7# $ A/
exercises are hard lo miss.
Have a Go: Learn something by doing it
The Have a Go exercises are inlended lo give you raclicaI exerience al various
anaIylicaI melhods. Many viII refer lo suIemenlary dala, vhich you can gel from
lhe comanion vebsile. Some dala are inlended lo be used in IxceI and olhers are for
using vilh R.
Mosl of lhe @$7# $ A/ exercises uliIise dala lhal is avaiIabIe on lhe comanion vebsile. The
maleriaI on lhe vebsile incIudes various sreadsheels, some conlaining dala and some
aIIoving anaIylicaI rocesses. The B=?=C?6$!$ fiIe is lhe mosl heIfuI lhis is an R fiIe,
vhich conlains dala and cuslom R commands. You can use lhe dala for lhe exercises (and
for raclice) and lhe cuslom commands lo heI you carry oul a variely of anaIylicaI roc-
esses. The cuslom commands are menlioned lhroughoul lhe book and lhe vebsile con-
lains a comIele direclory.
You viII aIso see lis and noles, vhich viII sland oul from lhe main lexl. These are 'use-
fuI' ilems of delaiI erlaining lo lhe lexl bul vhich I feIl vere imorlanl lo highIighl.
Tips and Notes: Useful additional information
The comanion vebsile conlains suIemenlary dala, vhich you can use for lhe
exercises. There are aIso sreadsheels and usefuI cuslom R commands lhal you can
use for your ovn anaIyses.
Al lhe end of each chaler lhere is a summary labIe lo heI give you an overviev of lhe
maleriaI in lhal chaler. There are aIso some seIf-assessmenl exercises for you lo lry oul.
The ansvers are in Aendix 1.
Introduction
|
ix
Support files
The comanion vebsile (see resources age: hll://vvv.eIagicubIishing.com/commu-
nily-ecoIogy-resources.hlmI) conlains suorl maleriaI lhal incIudes sreadsheel caIcuIa-
lions and dala in IxceI and CSV (comma searaled vaIues) formal. There is aIso an R dala
fiIe, vhich conlains cuslom R commands and dalasels. Inslruclions on hov lo Ioad lhe R
dala inlo your coy of R are on lhe vebsile. In brief you need lo use lhe load() command,
for Windovs or Mac you can lye lhe foIIoving:
load(file.choose())
This viII oen a brovser vindov and you can seIecl lhe B=?=C?6$!$ fiIe. On Linux
machines you'II need lo reIace lhe file.choose() arl vilh lhe exacl fiIename in quoles,
see lhe vebsile for more delaiIs.
I hoe lhal you viII find lhis book heIfuI, usefuI and inleresling. Above aII, I hoe lhal
il heIs you lo discover lhal anaIysis of communily ecoIogy is nol lhe 'boring malhs' al lhe
end of your fieIdvork bul an en|oyabIe and enIighlening exerience.
Mark Gardener, Devon 2013
x
|
Introduction
11. Rank abundance or
dominance models
One vay of Iooking al lhe diversily of a communily is lo arrange lhe secies in order of
abundance and lhen Iol lhe resuIl on a grah. If lhe communily is very diverse lhen lhe
Iol viII aear 'fIal'. You mel lhis kind of aroach in Chaler 8 vhen Iooking al even-
ness and drev an evenness Iol in Seclion 8.3.4 using a TsaIIis enlroy rofiIe. In !"#$%&%'(
Iols lhe secies abundance is generaIIy reresenled as lhe Iog of lhe abundance.
Various modeIs have been roosed lo heI exIain lhe observed allerns of domi-
nance Iols. In lhis chaler you'II see hov lo creale lhese modeIs and lo visuaIise lhem
using commands in lhe *(+&% command ackage. Laler in lhe chaler you viII see hov lo
examine Iisher's Iog-series (Seclion 11.2) and Ireslon's IognormaI modeI (Seclion 11.3) bul
firsl you viII Iook al some dominance modeIs.
11.1 Dominance models
Rankabundance dominance (RAD) modeIs, or dominance/diversily Iols, shov Iogarilh-
mic secies abundances againsl secies rank order. They are oflen used as a vay lo anaIyse
lyes of communily dislribulion, arlicuIarIy in Ianl communilies.
The *(+&% ackage conlains severaI commands lhal aIIov you lo creale and visuaIise
RAD modeIs.
11.1.1 Types of RAD model
There are severaI modeIs in common use, each lakes lhe same inul dala (Iogarilhmic abun-
dance and rank of abundance) and uses various aramelers lo fil a modeI lhal describes
lhe observed allern.
There are five basic modeIs avaiIabIe via lhe *(+&% ackage:

LognormaI.

Ireemlion.

roken slick.

MandeIbrol.

Zif.
The radfit() command carries oul lhe necessary comulalions lo fil aII lhe modeIs lo a
communily dalasel. The resuIl is a comIicaled ob|ecl conlaining aII lhe modeIs aIied
11. Rank abundance or dominance models
|
335
lo each samIe in your dalasel. You can lhen delermine lhe 'besl' modeI for each samIe
lhal you have.
The *(+&% ackage aIso has searale commands lhal aIIov you lo inlerrogale lhe mod-
eIs and visuaIise lhem. You can aIso conslrucl a secific modeI for a samIe or enlire dala-
sel. The various modeIs are:

,"+%"-#&. Ianls are affecled by environmenl and each olher. The modeI viII
lend lo normaI, grovlh lends lo be Iogarilhmic so LognormaI modeI is IikeIy.

/-((#01$"% (Molomura modeI or geomelric series) resource arlilioning


modeI. The mosl comelilive secies grabs resources, vhich Ieaves Iess for olher
secies.

2-"3(% 41$'3 assumes abundance refIecls arlilioning aIong a gradienl. This is


oflen used as a %5.. modeI.

6&%!(.7-"1 cosl of informalion. Abundance deends on revious secies and


hysicaI condilions (lhe cosls). Iioneers lherefore have Iov cosls.

8$09 cosl of informalion. The forerunner of MandeIbrol (a subsel of il vilh fever


aramelers).
The modeIs each have a variely of aramelers, in each case lhe abundance of secies al
rank - (&
-
) is lhe caIcuIaled vaIue.
Broken stick model
The broken slick modeI has no acluaI aramelers: lhe abundance of secies al rank - is
caIcuIaled Iike so:
&
r
:/; (1/<)
In lhis modeI : is lhe number of individuaIs and ; is lhe number of secies in lhe com-
munily. This gives a nuII modeI vhere lhe individuaIs are randomIy dislribuled among
observed secies, and lhere are no filled aramelers.
Preemption model
The (niche) reemlion modeI (aIso caIIed Molomura modeI or geomelric series) has a
singIe filled arameler. The abundance of secies al rank - is caIcuIaled Iike so:
&
r
:(1 )
(- 1)
In lhis modeI : is lhe number of individuaIs and lhe arameler is a decay rale of abun-
dance vilh rank. In a reguIar RAD Iol (see Seclion 11.1.3) lhe modeI is a slraighl Iine.
Lognormal model
The IognormaI modeI has lvo filled aramelers, lhe abundance of secies al rank - is caI-
cuIaled Iike so:
&
r
ex(Iog() + Iog() =)
This modeI assumes lhal lhe Iogarilhmic abundances are dislribuled normaIIy. In lhe modeI,
= is a normaI deviale and and are lhe mean and slandard devialion of lhe dislribulion.
336
|
Community Ecology: Analytical Methods using R and Excel
Zipf model
In lhe Zif modeI lhere are lvo filled aramelers, lhe abundance of secies al rank - is
caIcuIaled Iike so:
&
r
: /
1
-

In lhe Zif modeI : is lhe number of individuaIs, /


>
is lhe roorlion of lhe mosl abundanl
secies and is a decay coefficienl.
Mandelbrot model
The MandeIbrol modeI adds one arameler lo lhe Zif modeI, lhe abundance of secies al
rank - is caIcuIaled Iike so:
&
r
:' (- + )

The addilion of lhe arameler Ieads lo lhe /


>
arl of lhe Zif modeI becoming a simIe
scaIing conslanl '.
Summary of models
Much has been vrillen aboul lhe ecoIogicaI and evoIulionary significance of lhe various
modeIs. If your dala haen lo fil a arlicuIar modeI il does nol mean lhal lhe underIying
ecoIogicaI lheory behind lhal modeI musl exisl for your communily. ModeIIing is a vay
lo lry lo undersland lhe reaI vorId in a simIer and rediclabIe fashion. The modeIs faII
inlo lvo basic cams:

ModeIs based on resource arlilioning.

ModeIs based on slalislicaI lheory.


The resource-arlilioning modeIs can be furlher sIil inlo lvo, oeraling over ecoIogicaI
lime or evoIulionary lime.
The broken slick modeI is an ecoIogicaI resource-arlilioning modeI. Il is oflen used
as a nuII modeI because il assumes lhal lhere are environmenlaI gradienls, vhich secies
arlilion in a simIe vay.
The reemlion modeI is an evoIulionary resource-arlilioning modeI. Il assumes lhal
lhe mosl comelilive secies viII gel a Iarger share of resources regardIess of vhen il
arrived in lhe communily.
The IognormaI modeI is a slalislicaI modeI. The IognormaI reIalionshi aears oflen
in communilies. One lheory is lhal secies are affecled by many faclors, environmenlaI
and comelilive lhis Ieads lo a normaI dislribulion. IIanl grovlh is Iogarilhmic so lhe
IognormaI modeI 'fils'. Nole lhal lhe normaI dislribulion refers lo lhe abundance-cIass
hislogram.
The Zif and MandeIbrol modeIs are slalislicaI modeIs reIaled lo lhe cosl of informa-
lion. The resence of a secies deends on revious condilions, environmenlaI and re-
vious secies resence lhese are lhe cosls. Iioneer secies have Iov cosls lhey do nol
need lhe resence of olher secies or rior condilions. Comelilor secies and Iale-succes-
sionaI secies have higher cosls, in lerms of energy, lime or ecosyslem organisalion.
You can lhink of lhe difference belveen IognormaI and Zif/MandeIbrol modeIs as
being hov lhe faclors lhal affecl lhe secies oerales:
11. Rank abundance or dominance models
|
337

LognormaI: faclors aIy simuIlaneousIy.

Zif/MandeIbrol: faclors aIy sequenliaIIy.


Mosl of lhe modeIs assume you have genuine counls of individuaIs. This is fine for animaI
communilies bul nol so sensibIe for Ianls, vhich have more Iaslic grovlh. In an ideaI
silualion you vouId use some kind of roxy for biomass lo assess Ianl communilies.
Cover scaIes are nol generaIIy vieved as being aIlogelher suilabIe bul of course if lhese are
aII lhe dala you've gol, lhen you'II robabIy go vilh lhem! In lhe nexl seclion you viII see
hov lo creale lhe various modeIs and examine lheir roerlies.
11.1.2 Creating RAD models
There are lvo main vays you couId roceed vhen il comes lo making RAD modeIs:

Make aII RAD modeIs and comare lhem.

Make a singIe RAD modeI.


In lhe firsl case you are mosl IikeIy lo reare aII lhe ossibIe modeIs so lhal you can see
vhich is lhe 'besl' for each samIe. In lhe second case you are mosl IikeIy lo vish lo com-
are a singIe modeI belveen samIes.
The radfit() command in lhe *(+&% ackage viII reare aII five RAD modeIs for a com-
munily dalasel or singIe samIe. You can aIso reare a singIe RAD modeI using commands
of lhe form rad.xxxx(), vhere xxxx is lhe name of lhe modeI you vanl (TabIe 11.1).
Table 11.1 RAD models and their corresponding R commands (from the vegan package).
RAD model Command
Lognormal
rad.lognormal()
Pre-emption
rad.preempt()
Broken stick
rad.null()
Mandelbrot
rad.zipfbrot()
Zipf
rad.zipf()
You'II see hov lo reare individuaI modeIs Ialer bul firsl you viII see hov lo reare aII
RAD modeIs for a samIe.
Preparing all RAD models
The radfit() command aIIovs you lo creale aII five common RAD modeIs for a com-
munily dalasel conlaining muIliIe samIes. You can aIso use il lo oblain modeIs for a
singIe samIe.
RAD model overview
To make a modeI you simIy use lhe radfit() command on a communily dalasel or
samIe. If you are Iooking al a dalasel vilh severaI samIes lhen lhe dala musl be in lhe
form of a data.frame. If you have a singIe samIe lhen lhe dala can be a simIe vector
or a matrix.
338
|
Community Ecology: Analytical Methods using R and Excel
The resuIl you see viII deend on vhelher you used a muIli-samIe dalasel or a singIe
samIe. Ior a dalasel vilh severaI samIes you see a rov for each of lhe five modeIs sIil
inlo coIumns for each samIe:
> gb.rad = radfit(gbt)
> gb.rad
Deviance for RAD models:
Edge Grass Wood
Null 6410.633 1697.424 2527.32
Preemption 571.854 422.638 155.43
Lognormal 740.107 72.456 856.94
Zipf 931.124 132.885 1427.66
Mandelbrot 229.538 45.899 155.43
If you onIy used a singIe samIe lhen lhe resuIl shovs a rov for each modeI vilh coIumns
shoving various resuIls:
> gb.rad.E1 <- radfit(gb.biol[1,])
> gb.rad.E1
RAD models, family poisson
No. of species 17, total abundance 715
par1 par2 par3 Deviance AIC BIC
Null 828.463 888.755 888.755
Preemption 0.5215 86.117 148.409 149.242
Lognormal 1.5238 2.4142 96.605 160.897 162.563
Zipf 0.63709 -2.0258 105.544 169.836 171.502
Mandelbrot 3399.6 -5.3947 3.9929 39.999 106.291 108.791
In any evenl you end u vilh a resuIl ob|ecl lhal conlains informalion aboul each of lhe
RAD modeIs. You can exIore lhe resuIl in more delaiI using a variely of 'heIer' com-
mands and by using lhe $ synlax lo viev lhe various resuIl comonenls.
RAD model components
Once you have your RAD modeI resuIl you can examine lhe various comonenls. The
resuIl of lhe radfit() command is a lye of list, vhich conlains severaI Iayers of com-
onenls. The lo 'Iayer' is a resuIl for each samIe:
> gbt.rad
Deviance for RAD models:
Edge Grass Wood
Null 6410.633 1697.424 2527.32
Preemption 571.854 422.638 155.43
Lognormal 740.107 72.456 856.94
Zipf 931.124 132.885 1427.66
Mandelbrot 229.538 45.899 155.43
> names(gbt.rad)
[1] "Edge" "Grass" "Wood"
11. Rank abundance or dominance models
|
339
Ior each named samIe lhere are furlher Iayers:
> names(gbt.rad$Edge)
[1] "y" "family" "models"
The $models Iayer conlains lhe five RAD modeIs:
> names(gbt.rad$Edge$models)
[1] "Null" "Preemption" "Lognormal" "Zipf" "Mandelbrot"
Iach of lhe modeIs conlains severaI comonenls:
> names(gbt.rad$Edge$models$Mandelbrot)
[1] "model" "family" "y" "coefficients"
[5] "fitted.values" "aic" "rank" "df.residual"
[9] "deviance" "residuals" "prior.weights"
So, by using lhe $ synlax you can driII dovn inlo lhe resuIl and viev lhe searale com-
onenls. AIC vaIues, for examIe, are used lo delermine lhe 'besl' modeI from a range
of olions. The AIC vaIues are an eslimale of informalion 'Iosl' vhen a modeI is used lo
reresenl a silualion. In lhe foIIoving exercise you can have a go al crealing a series of
RAD modeIs for lhe 18-samIe ground beelIe communily dala. You can lhen examine lhe
delaiIs and comare modeIs.
Have a Go: Create multiple RAD models for a
community dataset
Ior lhis exercise you viII need lhe ground beelIe dala in lhe ?@A@BAC&1& fiIe. You viII
aIso need lhe *(+&% ackage.
1. Slarl by rearing lhe *(+&% ackage:
> library(vegan)
2. Make a series of RAD modeIs for lhe ground beelIe dala you may gel varnings,
vhich reIale lo lhe filling of some of lhe generaIised Iinear modeIs do nol vorry
overIy aboul lhese:
> gb.rad <- radfit(gb.biol)
3. Viev lhe resuIl by lying ils name you viII see lhe deviance for each modeI/sam-
Ie combinalion:
> gb.rad

Deviance for RAD models:

E1 E2 E3 E4 E5 E6 G1
Null 828.4633 546.8046 532.3123 874.3219 893.7626 701.7052 331.3146
Preemption 86.1171 74.6780 49.5901 155.1716 101.2498 75.4722 131.4807
Lognormal 96.6051 144.1771 110.9866 138.4723 148.3373 137.1522 27.4805
Zipf 105.5441 184.9127 145.8725 162.6555 197.7341 186.7730 14.7817
Mandelbrot 39.9992 74.6780 49.5901 63.0773 106.0696 75.4718 14.5470
G2 G3 G4 G5 G6 W1 W2
Null 155.8671 85.2082 132.7137 199.5453 135.7377 684.9151 272.1441
Preemption 51.0619 23.3040 42.5072 62.1768 45.4607 99.0215 25.4618
340
|
Community Ecology: Analytical Methods using R and Excel
Lognormal 13.7845 9.7973 14.3199 15.8622 18.7468 286.6316 92.0102
Zipf 11.6686 10.9600 23.3319 19.1257 25.5595 398.0188 179.2625
Mandelbrot 4.2693 3.0943 4.7256 7.0041 8.9452 99.0212 25.4566
W3 W4 W5 W6
Null 270.9451 296.5025 330.6709 204.388
Preemption 20.5931 42.4143 47.5003 32.311
Lognormal 75.1871 153.1896 174.7615 78.464
Zipf 143.4578 238.3210 282.7760 168.513
Mandelbrot 20.5906 42.4127 47.4973 32.299
4. Use lhe summary() command lo give delaiIs aboul each samIe and lhe modeI
delaiIs lhe Iisl is quile exlensive:
> summary(gb.rad)
*** E1 ***
RAD models, family poisson
No. of species 17, total abundance 715
par1 par2 par3 Deviance AIC BIC
Null 828.463 888.755 888.755
Preemption 0.5215 86.117 148.409 149.242
Lognormal 1.5238 2.4142 96.605 160.897 162.563
Zipf 0.63709 -2.0258 105.544 169.836 171.502
Mandelbrot 3399.6 -5.3947 3.9929 39.999 106.291 108.791
5. Look al lhe samIes avaiIabIe for inseclion:
> names(gb.rad)
[1] "E1" "E2" "E3" "E4" "E5" "E6" "G1" "G2" "G3" "G4" "G5" "G6" "W1" "W2"
[15] "W3" "W4" "W5" "W6"
6. Use lhe $ synlax lo viev lhe RAD modeIs for lhe D> samIe:
> gb.rad$W1
RAD models, family poisson
No. of species 12, total abundance 1092
par1 par2 par3 Deviance AIC BIC
Null 684.915 737.908 737.908
Preemption 0.47868 99.022 154.015 154.499
Lognormal 3.2639 1.7828 286.632 343.625 344.594
Zipf 0.53961 -1.6591 398.019 455.012 455.982
Mandelbrot Inf -1.3041e+08 2.0021e+08 99.021 158.014 159.469
7. Irom sle 6 you can see lhal lhe reemlion modeI has lhe Iovesl AIC vaIue. Viev
lhe AIC vaIues for aII lhe modeIs and samIes:
> sapply(gb.rad, function(x) unlist(lapply(x$models, AIC)))
E1 E2 E3 E4 E5 E6 G1
Null 888.7550 604.7068 589.1388 965.4858 973.9772 771.2113 418.5341
Preemption 148.4088 134.5803 108.4166 248.3355 183.4645 146.9783 220.7002
Lognormal 160.8968 206.0793 171.8131 233.6363 232.5519 210.6583 118.7000
Zipf 169.8358 246.8149 206.6991 257.8194 281.9487 260.2791 106.0012
Mandelbrot 106.2909 138.5802 112.4166 160.2413 192.2843 150.9779 107.7665
11. Rank abundance or dominance models
|
341
The slruclure of lhe resuIl for a singIe samIe is lhe same as for lhe muIli-samIe dala bul
you have one Iess IeveI of dala you do nol have lhe samIe names.
y comaring lhe AIC vaIues for lhe various modeIs you can delermine lhe 'besl' modeI
for each samIe, as you sav in sle 7 of lhe receding exercise.
The radfit() command assumes lhal your dala are genuine counl dala and lherefore
are inlegers. If you have vaIues lhal are some olher measure of abundance lhen you'II
have lo modify lhe modeI filling rocess by using a differenl dislribulion family, such
as Gamma. This is easiIy carried oul by using lhe family = Gamma inslruclion in lhe
radfit() command. In lhe foIIoving exercise you can have a go al making RAD modeIs
for some non-inleger dala lhal require a E&##& fil.
G2 G3 G4 G5 G6 W1 W2
Null 229.47852 144.66473 226.4738 286.5904 19.38683 737.9082 325.96427
Preemption 126.67329 84.76055 138.2674 151.2219 131.10975 154.0146 81.28201
Lognormal 91.39596 73.25383 112.0800 106.9072 106.39589 343.6247 149.83040
Zipf 89.27999 74.41651 121.0921 110.1708 113.20861 455.0118 237.08266
Mandelbrot 83.88072 68.55087 104.4857 100.0491 98.59426 158.0142 85.27674
W3 W4 W5 W6
Null 323.27808 350.63206 385.2040 252.71046
Preemption 74.92607 98.54388 104.0333 82.63346
Lognormal 131.52006 211.31915 233.2946 130.78639
Zipf 199.79075 296.45061 341.3091 220.83585
Mandelbrot 78.92356 102.54224 108.0304 86.62174
8. Look al vhal modeIs are avaiIabIe for lhe E> samIe:
> names(gb.rad$G1$models)
[1] "Null" "Preemption" "Lognormal" "Zipf" "Mandelbrot"
9. Viev lhe IognormaI modeI for lhe E> samIe:
> gb.rad$G1$models$Lognormal
RAD model: Log-Normal
Family: poisson
No. of species: 28
Total abundance: 365
log.mu log.sigma Deviance AIC BIC
0.8149253 2.0370676 27.4805074 118.6999799 121.3643889
The $ synlax aIIovs you lo exIore lhe modeIs in delaiI and, as you sav in sle 7, you
can aIso gel a summary of lhe 'imorlanl' eIemenls of lhe modeIs.
Have a Go: Create RAD models for abundance
data using a Gamma distribution
You viII need lhe *(+&% ackage for lhis exercise and lhe 79B7$". dala, vhich are found
in lhe ?@A@BAC&1& fiIe.
1. Slarl by rearing lhe *(+&% ackage:
> library(vegan)
342
|
Community Ecology: Analytical Methods using R and Excel
Il is usefuI lo visuaIise lhe modeIs lhal you make, and you'II see hov lo do lhis shorlIy
(Seclion 11.1.3) bul before lhal you viII see hov lo reare singIe RAD modeIs.
Preparing single RAD models
Ralher lhan reare aII five RAD modeIs you mighl refer lo examine a singIe modeI. You
can use lhe $ synlax lo gel lhe singIe modeIs from a radfit() resuIl bul lhis can be a bil
ledious.
The *(+&% ackage conlains severaI commands lhal aIIov you lo creale individuaI RAD
modeIs (TabIe 11.1). These commands are designed lo oerale on singIe samIes ralher
lhan dala frames conlaining muIliIe samIes. Hovever, vilh some coercion you can make
resuIls ob|ecls conlaining a singIe RAD modeI for severaI samIes. An advanlage of singIe
modeIs is lhal you can use various 'heIer' commands lo exlracl modeI comonenls. In lhe
foIIoving exercise you can have a go al making some singIe RAD modeI resuIls.
2. The 79B7$". dala vere reared from lhe 79 dala. The xtabs() command vas used
and lhe resuIl is a labIe ob|ecl lhal has lvo cIasses Iook al lhe dala cIass:
> class(bf.biol)
[1] "xtabs" "table"
3. You need lo gel lhese dala inlo a data.frame formal so lhal lhe radfit() com-
mand can reare a series of modeIs for each samIe:
> bfs =as.matrix(bf.biol)
> class(bfs) = "matrix"
> bfs = as.data.frame(bfs)
4. Nov make a radfit() resuIl using a Gamma dislribulion, since lhe dala are nol inle-
gers. You viII gel varnings lhal lhe generaIised Iinear modeI did nol converge:
> bfs.rad = radfit(bfs, family = Gamma)
5. Look al lhe RAD modeIs you reared:
> bfs.rad
Deviance for RAD models:
1996 1997 1998 1999 2000 2001
Null 6.75808 5.90335 9.76398 16.10717 14.07862 12.34689
Preemption 0.82914 1.24224 1.16693 2.23559 2.61460 0.52066
Lognormal 2.32981 1.95389 3.34543 3.85454 2.67501 1.27117
Zipf 3.80899 5.85292 5.03517 2.57252 2.50295 4.76591
Mandelbrot 0.65420 1.19315 1.13141 0.80418 1.08860 0.51195
2002 2003 2004 2005
Null 18.68292 22.86051 18.99316 14.3380
Preemption 1.84098 4.44566 2.68697 1.9573
Lognormal 2.71852 3.41538 4.32521 3.0185
Zipf 3.26510 3.39652 3.14484 2.2478
Mandelbrot 0.95159 2.62833 1.11120 0.6803
The RAD modeIs reared using lhe Gamma dislribulion can be handIed Iike lhe mod-
eIs you made using lhe Ioisson dislribulion (lhe defauIl).
11. Rank abundance or dominance models
|
343
Have a Go: Create single RAD models for community data
Ior lhis exercise you viII need lhe ground beelIe dala in lhe ?@A@BAC&1& fiIe. You viII
aIso need lhe *(+&% ackage.
1. Slarl by rearing lhe *(+&% ackage:
> library(vegan)
2. Make a reemlion modeI for lhe D> samIe:
> gbW1.pe = rad.preempt(gb.biol["W1",])
> gbW1.pe
RAD model: Preemption
Family: poisson
No. of species: 12
Total abundance: 1092
alpha Deviance AIC BIC
0.4786784 99.0215048 154.0145519 154.4994586
3. Gel lhe filled vaIues from lhe modeI:
> fitted(gbW1.pe)
[1] 522.7168308 272.5035660 142.0619905 74.0599819 38.6090670
[6] 20.1277400 10.4930253 5.4702405 2.8517545 1.4866812
[11] 0.7750390 0.4040445
4. Nov make a MandeIbrol modeI for lhe E> samIe:
> gbG1.zb = rad.zipfbrot(gb.biol["G1",])
5. Use some heIer commands lo exlracl lhe AIC and coefficienls from lhe modeI:
> AIC(gbG1.zb)
[1] 107.7665
> coef(gbG1.zb)
c gamma beta
0.6001759 -1.6886844 0.1444777
6. Nov make a IognormaI modeI for lhe enlire dalasel use lhe apply() command
Iike so:
> gb.ln = apply(gb.biol, MARGIN = 1, rad.lognormal)
7. Use lhe names() command lo see lhal lhe resuIl conlains a modeI for each samIe:
> names(gb.ln)
[1] "E1" "E2" "E3" "E4" "E5" "E6" "G1" "G2" "G3" "G4" "G5" "G6" "W1"
[14] "W2" "W3" "W4" "W5" "W6"
> names(gb.ln$E1)
[1] "model" "family" "y" "coefficients"
[5] "fitted.values" "aic" "rank" "df.residual"
[9] "deviance" "residuals" "prior.weights"
8. Viev lhe modeI for lhe @> samIe:
> gb.ln$E1
344
|
Community Ecology: Analytical Methods using R and Excel
Tip: The lapply() and sapply() commands
The lapply() command oerales on list ob|ecls and aIIovs you lo use a funclion over
lhe comonenls of lhe list. The resuIl is ilseIf a list, vilh names lhe same as lhe originaI
comonenls. The sapply() command is very simiIar bul lhe resuIl is a matrix ob|ecl,
vhich may be more convenienl.
In lhe receding exercise you used lhe AIC(), coef() and fitted() commands lo exlracl
lhe AIC vaIues, coefficienls and lhe filled vaIues from lhe modeIs. Olher 'heIer' commands
are deviance() and resid(), vhich roduce lhe deviance and residuaIs resecliveIy.
Comparing different RAD models
You've aIready seen hov lo Iook al lhe differenl modeIs and lo comare lhem, by Iooking
al AIC vaIues for examIe. The sapply() command is arlicuIarIy usefuI as il aIIovs you
lo execule a command over lhe various eIemenls of lhe resuIl (vhich is a kind of list).
Il vouId be usefuI lo delermine if differenl modeIs vere significanlIy differenl from one
anolher. The modeI vilh lhe Iovesl AIC vaIue is considered lo be lhe 'besl' and il is easy
lo see vhich lhis is by inseclion:
> sapply(mod, function(x) unlist(lapply(x$models, AIC)))
Edge Grass Wood
Null 6535.1052 1850.7079 2604.8112
Preemption 698.3265 577.9220 234.9224
Lognormal 868.5789 229.7401 938.4294
Zipf 1059.5962 290.1691 1509.1537
Mandelbrot 360.0098 205.1833 238.9203
RAD model: Log-Normal
Family: poisson
No. of species: 17
Total abundance: 715
log.mu log.sigma Deviance AIC BIC
1.523787 2.414170 96.605129 160.896843 162.563270
9. Nov viev lhe coefficienls for aII lhe samIes:
> sapply(gb.ln, FUN = coef)
E1 E2 E3 E4 E5 E6
log.mu 1.523787 2.461695 2.107499 1.686040 2.052081 2.371504
log.sigma 2.414170 1.952583 2.056276 2.120549 2.092042 1.995912
G1 G2 G3 G4 G5 G6
log.mu 0.8149253 1.249582 1.284923 1.369442 1.286567 1.500785
log.sigma 2.0370676 1.761516 1.651098 1.588253 1.760267 1.605790
W1 W2 W3 W4 W5 W6
log.mu 3.263932 3.470459 3.269124 3.178878 3.357883 3.525677
log.sigma 1.782800 1.540651 1.605284 1.543145 1.526280 1.568422
The resuIl you oblained in sle 6 is a list ob|ecl so you used lhe sapply() command
lo gel lhe coefficienls in sle 9.
11. Rank abundance or dominance models
|
345
Il is a IillIe more difficuIl lo gel a resuIl lhal shovs lhe 'besl' modeI for each samIe. In lhe
foIIoving exercise you can have a go al making a resuIl ob|ecl lhal conlains lhe Iovesl AIC
vaIue and lhe malching modeI name for every samIe.
Have a Go: Create a result object that shows the lowest
AIC and matching model name for a radfit() result
Ior lhis exercise you viII need lhe ground beelIe dala in lhe ?@A@BAC&1& fiIe. You viII
aIso need lhe *(+&% ackage.
1. Slarl by rearing lhe *(+&% ackage:
> library(vegan)
2. Make a RAD resuIl using lhe radfit() command:
> gb.rad = radfit(gb.biol)
3. Tying lhe resuIl name gives lhe deviance bul you need lhe AIC vaIues as a resuIl
ob|ecl so use lhe sapply() command Iike so:
> gb.aic = sapply(gb.rad, function(x) unlist(lapply(x$models, AIC)))
4. Viev lhe resuIl: you gel five rovs, one for each modeI, and a coIumn for each
samIe:
> gb.aic[, 1:6]
E1 E2 E3 E4 E5 E6
Null 888.7550 604.7068 589.1388 965.4858 973.9772 771.2113
Preemption 148.4088 134.5803 108.4166 248.3355 183.4645 146.9783
Lognormal 160.8968 206.0793 171.8131 233.6363 232.5519 210.6583
Zipf 169.8358 246.8149 206.6991 257.8194 281.9487 260.2791
Mandelbrot 106.2909 138.5802 112.4166 160.2413 192.2843 150.9779
5. The resuIl is a matrix so converl il lo a data.frame:
> gb.aic = as.data.frame(gb.aic)
6. Nov make an index lhal shovs vhich AIC vaIue is lhe Iovesl for every samIe:
> index <- apply(gb.aic, MARGIN = 2, function(x) which(x == min(x)))
> index
E1 E2 E3 E4 E5 E6 G1 G2 G3 G4 G5 G6 W1 W2 W3 W4 W5 W6
5 2 2 5 2 2 4 5 5 5 5 5 2 2 2 2 2 2
7. You vanl lo make a nev veclor lhal conlains lhe Iovesl AIC vaIues. You need a
simIe Ioo:
> aicval <- numeric(0)
> for(i in 1:ncol(gb.aic)) {
aicval[i] <- gb.aic[which(gb.aic[,i] == min(gb.aic[,i])), i]
}
8. In sle 7 you sel-u a 'dummy' veclor lo receive lhe resuIls. Then lhe Ioo runs for as
many coIumns as lhere are in lhe AIC resuIls. Iach lime around lhe Ioo gels lhe mini-
mum AIC vaIue for lhal coIumn and adds il lo lhe dummy veclor. Viev lhe resuIl:
346
|
Community Ecology: Analytical Methods using R and Excel
Note: Minimum AIC values and RAD model
The sles in lhe exercise lhal crealed lhe data.frame conlaining lhe minimum AIC vaIues
and lhe corresonding RAD modeI name are ackaged inlo a cuslom funclion rad_aic(),
vhich is arl of lhe ?@A@BAC&1& fiIe.
The minimum AIC vaIues aIIov you lo seIecl lhe 'besl' RAD modeI bul hov do you knov
if lhere is any significanl difference belveen modeIs` Il may be lhal severaI modeIs are
equaIIy 'good'. There is no raclicaI vay of delermining lhe slalislicaI difference belveen
RAD modeIs because lhey are based on differenl dala (lhe modeIs use differenl aram-
> aicval
[1] 106.29094 134.58026 108.41663 160.24125 183.46446 146.97826
[7] 106.00117 83.88072 68.55087 104.48570 100.04912 98.59426
[13] 154.01455 81.28201 74.92607 98.54388 104.03335 82.63346
9. Assign names lo lhe minimum AIC vaIues by using lhe originaI samIe names:
> names(aicval) <- colnames(gb.aic)
> aicval
E1 E2 E3 E4 E5 E6 G1
106.29094 134.58026 108.41663 160.24125 183.46446 146.97826 106.00117
G2 G3 G4 G5 G6 W1 W2
83.88072 68.55087 104.48570 100.04912 98.59426 154.01455 81.28201
W3 W4 W5 W6
74.92607 98.54388 104.03335 82.63346
10. Nov use lhe index vaIue you made in sle 6 lo gel lhe names of lhe RAD modeIs
lhal corresond lo lhe Iovesl AIC vaIues:
> monval <- rownames(gb.aic)[index]
11. Assign lhe samIe names lo lhe modeIs so you can kee lrack of vhich modeI
beIongs lo vhich samIe:
> names(monval) <- colnames(gb.aic)
> monval
E1 E2 E3 E4 E5
"Mandelbrot" "Preemption" "Preemption" "Mandelbrot" "Preemption"
E6 G1 G2 G3 G4
"Preemption" "Zipf" "Mandelbrot" "Mandelbrot" "Mandelbrot"
G5 G6 W1 W2 W3
"Mandelbrot" "Mandelbrot" "Preemption" "Preemption" "Preemption"
W4 W5 W6
"Preemption" "Preemption" "Preemption"
12. Nov assembIe lhe resuIls inlo a nev data.frame:
> gb.models <- data.frame(AIC = aicval, Model = monval)
Your finaI resuIl has lvo coIumns, one conlaining lhe Iovesl AIC and a coIumn con-
laining lhe name of lhe corresonding RAD modeI. The rov names of lhe data.frame
conlain lhe samIe names so lhere is no need lo make an addilionaI coIumn.
11. Rank abundance or dominance models
|
347
elers). This means you cannol use lhe anova() command for examIe, Iike you mighl vilh
lm() or glm() modeIs.
If you have reIicale samIes, hovever, you can use anaIysis of variance lo exIore
differences belveen modeIs. The rocess invoIves Iooking al lhe variabiIily in lhe modeI
deviance belveen reIicales. In lhe foIIoving exercise you can have a go al exIoring vari-
abiIily in RAD modeIs for a subsel of lhe ground beelIe dala vilh six reIicales.
Have a Go: Perform ANOVA on RAD model deviance
Ior lhis exercise you viII need lhe ground beelIe dala in lhe ?@A@BAC&1& fiIe. You viII
aIso need lhe *(+&% ackage.
1. Slarl by rearing lhe *(+&% ackage:
> library(vegan)
2. Make a RAD modeI resuIl from lhe firsl six rovs of lhe ground beelIe dala (reIaling
lo lhe @!+( habilal) using lhe radfit() command:
> Edge.rad = radfit(gb.biol[1:6, ])
3. Ixlracl lhe deviance from lhe resuIl:
> Edge.dev = sapply(Edge.rad, function(x)
unlist(lapply(x$models, deviance)))
> Edge.dev
E1 E2 E3 E4 E5 E6
Null 828.46326 546.80456 532.31232 874.32187 893.7626 701.70519
Preemption 86.11705 74.67805 49.59012 155.17162 101.2498 75.47216
Lognormal 96.60513 144.17705 110.98661 138.47233 148.3373 137.15216
Zipf 105.54412 184.91272 145.87254 162.65549 197.7341 186.77304
Mandelbrot 39.99923 74.67802 49.59008 63.07732 106.0696 75.47178
4. Nov rolale lhe resuIl so lhal lhe modeIs form lhe coIumns and lhe reIicales (sam-
Ies) are lhe rovs:
> Edge.dev = t(Edge.dev)
> Edge.dev
Null Preemption Lognormal Zipf Mandelbrot
E1 828.4633 86.11705 96.60513 105.5441 39.99923
E2 546.8046 74.67805 144.17705 184.9127 74.67802
E3 532.3123 49.59012 110.98661 145.8725 49.59008
E4 874.3219 155.17162 138.47233 162.6555 63.07732
E5 893.7626 101.24981 148.33726 197.7341 106.06963
E6 701.7052 75.47216 137.15216 186.7730 75.47178
5. You viII need lo use lhe stack() command lo rearrange lhe dala inlo lvo coI-
umns, one for lhe deviance and one for lhe modeI name. Hovever, firsl you need
lo converl lhe resuIl inlo a data.frame ob|ecl:
> Edge.dev = as.data.frame(Edge.dev)
> class(Edge.dev)
[1] "data.frame"
6. Nov you can use lhe stack() command and aIler lhe coIumn names:
348
|
Community Ecology: Analytical Methods using R and Excel
> Edge.dev = stack(Edge.dev)
> names(Edge.dev) = c("deviance", "model")
7. You nov have a data.frame lhal can be used for anaIysis. efore lhal lhough
you shouId aIler lhe names of lhe RAD modeIs as lhey are quile Iong make lhem
shorler:
> levels(Edge.dev$model) = c("Log", "Mb", "BS", "Pre", "Zip")
8. Nov carry oul an ANOVA on lhe deviance lo see if lhere are significanl differences
belveen lhe RAD modeIs use lhe Iogarilhm of lhe deviance lo heI normaIise lhe
dala:
> Edge.aov = aov(log(deviance) ~ model, data = Edge.dev)
> summary(Edge.aov)
Df Sum Sq Mean Sq F value Pr(>F)
model 4 20.9193 5.2298 65.545 6.937e-13 ***
Residuals 25 1.9948 0.0798
---
Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
9. Use lhe TukeyHSD() command lo exIore differences belveen lhe individuaI
modeIs:
> TukeyHSD(Edge.aov, ordered = TRUE)
Tukey multiple comparisons of means
95% family-wise confidence level
factor levels have been ordered
Fit: aov(formula = log(deviance) ~ model, data = Edge.dev)
$model
diff lwr upr p adj
Pre-Mb 0.2700865 -0.20887308 0.7490461 0.4776096
Log-Mb 0.6773801 0.19842055 1.1563397 0.0028170
Zip-Mb 0.9053575 0.42639796 1.3843171 0.0000820
BS-Mb 2.3975406 1.91858106 2.8765002 0.0000000
Log-Pre 0.4072936 -0.07166594 0.8862532 0.1233203
Zip-Pre 0.6352710 0.15631147 1.1142306 0.0053397
BS-Pre 2.1274541 1.64849457 2.6064137 0.0000000
Zip-Log 0.2279774 -0.25098216 0.7069370 0.6345799
BS-Log 1.7201605 1.24120094 2.1991201 0.0000000
BS-Zip 1.4921831 1.01322353 1.9711427 0.0000000
10. VisuaIise lhe differences belveen lhe modeIs by using a box-vhisker Iol. Your
Iol shouId resembIe Iigure 11.1:
> boxplot(log(deviance) ~ model, data = Edge.dev, las = 1)
> title(xlab = "RAD model", ylab = "Log(model deviance)")
11. You can see from lhe resuIls lhal lhere are differences belveen lhe RAD modeIs. The
MandeIbrol modeI has lhe Iovesl overaII deviance bul il is nol significanlIy differ-
enl from lhe reemlion modeI. You can see lhis more cIearIy if you Iol lhe Tukey
resuIl direclIy, lhe foIIoving command roduces a Iol lhal Iooks Iike Iigure 11.2:
> plot(TukeyHSD(Edge.aov, ordered = TRUE), las = 1)
11. Rank abundance or dominance models
|
349
Log Mb BS Pre Zip
4.0
4.5
5.0
5.5
6.0
6.5
RAD model
L
o
g
(
m
o
d
e
l

d
e
v
i
a
n
c
e
)
Figure 11.1 Model deviance (log deviance) for various RAD models. Log = lognormal,
Mb = Mandelbrot, BS = broken stick, Pre = preemption, Zip = ZipfMandelbrot.
!"! !"# !"# !"# !"# !"# !"#
!"#$%&
!"#$%&
!"#$%&'
!"#$%&
!"#$%&'
!"#$%&'
!"#$%
!"#$%&
!"#$%&
!"#$%&
95% famiIy-wise confidence IeveI
Differences in mean levels of model
Figure 11.2 Tukey HSD result of pairwise differences in RAD model for ground beetle
communities.
In lhis case lhe deviance of lhe originaI RAD modeIs vas Iog lransformed lo heI vilh
normaIising lhe dala nolice lhal you do nol have lo make a lransformed variabIe in
advance, you can do il from lhe aov() and boxplot() commands direclIy.
350
|
Community Ecology: Analytical Methods using R and Excel
Tip: Reordering variables
In many cases lhe factor variabIes lhal you use in anaIyses are unordered. R lakes lhem
aIhabelicaIIy and lhis can be 'inconvenienl' for some Iols. Use lhe reorder() command lo
aIler lhe order of lhe various factor IeveIs. The command vorks Iike so:
reorder(factor, response, FUN = mean)
So, if you vanl lo reorder lhe factor lo shov a boxIol in order of mean vaIue you vouId
use lhe command lo make a nev 'version' of lhe originaI factor, vhich you lhen use in
your boxplot() command.
Note: ANOVA for RAD models
The commands required for conducling ANOVA on RAD modeIs are bundIed inlo a cus-
lom command, rad_test(), vhich is arl of lhe ?@A@BAC&1& fiIe. The command incIudes
print(), summary() and plot() melhods, lhe Ialler aIIoving you lo roduce a boxIol
of lhe deviance or a Iol of lhe osl-hoc resuIls.
11.1.3 Visualising RAD models using dominance/diversity plots
You need lo be abIe lo visuaIise lhe RAD modeIs as dominance/diversily Iols. The
radfit() and rad.xxxx() commands have lheir ovn plot() roulines, some of vhich
use lhe .&11$'( ackage. This ackage comes as arl of lhe basic R inslaIIalion bul is nol
Ioaded unliI required.
Mosl oflen you viII have lhe resuIl of a radfit() command and viII have a resuIl lhal
gives you aII five RAD modeIs for lhe samIes in your communily dalasel. In lhe foIIoving
exercise you can have a go al comaring lhe DD Iols for aII lhe samIes in a communily
dalasel.
Have a Go: Visualise RAD models from multiple samples
Ior lhis exercise you viII need lhe ground beelIe dala in lhe ?@A@BAC&1& fiIe. You viII
aIso need lhe *(+&% ackage. The .&11$'( ackage viII be used bul lhis shouId aIready be
inslaIIed as arl of lhe normaI inslaIIalion of R.
1. Slarl by rearing lhe *(+&% ackage:
> library(vegan)
2. Make a RAD modeI from lhe ground beelIe dala using lhe radfit() command:
> gb.rad = radfit(gb.biol)
3. Make a Iol lhal shovs aII lhe samIes and seIecls lhe besl RAD modeI for each
one. The plot() command viII uliIise lhe .&11$'( ackage, vhich viII be readied if
necessary. The finaI grah shouId resembIe Iigure 11.3:
> plot(gb.rad)
11. Rank abundance or dominance models
|
351
4. Nov make a Iol lhal shovs aII samIes bul for a singIe RAD modeI (/-((#01$"%),
your grah shouId resembIe Iigure 11.4:
> plot(gb.rad, model = "Preemption")
!"#$
!
"
#
$
%
&
$
'
(
!
!
!"
!"
!""
!""
!" !"
! ! !" !" !" !"
!" !" !" !"
! ! !" !" !" !"
!" !" !" !"
!" !" !" !" !" !" !" !"
!
!
!"
!"
!""
!""
!" !"
!
!
!"
!"
!""
!""
!" !" !" !" !" !" !" !" !" !"
! ! !" !" !" !"
!" !" !" !"
! ! !" !" !" !"
!
!
!"
!"
!""
!""
!" !"
!"##
Preemption
!"#$"%&'(
!"#$
Mandelbrot
Figure 11.3 RAD models for 18 samples of ground beetles. Each panel shows the RAD
model with the lowest AIC.
!"#$
!
"
#
$
%
&
$
'
(
!
!
!"
!"
!""
!""
!" !"
! ! !" !" !" !"
!" !" !" !"
! ! !" !" !" !"
!" !" !" !"
!" !" !" !" !" !" !" !"
!
!
!"
!"
!""
!""
!" !"
!
!
!"
!"
!""
!""
!" !" !" !" !" !" !" !" !" !"
! ! !" !" !" !"
!" !" !" !"
! ! !" !" !" !"
!
!
!"
!"
!""
!""
!" !"
!"##
Preemption
!"#$"%&'(
!"#$
Mandelbrot
Figure 11.4 Dominance/diversity for the preemption RAD model for 18 samples of ground
beetles.
352
|
Community Ecology: Analytical Methods using R and Excel
If you have a singIe samIe and a radfit() resuIl, conlaining lhe five RAD modeIs, you
can use lhe plot() command lo roduce a sIighlIy differenl Iooking Iol. In lhis inslance
you gel a singIe Iol vindov vilh lhe 'fil Iines' suerimosed onlo a singIe Iol vindov.
If you vanl a Iol vilh searale aneIs you can use lhe radlattice() command lo ro-
duce one. In lhe foIIoving exercise you can have a go al visuaIising RAD modeIs for a
singIe samIe.
Have a Go: Visualise RAD models for a single sample
Ior lhis exercise you viII need lhe ground beelIe dala in lhe ?@A@BAC&1& fiIe. You viII
aIso need lhe *(+&% ackage. The .&11$'( ackage viII be used bul lhis shouId aIready be
inslaIIed as arl of lhe normaI inslaIIalion of R.
1. Slarl by rearing lhe *(+&% ackage:
> library(vegan)
2. Make a RAD modeI from lhe ground beelIe dala using lhe radfit() command:
> gb.rad = radfit(gb.biol)
3. Nov use lhe plot() command lo viev aII lhe RAD modeIs for lhe @> samIe, your
Iol shouId resembIe Iigure 11.5:
> plot(gb.rad$E1)
! !" !"
!
!
!
!
"
!
"
!
"
!
"
"
!
"
"
!"#$
!
"
#
$
%
&
$
'
(
!"##
Preemption
!"#$"%&'(
!"#$
Mandelbrot
Figure 11.5 Dominance/diversity for RAD models in a sample of ground beetles.
Il is nol easy lo aIler lhe coIours on lhe Iols lhese are sel by lhe plot() command
inlernaIIy.
11. Rank abundance or dominance models
|
353
Tip: Plot axes in log scale
To Iol bolh axes in a Iog scaIe you can simIy use lhe log = "xy" inslruclion as arl of
your plot() command. Nole lhough lhal lhis onIy vorks for Iols lhal oerale in a singIe
vindov and nol lhe .&11$'( lye Iols.
In lhe receding exercise you used lhe defauIl coIours and Iine slyIes. Il is nol lriviaI lo
aIler lhem because lhey are buiIl-in lo lhe commands and nol 'avaiIabIe' as searale user-
conlroIIed inslruclions. Hovever, you can roduce a more cuslomised grah by roduc-
!"#$
!
"
#
$
%
&
$
'
(
!"#
!"!
!"#
!"#
!"#
AC = 888.75 AC = 888.75
!"## !"##
! !" !"
AC = 148.41 AC = 148.41
Preemption Preemption
AC = 160.90 AC = 160.90
!"#$"%&'( !"#$"%&'(
! !" !"
AC = 169.84 AC = 169.84
!"#$ !"#$
!"#
!"!
!"#
!"#
!"#
AC = 106.29 AC = 106.29
Mandelbrot Mandelbrot
Figure 11.6 Dominance/diversity for RAD models in a sample of ground beetles.
4. You can comare lhe five modeIs in searale aneIs by using lhe radlattice()
command, your grah shouId resembIe Iigure 11.6:
> radlattice(gb.rad$E1)
In lhis exercise you seIecled a singIe samIe from a radfit() resuIl lhal conlained
muIliIe samIes. You can make a resuIl for a singIe samIe easiIy by simIy secifying
lhe aroriale samIe in lhe radfit() command ilseIf, e.g.
> radfit(gb.biol["E1", ]
Hovever, il is easy enough lo reare a resuIl for aII samIes and lhen you are abIe lo
seIecl any one you vish.
354
|
Community Ecology: Analytical Methods using R and Excel
ing singIe RAD modeI resuIls. These singIe-modeI resuIls have plot(), lines() and
points() melhods, vhich aIIov you fine conlroI over lhe grahs you roduce.
Customising DD plots
The reguIar plot() and radlattice() commands aIIov you lo comare RAD modeIs
for one or more samIes. Hovever, you may vish lo visuaIise arlicuIar modeI-samIe
combinalions and roduce a more 'largeled' Iol. In lhe foIIoving exercise you can have a
go al making a more seIeclive Iol.
Have a Go: Make a selective dominance/diversity plot
Ior lhis exercise you viII need lhe ground beelIe dala in lhe ?@A@BAC&1& fiIe. You viII
aIso need lhe *(+&% ackage. The .&11$'( ackage viII be used bul lhis shouId aIready be
inslaIIed as arl of lhe normaI inslaIIalion of R.
1. Slarl by rearing lhe *(+&% ackage:
> library(vegan)
2. Make a IognormaI RAD modeI for lhe @> samIe of lhe ground beelIe communily
dala:
> m1 = rad.lognormal(gb.biol["E1",])
3. Make anolher IognormaI modeI bul for lhe @F samIe:
> m2 = rad.lognormal(gb.biol["E2",])
4. Nov make a broken slick modeI for lhe @G samIe:
> m3 = rad.null(gb.biol["E3",])
5. Slarl lhe Iol by Iooking al lhe #> modeI you made in sle 2:
> plot(m1, pch = 1, lty = 1, col = 1)
6. Add oinls from lhe #F modeI (sle 3) and lhen add a Iine for lhe RAD modeI fil.
Use differenl coIour, Iolling symboIs and Iine lye from lhe Iol in sle 5:
> points(m2, pch = 2, col = 2)
> lines(m2, lty = 2, col = 2)
7. Nov add oinls and Iines for lhe m3 modeI (sle 4) and use differenl coIours and
so on:
> points(m3, pch = 3, col = 3)
> lines(m3, lty = 3, col = 3)
8. IinaIIy add a Iegend, make sure lhal you malch u lhe coIours, Iine lyes and Iol-
ling characlers. Your finaI grah shouId resembIe Iigure 11.7:
> legend(x = "topright",
legend = c("Lognormal E1", "Lognormal E2", "Broken Stick E3"),
pch = 1:3, lty = 1:3, col = 1:3, bty = "n")
11. Rank abundance or dominance models
|
355
Identifying species on plots
Your basic dominance/diversily Iol shovs lhe Iog of lhe secies abundances againsl lhe
rank of lhal abundance. You see lhe oinls reIaling lo each secies bul il mighl be heIfuI
lo be abIe lo see vhich oinl reIales lo vhich secies. The plot() commands lhal roduce
singIe-vindov Iols (i.e. nol ones lhal use lhe .&11$'( ackage) of RAD modeIs aIIov you
lo idenlify lhe oinls, so you can see vhich secies are vhich. The identify() command
aIIovs you lo use lhe mouse lo essenliaIIy add IabeIs lo a Iol. The Iol needs lo be of a se-
cific cIass, "ordiplot", vhich is roduced vhen you make a Iol of an RAD modeI. This
cIass of Iol is aIso roduced vhen you Iol lhe resuIls of ordinalion (see Chaler 14).
In lhe foIIoving exercise you can have a go al making a Iol of an RAD modeI and cus-
lomising il by idenlifying lhe oinls vilh lhe secies names.
! !" !"
!
!
!
!
"
!
"
!
"
!
"
"
!
"
"
!"#$
!
"
#
$
%
&
$
'
(
Lognormal E1
Lognormal E2
Broken Stick E3
Figure 11.7 Dominance/diversity for different RAD models and samples of ground beetles.
The grah you made is erhas nol a very sensibIe one bul il does iIIuslrale hov you
can buiId a cuslomised Iol of your RAD modeIs.
Have a Go: Identify the species from points
of a dominance/diversity plot
Ior lhis exercise you viII need lhe ground beelIe dala in lhe ?@A@BAC&1& fiIe. You viII
aIso need lhe *(+&% ackage.
1. Slarl by rearing lhe *(+&% ackage:
> library(vegan)
2. Make a Zif modeI of lhe @> samIe:
> gb.zipf = rad.zipf(gb.biol["E1",])
356
|
Community Ecology: Analytical Methods using R and Excel
3. Nov make a Iol of lhe RAD modeI bul assign lhe resuIl lo a named ob|ecl:
> op = plot(gb.zipf)
4. The Iol shovs basic oinls and a Iine for lhe filled modeI. You viII redrav lhe Iol
and cuslomise il shorlIy bul firsl Iook al lhe "0 ob|ecl you |usl crealed:
> op
$species
rnk poi
Aba.par 1 388
Pte.mad 2 210
Neb.bre 3 59
Pte.str 4 21
Cal.rot 5 13
Pte.mel 6 4
Pte.nige 7 3
Ocy.har 8 3
Car.vio 9 3
Poe.cup 10 2
Pla.ass 11 2
Bem.man 12 2
Sto.pum 13 1
Pte.obl 14 1
Pte.nigr 15 1
Lei.ful 16 1
Bem.lam 17 1
attr(,"class")
[1] "ordiplot"
5. The "0 ob|ecl conlains aII lhe dala you need for a Iol. The identify() command
viII use lhe rov names as lhe defauIl IabeIs bul firsl, redrav lhe Iol and disIay
lhe oinls onIy (lhe defauIl is type = "b"). AIso, suress lhe axes and make a
IillIe more room lo fil lhe IabeIs inlo lhe Iol region:
> op = plot(gb.zipf, type = "p", pch = 43, xlim = c(0, 20), axes = FALSE)
6. You may gel a varning message bul lhe Iol is crealed anyhov. The type = "p"
arl lurned off lhe Iine lo Ieave lhe oinls onIy (type = "l" vouId shov lhe Iine
onIy). Nov add in lhe H-axis and sel lhe axis lick osilions exIicilIy:
> axis(2, las = 1, at = c(1,2,5,10,20, 50, 100, 200, 400))
7. Nov add in lhe <-axis bul shifl ils osilion in lhe margin so il is one Iine oulvards.
You can aIso secify lhe axis lick osilions using lhe pretty() command, vhich
vorks oul neal inlervaIs:
> axis(1, line = 1, at = pretty(0:20))
8. IinaIIy you gel lo IabeI lhe oinls. Slarl by lying lhe command:
> identify(op, cex = 0.9)
9. Nov lhe command viII be vailing for you lo cIick vilh lhe mouse in lhe Iol region.
SeIecl lhe Iol vindov by cIicking in an ouler margin or lhe header bar lhis 'acli-
vales' lhe Iol. Iosilion your mouse cursor |usl beIov lhe lo-mosl oinl and cIick
once. The IabeI aears |usl beIov lhe oinl. Nov move lo lhe nexl oinl and cIick
|usl lo lhe righl of il lhe IabeI aears lo lhe righl. The osilion of lhe IabeI reIalive
11. Rank abundance or dominance models
|
357
Tip: Labels and the identify() command
y defauIl lhe identify() command lakes ils IabeIs from lhe dala you are idenlifying,
usuaIIy lhe rov names. You can secify olher IabeIs using lhe labels inslruclion. You can
aIso aIler lhe IabeI aearance using basic grahicaI aramelers, e.g. cex (characler exan-
sion/size) and col (coIour).
The as.rad() command aIIovs you lo reassembIe your dala inlo a form suilabIe for Iol-
ling in a DD Iol. The command lakes communily abundance dala and reorders lhe se-
cies in rank order, vilh lhe mosl abundanl being firsl. The resuIl hoIds a cIass, "rad", lhal
can be used in a plot() command:
> as.rad(gb.biol[1,])
Aba.par Pte.mad Neb.bre Pte.str Cal.rot Pte.mel Pte.nige
388 210 59 21 13 4 3
Ocy.har ar.vio Poe.cup Pla.ass Bem.man Sto.pum Pte.obl
3 3 2 2 2 1 1
lo lhe oinl viII deend on lhe osilion of lhe mouse. In lhis vay you can osilion
lhe IabeIs so lhey do nol overIa. CIick on lhe olher oinls lo IabeI lhem. Your finaI
grah shouId resembIe Iigure 11.8.
!"#$
!
"
#
$
%
&
$
'
(
!
!
!
!
!
!
! ! !
! ! !
! ! ! ! ! !
!
!
!"
!"
!"
!""
!""
!""
! ! !" !" !"
!"#$%#&
!"#$%&'
!"#$#%"
!"#$%"&
!"#$%&'
!"#$%#&
!"#$%&'#
!"#$%&'
!"#$%&'
!"#$%&'
!"#$#%%
!"#$#%&
!"#$%&'
!"#$%&'
!"#$%&'(
!"#$%&'
!"#$%&#
Figure 11.8 Dominance/diversity plot for a sample of ground beetles.
If you onIy vish lo IabeI some oinls lhen you can slo idenlificalion al any lime by
ressing lhe Isc key.
358
|
Community Ecology: Analytical Methods using R and Excel
Pte.nigr Lei.ful Bem.lam
1 1 1
attr(,"class")
[1] "rad"
The resuIling plot() vouId conlain onIy lhe oinls, Iolled as lhe Iog of lhe abundance
againsl lhe rank.
One of lhe RAD modeIs you've seen is lhe IognormaI modeI. This vas one of lhe firsl
RAD modeIs lo be deveIoed and in lhe foIIoving seclions you viII Iearn more aboul
IognormaI dala series.
11.2 Fishers log-series
The IognormaI modeI you've seen so far slems from lhe originaI vork of Iisher you mel
lhis earIier (in Seclion 8.3.2) in lhe conlexl of an index of diversily. The *(+&% ackage uses
non-Iinear modeIIing lo caIcuIale Iisher's Iog-series (Iook back al Iigures 8.6 and 8.7).
The fisherfit() command in lhe *(+&% ackage carries oul lhe main modeI filling
rocesses. You Iooked al lhis in Seclion 8.3.2 bul in lhe foIIoving exercise you can have a
go al making Iisher's Iog-series and exIoring lhe resuIls vilh a differenl emhasis.
Have a Go: Explore Fishers log-series
You viII need lhe *(+&% and 6I;; ackages for lhis exercise. The 6I;; ackage comes
as arl of lhe basic dislribulion of R bul is nol Ioaded by defauIl. You viII aIso use lhe
ground beelIe dala in lhe ?@A@BAC&1& fiIe.
1. Slarl by rearing lhe *(+&% and 6I;; ackages:
> library(vegan)
> library(MASS)
2. Make a Iog-series resuIl for aII samIes in lhe ground beelIe communily dalasel:
> gb.fls <- apply(gb.biol, MARGIN = 1,fisherfit)
3. You made Iisher's Iog-series modeIs for aII samIes see lhe names of lhe como-
nenls of lhe resuIl:
> names(gb.fls)
[1] "E1" "E2" "E3" "E4" "E5" "E6" "G1" "G2" "G3" "G4" "G5" "G6"
[13] "W1" "W2" "W3" "W4" "W5" "W6"
4. Look al lhe resuIl for lhe E> samIe:
> gb.fls$G1
Fisher log series model
No. of species: 28
Estimate Std. Error
alpha 7.0633 1.5389
5. Look al lhe comonenls of lhe resuIl for lhe G1 samIe:
11. Rank abundance or dominance models
|
359
> names(gb.fls$G1)
[1] "minimum" "estimate" "gradient" "hessian"
[5] "code" "iterations" "df.residual" "nuisance"
[9] "fisher"
6. Look al lhe $fisher comonenl:
> gb.fls$G1$fisher
1 2 3 4 5 6 17 23 25 52 178
12 3 3 1 2 1 1 2 1 1 1
attr(,"class")
[1] "fisher"
7. You can gel lhe frequency and number of secies comonenls using lhe
as.fisher() command:
> as.fisher(gb.biol["G1",])
1 2 3 4 5 6 17 23 25 52 178
12 3 3 1 2 1 1 2 1 1 1
attr(,"class")
[1] "fisher"
8. VisuaIise lhe Iog-series vilh a Iol and aIso Iook al lhe rofiIe lo ascerlain lhe nor-
maIily, sIil lhe Iol vindov in lvo and roduce a Iol lhal resembIes Iigure 11.9:
> opt = par(mfrow = c(2,1))
> plot(gb.fls$G1)
> plot(profile(gb.fls$G1))
> par(opt)
! !" !"" !"#
!
!
!
!
!
!
"
!"#$%#&'(
!
"
#
$
%
#
&
! ! ! !" !"
!
"
!
"
!
"
!
!
!
!
!"#$!
!
"
#
Figure 11.9 Fishers log-series (top) and profile plot (bottom) for a sample of ground beetles.
360
|
Community Ecology: Analytical Methods using R and Excel
Iisher's Iog-series can onIy be used for counls of individuaIs and nol for olher forms of abun-
dance dala. You musl have inleger vaIues for lhe fisherfit() command lo oerale.
Tip: Convert abundance data to log-series data
The as.fisher() command in lhe *(+&% ackage aIIovs you lo 'converl' abundance dala
inlo Iisher's Iog-series dala.
Iisher's modeI seems lo imIy infinile secies richness and so 'imrovemenls' have been made
lo lhe modeI. In lhe foIIoving seclion you'II see hov Ireslon's IognormaI modeI can be used.
11.3 Prestons lognormal model
Ireslon's IognormaI modeI (Ireslon 1948) is a sublIe varialion on Iisher's Iog-series. The
frequency cIasses of lhe <-axis are coIIased and merged inlo vider bands, crealing oclaves
of doubIing size, 1, 2, 34, 58, 916 and so on. Iurlhermore, for each frequency haIf lhe
secies are lransferred lo lhe nexl highesl oclave. This makes lhe dala aear more Iognor-
maI by reducing lhe Iovesl oclaves (vhich are usuaIIy high).
In lhe *(+&% ackage lhe prestonfit() command carries oul lhe modeI filling rocess.
y defauIl lhe frequencies are sIil, vilh haIf lhe secies being lransferred lo lhe nexl highesl
oclave. Hovever, you can lurn lhis fealure off by using lhe tiesplit = FALSE inslruclion.
The execled frequency 9 al an abundance oclave " is delermined by lhe formuIa shovn
in Iigure 11.10.
9. Use lhe confint() command lo gel lhe confidence inlervaIs of aII lhe Iog-series
you can use lhe sapply() command lo heI:
> sapply(gb.ff, confint)
E1 E2 E3 E4 E5 E6
2.5 % 1.778765 1.315205 1.501288 3.030514 2.287627 1.695922
97.5 % 5.118265 4.196685 4.626269 7.266617 5.902574 4.852549
G1 G2 G3 G4 G5 G6
2.5 % 4.510002 3.333892 2.687344 4.628881 4.042329 3.658648
97.5 % 10.618303 8.765033 7.892262 10.937909 9.806917 9.205348
W1 W2 W3 W4 W5 W6
2.5 % 0.9622919 0.8672381 0.8876847 1.029564 0.9991796 0.7614008
97.5 % 3.3316033 3.1847201 3.2699293 3.595222 3.4755296 2.9843201
The plot() command roduces a kind of bar charl vhen used vilh lhe resuIl of a
fisherfit() command. You can aIler various eIemenls of lhe Iol such as lhe axis
IabeIs. Try aIso lhe bar.col and line.col inslruclions, vhich aIler lhe coIours of lhe
bars and filled Iine.
! "! "#$
%&'
(
#



(

(
(
Figure 11.10 Prestons lognormal model. Expected frequency for octaves (o), where is
the location of the mode, is the mode width (both in log2 scale) and S0 is
expected number of species at mode.
11. Rank abundance or dominance models
|
361
The IognormaI modeI is usuaIIy lruncaled al lhe Iovesl end, vilh lhe resuIl lhal some rare
secies may nol be recorded lhis lruncalion is caIIed lhe *($. .$%(.
The prestonfit() command fils lhe lruncaled IognormaI modeI as a second degree
Iog-oIynomiaI lo lhe oclave ooIed dala using Ioisson (vhen tiesplit = FALSE) or
quasi-Ioisson (vhen tiesplit = TRUE) error dislribulion.
The prestondistr() command uses an aIlernalive melhod: filling a Iefl-lruncaled
normaI dislribulion lo Iog2 lransformed non-ooIed observalions vilh direcl maximisa-
lion of Iog-IikeIihood.
olh commands have Iolling roulines, vhich roduce a bar charl and filled Iine. You
can aIso add exlra Iines lo lhe Iols. In lhe foIIoving exercise you can have a go al exIor-
ing Ireslon's Iog-series.
Have a Go: Explore Prestons lognormal models
You viII need lhe *(+&% ackage for lhis exercise. You viII aIso use lhe ground beelIe
dala in lhe ?@A@BAC&1& fiIe.
1. Slarl by rearing lhe *(+&% ackage:
> library(vegan)
2. Make a Ireslon IognormaI modeI using lhe combined dala from lhe ground beelIe
samIes:
> gb.oct = prestonfit(colSums(gb.biol))
> gb.oct
Preston lognormal model
Method: Quasi-Poisson fit to octaves
No. of species: 48
mode width S0
3.037810 4.391709 5.847843
Frequencies by Octave
0 1 2 3 4 5
Observed 2.000000 4.500000 10.000000 9.500000 2.000000 6.000000
Fitted 4.603598 5.251002 5.686821 5.847627 5.709162 5.292339
6 7 8 10 11 12
Observed 4.000000 2.000000 4.000000 1.000000 1.000000 1.000000
Fitted 4.658067 3.892659 3.088657 1.664425 1.130409 0.728936
13
Observed 1.0000000
Fitted 0.4462991
3. Ior comarison use lhe prestondistr() command lo make an aIlernalive modeI:
> gb.ll = prestondistr(colSums(gb.biol))
> gb.ll
Preston lognormal model
Method: maximized likelihood to log2 abundances
No. of species: 48
mode width S0
2.534594 3.969009 5.931404
362
|
Community Ecology: Analytical Methods using R and Excel
Frequencies by Octave
0 1 2 3 4 5
Observed 2.000000 4.500000 10.000000 9.500000 2.000000 6.000000
Fitted 4.837308 5.504215 5.877843 5.890765 5.540596 4.890714
6 7 8 10 11 12
Observed 4.000000 2.000000 4.000000 1.000000 1.0000000 1.000000
Fitted 4.051531 3.149902 2.298297 1.011387 0.6099853 0.345265
13
Observed 1.0000000
Fitted 0.1834074
4. olh versions of lhe modeI have lhe same comonenls. Look al lhese using lhe
names() command:
> names(gb.oct)
[1] "freq" "fitted" "coefficients" "method"
> names(gb.ll)
[1] "freq" "fitted" "coefficients" "method"
5. Viev lhe Quasi-Ioisson modeI in a Iol use lhe yaxs = "i" inslruclion lo 'ground'
lhe bars:
> plot(gb.oct, bar.col = "gray90", yaxs = "i")
6. The Iol shovs a hislogram of lhe frequencies of lhe secies in lhe differenl oclaves.
The Iine shovs lhe filled dislribulion. The verlicaI Iine shovs lhe mode and lhe
horizonlaI Iine lhe slandard devialion of lhe resonse. Add lhe delaiIs for lhe aIler-
nalive modeI using lhe lines() command:
> lines(gb.ll, line.col = "blue", lty = 2)
7. Nov examine lhe densily dislribulion of lhe hislogram and add lhe densily Iine lo
lhe Iol, your finaI grah shouId resembIe Iigure 11.11:
> den = density(log2(colSums(gb.biol)))
> lines(den$x, ncol(gb.biol)*den$y, lwd = 2, col = "darkgreen", lty = 3)
!"#$%#&'(
!
"
#
$
%
#
&
!
!
!
!
!
!
"
! ! ! ! !" !" !" !"# !"# !"# !"#$ !"#$ !"#$ !"#$
Figure 11.11 Prestons log-series for ground beetle communities. Solid line = quasi-
Poisson model, dashed line = log likelihood model, dotted line = density.
11. Rank abundance or dominance models
|
363
Tip: Axis extensions
y defauIl R usuaIIy adds a bil of exlra sace lo lhe ends of lhe < and H axes (aboul 4% is
added lo lhe ends). This is conlroIIed by lhe xaxs and yaxs grahicaI aramelers. The
defauIl is xaxs = "r" and lhe same for yaxs. You can 'shrink' lhe axes by selling lhe vaIue
lo "i". for lhe axis you require.
You can converl secies counl dala lo Ireslon oclave dala by using lhe as.preston()
command:
> as.preston(colSums(gb.biol))
0 1 2 3 4 5 6 7 8 10 11 12 13
2.0 4.5 10.0 9.5 2.0 6.0 4.0 2.0 4.0 1.0 1.0 1.0 1.0
attr(,"class")
[1] "preston"
This makes a resuIl ob|ecl lhal has a seciaI cIass, "preston", vhich currenlIy does nol
have any secific commands associaled vilh il. Hovever, you couId olenliaIIy use such
a resuIl lo make your ovn cuslom funclions.
8. You can see lhal neilher modeI is a reaIIy greal fil! Have a Iook al lhe olenliaI
number of 'unseen' secies:
> veiledspec(gb.oct)
Extrapolated Observed Veiled
64.37529 48.00000 16.37529
> veiledspec(gb.ll)
Extrapolated Observed Veiled
59.01053 48.00000 11.01053
9. The Ireslon modeI is lruncaled (usuaIIy al bolh ends) and so olher eslimales of
'unseen' secies may be referabIe, lry lhe specpool() command:
> specpool(gb.biol)
Species chao chao.se jack1 jack1.se jack2 boot
All 48 53.33333 4.929127 55.55556 3.832931 57.64706 51.81422
boot.se n
All 3.021546 18
If you vanl a samIe-by-samIe eslimale of unseen secies lhen lry lhe estimateR()
command vraed in apply() e.g. apply(gb.biol, 1, estimateR). Look back lo
Seclion 7.3.4 for more delaiIs.
11.4 Summary
Topic Key Points
RAD or
dominance-
diversity models
Rank-abundance dominance models arrange species in order of abundance.
and show log(abundance) against the rank of abundance. The flatter the curve
the more diverse the community is. Various models have been proposed to help
explain the observed patterns of dominance plots.
The radfit() command in the vegan package calculates a range of RAD models.
364
|
Community Ecology: Analytical Methods using R and Excel
Broken stick
model
Broken stick: This gives a null model where the individuals are randomly
distributed among observed species, and there are no fitted parameters. The
model is seen as an ecological resource-partitioning model.
The rad.null() command calculates broken stick models.
Preemption
model
The preemption model (also called Motomura model or geometric series) has a
single fitted parameter. The model tends to produce a straight line. The model is
seen as an evolutionary resource-partitioning model.
The rad.preempt() command calculates preemption models.
Lognormal
model
The lognormal model has two fitted parameters. It assumes that the log of
species abundance is normally distributed. The model implies that resources
affect species simultaneously.
The rad.lognormal() command calculates lognormal models.
Zipf model In the Zipf model there are two fitted parameters. The model implies that
resources affect species in a sequential manner.
The rad.zipf() command calculates Zipf models.
Mandelbrot
model
The Mandelbrot model adds one parameter to the Zipf model. The model implies
that resources affect species in a sequential manner.
The rad.zipfbrot() command calculates Mandelbrot models.
Comparing
models
The result of the radfit() command contains information about deviance
and AIC values for the models, allowing you to select the best. The AIC values
and best model are also displayed when you plot the result of radfit() that
contains multiple samples.
If you have replicate samples you can compare deviance between models using
ANOVA.
Visualise RAD
models with DD
plots
Once you have your RAD model(s), which can be calculated with the radfit()
command, you can visualise them graphically. The result of radfit() has
plot() routines, the lattice package is used to display some models, for example
the lattice system will display the best model for each sample if radfit() is
used on a dataset with multiple samples.
Plotting a radfit() result for a single sample produces a single plot with the
model fits overlaid for comparison. The radlattice() command will display
the models in separate panels (using the lattice package) for a single sample.
Fishers
log-series
Fishers log-series was an early attempt to model species abundances. One of the
model parameters (alpha) can be used as an index of diversity, calculated via the
fisher.alpha() command in the vegan package.
The fisherfit() command will compute Fishers log-series (using non-linear
modelling).
Use the confint() command in the MASS package to calculate confidence
intervals for Fishers log-series.
The as.fisher() command in the vegan package allows you to convert
abundance data into Fishers log-series data.
11. Rank abundance or dominance models
|
365
11.5 Exercises
11.1 Rank abundance-dominance modeIs derive from bioIogicaI or slalislicaI lheo-
ries. The (bioIogicaI) resource-arlilioning modeIs can be lhoughl of as oeraling
in lvo broad vays vhal are lhey`
11.2 The MandeIbrol RAD modeI is a derivalive of lhe Zif modeI, lvo addilionaI
aramelers being added TRUI or IALSI`
11.3 The C(J-$(4 dala is a malrix conlaining lvo samIes, counls of lroicaI buller-
fIy secies in canoy or underslorey habilal. Which is lhe 'besl' modeI for each
habilal`
11.4 The radfit() and rad.xxxx() commands assume lhal your dala are counl
dala. If you had cover dala inslead hov mighl you modify lhe command(s)`
11.5 Hov many unseen (i.e. veiIed) secies are caIcuIaled lo be in lhe C(J-$(4 dala`
The ansvers lo lhese exercises can be found in Aendix 1.
Prestons
lognormal
Prestons lognormal model is an improvement on Fishers log-series, which
implied infinite species richness. The frequency classes of the x-axis are collapsed
and merged into wider bands, creating octaves of doubling size, 1, 2, 34, 58,
916 and so on. Furthermore, for each frequency half the species are transferred
to the next highest octave.
The prestonfit() and prestondistr() commands in the vegan package
compute Prestons log-series. The commands have plotting routines allowing
you to visualise the models.
You can convert species count data to Preston octave data by using the
as.preston() command.
Topic Key Points

You might also like