Table Of ContentA Practical Guide to Ecological Modelling
A Practical Guide
to Ecological Modelling
Using R as a Simulation Platform
Karline Soetaert and Peter M.J. Herman
Netherlands Institute ofEcology,Yerseke,TheNetherlands
123
Dr.KarlineSoetaert Dr.PeterM.J.Herman
NetherlandsInstituteofEcology NetherlandsInstituteofEcology
CentreforEstuarine&MarineEcology CentreforEstuarine&MarineEcology
(NIOO-CEME) (NIOO-CEME)
4400ACYerseke POBox140
POBox140 4400ACYerseke
TheNetherlands TheNetherlands
[email protected] [email protected]
Additionalmaterial,theR-examplesandtheR-codeofallfigures,isavailableasanR-package(ecolMod),
whichcanbefoundontheofficialR-website(http://cran.r-project.org/).
TheR-examplefilesarealsoavailableonthewebsiteofthisbookatwww.springer.com
ISBN:978-1-4020-8623-6 e-ISBN:978-1-4020-8624-3
LibraryofCongressControlNumber:2008933286
(cid:2)c SpringerScience+BusinessMediaB.V.2009
Nopartofthisworkmaybereproduced,storedinaretrievalsystem,ortransmitted
inanyformorbyanymeans,electronic,mechanical,photocopying,microfilming,recording
orotherwise,withoutwrittenpermissionfromthePublisher,withtheexception
ofanymaterialsuppliedspecificallyforthepurposeofbeingentered
andexecutedonacomputersystem,forexclusiveusebythepurchaserofthework.
Coverillustration:ViewattheOosterscheldefromtheNetherlandsInstituteofEcology,Yerseke,
TheNetherlands.PhotographtakenbyThomasHaverkamp.
Printedonacid-freepaper
9 8 7 6 5 4 3 2 1
springer.com
Preface
WhyAnotherEcologicalModellingBook?
For several years we have taught courses on ecological modelling at the level of
graduates or starting PhD students. The audience typically consists of students
frombiology,geology,bio-engineering,and,lessfrequently,fromsciencessuchas
physicsandchemistry.Formostofthesestudentsourcoursewasafirstacquaintance
withthefieldofecologicalmathematicalmodelling.Althoughoftendifficult,itwas
an intellectual adventure both for them and for us. The course was set up as an
initiationtothesubject,startingfromthemostbasicofprinciplesbutnevertheless
leadingtoquiteadvancedapplications.
Thisbookisbasedonlecturenotesthatwerewrittenin2001andthataccompany
this modelling course. We prepared the original notes because we felt there was
shortageofabookcoveringallthematerialthatwewantedtoaddressinourlectures.
Thenotesalsoservedasareadabletextthatthestudentscanconsultwhilepreparing
for the exam. This allowed us to teach the theory in rather short lessons, leaving
moretimetocoverthepracticalexercises,duringwhichwedirectlyinteractedwith
thestudentsindividually.
This book is written for young researchers who want to get more out of their
datathanjustdescription.Evenwhentheyseethepossibilitiesofmodellingtohelp
them gaining insight in the processes they study, two factors might frighten them
awayfromthispath.Oneismathematicalformalism,theoremsanddetailedproofs,
the bread and butter of the applied mathematician. The other is complicated, se-
manticandnear-philosophicalecologicaltheory.Wehavesteeredawayfromthese
twoextremes.Wehavetriedtowriteabookthatisreadableforanaudiencewitha
basicformationinecologyandabasicknowledgeofmathematics.Althoughenough
materialispresentedthatmayalsointerestthemoreexperiencedecologicmodeller,
it is not a book only readable for either full-blown mathematicians or ecological
theoreticians.
Throughout the book we have tried to be practical, emphasizing the diversity
that exists in mathematical models and techniques. We discuss only the essential
aspectsofmathematicalmethods,withoutpretensiontomathematicalrigour:often
one does not need to understand the fine details of a technique to correctly apply
v
vi Preface
it,butithelpsgreatlytohaveanintuitiveunderstandingofitsfoundations.Thisis
whereouremphasishasbeenplaced.
Despite our preference for practical and simple approaches, fact is that the
basic methods of solution are often adequate only for the most simple of mod-
els. As application of more efficient and complex mathematics may considerably
speed up solution, and thus avoid frustration, we do not neglect to mention some
more advanced techniques that can make the life of a modeller so much more
pleasant.
Ecologicalmodellinghasmultipleroots.Manytheoreticalecologicalmodelsgo
backinsomewaytothepioneeringworkofLotkaandVolterra.Anewapproach,
aimingatenvironmentalmodelling,wasbasedonengineeringprinciplesfromabout
the 1960’s onwards. We have taken this approach as a starting point for the book,
becauseitismuchmoredirectlybasedonconservationlawsandthereforeaneas-
ier vehicle to explain principles underlying modelling. However, we have tried to
bridge,fromthere,tothemoreclassicalecologicalapproachinlatersectionsofthe
book.
ScopeandContent
Abriefmentionofthebook’scontentsrevealsitsscope.
We start by giving arguments as to why models are useful, from the scien-
tific point of view as well as with respect to management. This sets the scene
and explains why we are doing what we are doing. Here we introduce some
model applications, both simple and complex, that will be expanded on further in
thebook.
Afterhavingintroducedthesemanticsofmodels,wethenproceedwiththebasic
principlesoftransferringecologyintoequations.Thisiswhereourbookdiffersmost
fromotherbooks,whichgenerallyassumethatsuchknowledgeisalreadyavailable,
or can be deduced from the rather complex examples that these books generally
contain.Duringourlectureswebecameawarethatthementalswitchfromdescrip-
tivetoprocess-basedthinkingisthelargestleapformostofourstudents,itisNOT
themaths.Thereforewespendmuchefforttoexplainanddetailtheformulationof
ecologicalinteractions.
Next we deal with how space can be incorporated into the mass equations. We
concentrateonone-dimensionalproblemswithvariousgeometries,withashortex-
cursiontothreedimensions.
We then continue with the mathematical solution of the models, mentioning
where applicable possible sources of difficulty and error. This section deals with
differentialandnumericalcalculus,thebasicmathematicalconceptsareintroduced
as they are needed, and compiled in an appendix. This is definitely the most de-
mandingpartofthebook,butnecessarytoputtheoryintopractice.
Inanextchapter,thederivationofthesteady-statesolutionandsubsequentanal-
ysis of its properties introduces concepts such as stability, domains of attraction,
multiplestablestatesandbifurcation.
Preface vii
Thus far, the models that were discussed fall into the category of deterministic
differentialequations.Intheremainingpartofthebook,someothertypesofmodelsare
dealtwith.Theyincludedifference(discretetime)equations,dynamicmatrixmodels,
andsequentialdecisionmodels,alsoknownasdynamicprogrammingmodels.
Asitisessentialformakingrobustmodellingapplications,wegenerallyspenda
lotoftimeduringourpracticalcoursesondesigning,testing,validatingandimprov-
ingecologicalequations.Thisisthetopicofthefinalbookchapter,whichdiscusses
varioustechniquesforanalysingmodelbehaviour.
Each chapter is organised as follows: an introduction sets the scene of what is
to follow, and, if relevant, puts the chapter in perspective with respect to previous
chapters. The first sections give the basics and theory, if appropriate illustrated by
(simple) examples. Certain sections (starred) probe beyond the elementary level,
andmaybeskippedatfirstreading.Wealsofinditimportanttoactuallyshowhow
toimplementmodels,suchthatthereadermayacquirehands-onexperience.Thus,
each chapter includes case studies that illustrate (nearly) all methods discussed in
themaintext,andputthetheoryintopractice.Wherepossible,wechosepublished
modelsthataresimpleenoughandwereamongstthefirstintheirkind,toillustrate
concepts.Thecodetoruntheseexamples,implementedintheRcomputerlanguage,
isincludedanddiscussedinthebookandcanbefoundontheaccompanyingwebsite
orontheofficialR-website(seebelow).
R,theModellingPlatformUsedinthisBook
Forthosewhoarebeinginitiatedinthefield,thelearningofanew(programming)
language,ontopofthenewsetsofprinciplesthatsurroundmathematicalmodelling
maybeverydemanding.Therefore,duringourpracticalcourses,theproblemshave
been kept simple, such that the students can implement them in a spreadsheet, a
software package that most of them know or should know. These exercises, and
theirsolutions,canbefoundontheaccompanyingwebsite.
Forthisbook,wehavetakenadifferentapproachandweuseRforourexamples,
mainlybecauseitisfreesoftware,itisrapidlygainingpopularity,R-codeishighly
readable,and...wesimplylikeit.
AlthoughRwasnotoriginallydevelopedtobeusedasamodellingtool,itisvery
wellsuitedforthistask.Inourday-to-daywork,weuseRmainlytodevelopsimple
modelsortovisualisemodeloutput.WealsouseRtointerfacewithcompiledmod-
elswritteninFortran.Risthenusedforpost-processingthemodeloutput(making
graphs,creatingsummaries,performingtests...).
As the use of the R-language is growing rapidly, students are now becoming
acquaintedwithRduringtheirstatisticalcourses.Weexpect(orhope)thatitisonly
a matter of time before the use of spreadsheets in introductory modelling courses
canbeavoided.
Inanappendix,wegivea-veryshort-introductiontoR.Amoreextensiveintro-
ductioncanbefoundonthebook’swebsite.
viii Preface
TheBooksWebsite
Thebookcomeswithsomeadditionalmaterial,whichcanbedownloadedfromthe
book’swebsiteonwww.springer.com.
The files that contain the example codes are in a subdirectory named after the
chapter.Asthecodeisgenerallysmall,wehaveprintedalmostallofitinthebook.
Wemakeliberaluseofdiagramsandfiguresinourbook.Thishasapurpose:di-
agramsvisualiseconceptsandrelationships,whilefiguresareacriticallyimportant
toolforanalyzingmodeloutput.Rhasbeenusedformakingthesediagramsandfig-
ures.ThesourcecodeofallbookfigureshasbeenbundledinanofficialR-package
(ecolMod–SoetaertandHerman,2008)andputontheR-website(CRAN).Itcan
simplybeinstalledasaregularR-package,afterwhichthefiguresofeachchapter
canbegeneratedbyrunningademo,namedafterthechapter.
Acknowledgements
Manypeoplehaveprovidedvaluableinput/feedbackorreviewedpartsofthisbook.
WewouldliketothankespeciallyourcolleaguesJackMiddelburg,whocommented
ontheoverallconceptandonmostchaptersbutalsostimulatedustostartwriting
this book, Filip Meysman, Johan van de Koppel, Matthijs Vos, Dick van Oevelen,
Andreas Hofmann, Wolf Mooij and Marcel Klaassen. Whereas all these persons
providedgreathelp,ofcourseallremainingerrorsareourownresponsibility.Also
thanks to our post-docs (Marilaure Gre´goire, Sophie Rabouille, Caroline Ulses,
Jim Greenwood), our (former) PhD students (Dick van Oevelen, Jeroen Wijsman,
Filip Meysman, Henrik Andersson, Karel Van den Meersche, Andreas Hofmann,
Pieter Provoost, Tom van Engeland, Julius Kones, Paul Obade, Tom Cox) and all
MARELACandECOMAMAstudents,forchallengingustoexplainthemodelling
processfromthemostbasicuptothehighestlevel.
TheRoyalDutchAcademyofScience(KNAW)supportsourresearch,inwhich
we make frequent use of mathematical models. The University of Ghent, the Free
UniversityofBrussels,andtheUniversityofNijmegenallowedustoteachecolog-
icalmodellingtoundergraduateandgraduatestudents.Weexpressourgratitudeto
theNetherlandsInstituteofEcology,CentreforEstuarineandMarineEcology,our
baseinstitutionforprovidinguswiththeopportunitytofinalisethisbook.Finally,
wededicatethebooktothosethatareneartous:ourspouses,CarloHeip(KS)and
Rosette Mortier (PH), and our children, Maarten and Eva (KS), Eva, Gerard and
Judith(PH).
Yerseke,TheNetherlands K.Soetaert
Yerseke,TheNetherlands P.M.J.Herman
Contents
1 Introduction................................................... 1
1.1 WhatisaModel?........................................... 1
1.1.1 ASimpleExample:ZooplanktonEnergyBalance ......... 3
1.2 WhyDoWeNeedModels? .................................. 5
1.2.1 ModelsasAnalysingTools ............................ 5
1.2.2 ModelsasInterpolation,Extrapolation,andBudgetingTools 7
1.2.3 ModelstoQuantifyImmeasurableProcesses ............. 9
1.2.4 ModelPredictionasaManagementTool................. 10
1.3 ModellingStepsandIngredients .............................. 10
1.4 TheModeller’sToolkit ...................................... 13
2 ModelFormulation............................................. 15
2.1 ConceptualModel .......................................... 15
2.1.1 TheBalanceEquationofaStateVariable ................ 17
2.1.2 Example:ConceptualModelofaLakeEcosystem......... 19
2.1.3 ConservationofMassandEnergyasaConsistencyCheck.. 21
2.1.4 DimensionalHomogeneityandConsistencyofUnits....... 23
2.2 MathematicalFormulations .................................. 24
2.3 FormulationofChemicalReactions ........................... 25
2.3.1 TheLawofMassAction .............................. 25
2.3.2 Example:ASimpleChemicalReaction.................. 26
2.4 EnzymaticReactions........................................ 27
2.5 BasicFormulationofEcologicalInteractions.................... 28
2.5.1 Example: Flows to and from Phytoplankton
intheLakeEcosystem ............................... 28
2.5.2 MaximalInteractionStrength,RateLimitation
andInhibition....................................... 31
2.5.3 One Rate-Limiting Resource, 3 Types
ofFunctionalResponses.............................. 35
2.5.4 MorethanOneLimitingResource ...................... 37
2.5.5 InhibitionTerms ..................................... 38
2.6 CoupledModelEquations ................................... 40
2.6.1 FlowsModelledasFractionsofOtherFlows ............. 41
ix
x Contents
2.6.2 CoupledDynamicsofSourceandSinkCompartments ..... 42
2.6.3 StoichiometryandCouplingofElementCycles ........... 43
2.7 ModelSimplifications....................................... 44
2.7.1 CarryingCapacityFormulation......................... 45
2.7.2 ClosureTermsattheHighestTrophicLevel .............. 48
2.7.3 SimplificationbyDeletionofIntermediateLevels ......... 48
2.8 ImpactofPhysicalConditions ................................ 49
2.8.1 Temperature ........................................ 49
2.8.2 Light............................................... 50
2.8.3 OtherPhysicalImpacts ............................... 53
2.9 Examples ................................................. 54
2.9.1 NPZD,aSimpleEcosystemModelforAquaticEnvironments 54
2.9.2 AQUAPHY, a Physiological Model of Unbalanced
AlgalGrowth(**)................................... 58
2.10 CaseStudiesinR........................................... 63
2.10.1 MakingSenseOutofMathematicalFormulations ......... 63
2.10.2 OneFormula,SeveralParameterValues ................. 64
2.11 Projects................................................... 65
2.11.1 ConceptualModel:LakeEutrophication ................. 65
2.11.2 ModelFormulation:Nutrient-LimitedBatchCulture....... 66
2.11.3 ModelFormulation:DetritusDegradation................ 67
2.11.4 ModelFormulation:AnAutocatalyticReaction ........... 69
3 SpatialComponentsandTransport .............................. 71
3.1 MicroscopicandMacroscopicModels ......................... 72
3.2 RepresentingSpaceinModels................................ 74
3.2.1 SpatialDimensions................................... 74
3.2.2 DiscreteSpatialModels............................... 74
3.2.3 ContinuousSpatialModels ............................ 76
3.3 TransportinaZero-DimensionalModel........................ 77
3.4 TransportinaOne-DimensionalModel ........................ 79
3.4.1 FluxDivergence ..................................... 80
3.4.2 Macroscopic Formulation of Fluxes:
AdvectionandDispersion ............................ 82
3.4.3 TheGeneral1-DAdvection-Dispersion-ReactionEquation . 84
3.4.4 The 1-D Advection-Dispersion-Reaction Equation
inEstuaries,RiversandLakes ......................... 85
3.4.5 The 1-D Advection-Dispersion-Reaction Equation
inShapeswithDifferentSymmetries ................... 86
3.4.6 One-dimensionalDiffusioninPorousMedia(Sediments)(∗∗) 89
3.4.7 The3-DAdvection-Dispersion-ReactionEquation(∗)...... 92
3.5 BoundaryConditionsinSpatiallyExplicitModels ............... 92
3.5.1 BoundaryConditionsinDiscreteModels ................ 94
3.5.2 BoundaryConditionsinContinuousModels.............. 95
3.5.3 BoundaryConditionsinMulti-layeredModels(∗∗) ........ 98
Contents xi
3.6 CaseStudiesinR...........................................102
3.6.1 AnAutocatalyticReactioninaFlow-ThroughStirredTank .102
3.6.2 A1-DMicroscopicandMacroscopicModelofDiffusion...103
3.6.3 CellularAutomatonModelofDiffusion(∗∗)..............107
3.6.4 CompetitioninaLatticeGrid ..........................110
3.6.5 TransportandReactioninPorousMedia:
SilicateDiagenesis .................................. 114
4 Parameterization...............................................117
4.1 InSituMeasurement ........................................117
4.2 Literature-DerivedParameters ................................118
4.3 Calibration ................................................119
4.3.1 LinearRegression....................................120
4.3.2 NonlinearFitting ....................................122
4.4 CaseStudiesinR...........................................123
4.4.1 NonlinearParameterEstimation:P-ICurve...............123
4.4.2 Linear Versus Non-Linear Parameter Estimation:
SedimentBioturbation ............................... 125
4.4.3 Pseudo-Random Search, a Random-Based
MinimizationRoutine................................ 128
4.4.4 CalibrationofaSimpleModel .........................132
5 ModelSolution–AnalyticalMethods.............................139
5.1 AnEverydayLifeExample ..................................139
5.2 FindinganAnalyticalSolution................................140
5.3 Examples .................................................141
5.3.1 AVerySimpleFirst-OrderDifferentialEquation ..........141
5.3.2 TheLogisticEquation ................................143
5.3.3 A Second-Order Differential Equation: Carbon
DynamicsinSediments(∗)............................ 144
5.3.4 CoupledBODandOxygenEquations(∗) ................146
5.3.5 MultilayerDifferentialEquations(∗∗) ...................147
5.4 CaseStudiesinR...........................................150
5.4.1 TransientDispersion-ReactioninOneDimension .........150
5.4.2 TransientDiffusion-Reactionona2-DimensionalSurface ..151
5.4.3 Steady-State Oxygen Budget in Small Organisms
LivinginSuboxicConditions ......................... 152
5.4.4 Analytical Solution of the Non-Local Exchange
SedimentModel(∗∗∗) ................................ 158
5.5 Projects...................................................161
5.5.1 OrganicMatterSinkingThroughaWaterColumn.........161
5.5.2 OxygenDynamicsintheSediment......................162
5.5.3 CarbonDynamicsintheSediment ......................164