ebook img

Exploring Modeling with Data and Differential Equations Using R PDF

379 Pages·2022·8.501 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Exploring Modeling with Data and Differential Equations Using R

Exploring Modeling with Data and Differential Equations Using R Exploring Modeling with Data and Differential Equations Using R provides a unique introduction to differential equations with applications to the biological and other natural sciences. Additionally, model parameterization and simulation of stochastic differential equations are explored, providing additional tools for model analysis and evaluation. This unified framework sits “at the intersection” of different mathematical subject areas, data science, statistics, and the natural sciences. The text throughout emphasizes data science workflows using the R statistical software program and the tidy- verse constellation of packages. Only knowledge of calculus is needed; the text’s integrated framework is a stepping stone for further advanced study in mathematics or as a comprehensive introduction to modeling for quantitative natural scientists. The text will introduce you to: • modeling with systems of differential equations and developing analytical, computational, and visual solution techniques. • the R programming language, the tidyverse syntax, and developing data science workflows. • qualitative techniques to analyze a system of differential equations. • data assimilation techniques (simple linear regression, likelihood or cost functions, and Markov Chain, Monte Carlo Parameter Estimation) to parameterize models from data. • simulating and evaluating outputs for stochastic differential equation models. An associated R package provides a framework for computation and visualization of results. John Zobitz is a Professor of Mathematics and Data Science at Augsburg University in Minneapolis, Minnesota. His scholarship in environmental data science includes ecosystem models parameterized with datasets from environmental observation networks. He is a member of the Mathematical Asso- ciation of America (MAA) and previous president of the North Central Section of the MAA. He has served on the editorial board of MAA Notes. He was a recipient of the Fulbright-Saastamoinen Foun- dation Grant in Health and Environmental Sciences at the University of Eastern Finland in Kuopio, Finland. In addition, he is an affiliated member of the Ecological Forecasting Network and regularly taught at Fluxcourse, an annual summer course for measurements and modeling of ecosystem bio- geochemical fluxes. Exploring Modeling with Data and Differential Equations Using R John M. Zobitz First edition published 2023 by CRC Press 6000 Broken Sound Parkway NW, Suite 300, Boca Raton, FL 33487-2742 and by CRC Press 4 Park Square, Milton Park, Abingdon, Oxon, OX14 4RN CRC Press is an imprint of Taylor & Francis Group, LLC © 2023 John M. Zobitz Reasonable efforts have been made to publish reliable data and information, but the author and pub- lisher cannot assume responsibility for the validity of all materials or the consequences of their use. The authors and publishers have attempted to trace the copyright holders of all material reproduced in this publication and apologize to copyright holders if permission to publish in this form has not been obtained. If any copyright material has not been acknowledged please write and let us know so we may rectify in any future reprint. Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or utilized in any form by any electronic, mechanical, or other means, now known or hereafter invented, including photocopying, microfilming, and recording, or in any information stor- age or retrieval system, without written permission from the publishers. For permission to photocopy or use material electronically from this work, access www.copyright.com or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. For works that are not available on CCC please contact [email protected] Trademark notice: Product or corporate names may be trademarks or registered trademarks and are used only for identification and explanation without intent to infringe. Library of Congress Cataloging-in-Publication Data Names: Zobitz, John M., author. Title: Exploring modeling with data and differential equations using R / John M. Zobitz. Description: First edition. | Boca Raton, FL : CRC Press, 2023. | Includes bibliographical references and index. Identifiers: LCCN 2022022121 (print) | LCCN 2022022122 (ebook) | ISBN 9781032259482 (hbk) | ISBN 9781032261812 (pbk) | ISBN 9781003286974 (ebk) Subjects: LCSH: Biological models--Data processing. | Biological models--Mathematical models. | Differential equations. | R (Computer program language) Classification: LCC QH324.8 .Z63 2023 (print) | LCC QH324.8 (ebook) | DDC 570.285--dc23/eng/20220831 LC record available at https://lccn.loc.gov/2022022121 LC ebook record available at https://lccn.loc.gov/2022022122 ISBN: 978-1-032-25948-2 (hbk) ISBN: 978-1-032-26181-2 (pbk) ISBN: 978-1-003-28697-4 (ebk) DOI: 10.1201/9781003286974 Typeset in Latin Modern by KnowledgeWorks Global Ltd. Publisher’s note: This book has been prepared from camera-ready copy provided by the authors. To my parents Joan and Francis, who gave me strong roots from which to grow. To my wife Shannon, who provides me the support to keep my trunk from breaking. To my children Colin, Grant, Phoebe, who are the branches that support the emerald green leaves. Kiitos. Amor a todos. Contents List of Figures xiii Welcome xix I Models with Differential Equations 1 1 Models of Rates with Data 3 1.1 Rates of change in the world: a model is born . . . . . . . . . . 3 1.2 Modeling in context: the spread of a disease . . . . . . . . . . . 4 1.3 Model solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1.4 Which model is best? . . . . . . . . . . . . . . . . . . . . . . . 10 1.5 Start here . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 1.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2 Introduction to R 17 2.1 R and RStudio . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 2.2 First steps: getting acquainted with R . . . . . . . . . . . . . . 18 2.3 Increasing functionality with packages . . . . . . . . . . . . . . 20 2.4 Working with R: variables, data frames, and datasets . . . . . . 21 2.5 Visualization with R . . . . . . . . . . . . . . . . . . . . . . . . 24 2.6 Defining functions . . . . . . . . . . . . . . . . . . . . . . . . . 28 2.7 Concluding thoughts . . . . . . . . . . . . . . . . . . . . . . . . 30 2.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 3 Modeling with Rates of Change 35 3.1 Competing plant species and equilibrium solutions . . . . . . . 35 3.2 The Law of Mass Action . . . . . . . . . . . . . . . . . . . . . . 36 3.3 Coupled differential equations: lynx and hares . . . . . . . . . . 38 3.4 Functional responses . . . . . . . . . . . . . . . . . . . . . . . . 40 3.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 4 Euler’s Method 47 4.1 The flu and locally linear approximation . . . . . . . . . . . . . 47 4.2 A workflow for approximation . . . . . . . . . . . . . . . . . . . 49 4.3 Building an iterative method . . . . . . . . . . . . . . . . . . . 51 vii viii Contents 4.4 Euler’s method and beyond . . . . . . . . . . . . . . . . . . . . 57 4.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 5 Phase Lines and Equilibrium Solutions 65 5.1 Equilibrium solutions. . . . . . . . . . . . . . . . . . . . . . . . 65 5.2 Phase lines for differential equations . . . . . . . . . . . . . . . 67 5.3 A stability test for equilibrium solutions . . . . . . . . . . . . . 70 5.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 6 Coupled Systems of Equations 75 6.1 Flu with quarantine and equilibrium solutions . . . . . . . . . . 75 6.2 Nullclines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 6.3 Phase planes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 6.4 Generating a phase plane in R . . . . . . . . . . . . . . . . . . . 80 6.5 Slope fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 6.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 7 Exact Solutions to Differential Equations 89 7.1 Verify a solution . . . . . . . . . . . . . . . . . . . . . . . . . . 89 7.2 Separable differential equations . . . . . . . . . . . . . . . . . . 91 7.3 Integrating factors . . . . . . . . . . . . . . . . . . . . . . . . . 92 7.4 Applying the verification method to coupled equations . . . . . 95 7.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 II Parameterizing Models with Data 103 8 Linear Regression and Curve Fitting 105 8.1 What is parameter estimation? . . . . . . . . . . . . . . . . . . 105 8.2 Parameter estimation for global temperature data . . . . . . . 106 8.3 Moving beyond linear models for parameter estimation . . . . . 109 8.4 Parameter estimation with nonlinear models . . . . . . . . . . . 114 8.5 Towards model-data fusion . . . . . . . . . . . . . . . . . . . . 116 8.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 9 Probability and Likelihood Functions 121 9.1 Linear regression on a small dataset . . . . . . . . . . . . . . . 121 9.2 Continuous probability density functions . . . . . . . . . . . . . 122 9.3 Connecting probabilities to linear regression . . . . . . . . . . . 124 9.4 Visualizing likelihood surfaces . . . . . . . . . . . . . . . . . . . 126 9.5 Looking back and forward . . . . . . . . . . . . . . . . . . . . . 133 9.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 10 Cost Functions and Bayes’ Rule 137 10.1 Cost functions and model-data residuals . . . . . . . . . . . . . 137 10.2 Further extensions to the cost function . . . . . . . . . . . . . . 140 Contents ix 10.3 Conditional probabilities and Bayes’ rule . . . . . . . . . . . . . 141 10.4 Bayes’ rule in action . . . . . . . . . . . . . . . . . . . . . . . . 144 10.5 Next steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 10.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 11 Sampling Distributions and the Bootstrap Method 149 11.1 Histograms and their visualization . . . . . . . . . . . . . . . . 150 11.2 Statistical theory: sampling distributions . . . . . . . . . . . . . 152 11.3 Summary and next steps . . . . . . . . . . . . . . . . . . . . . . 156 11.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 12 The Metropolis-Hastings Algorithm 159 12.1 Estimating the growth of a dog . . . . . . . . . . . . . . . . . . 159 12.2 Likelihood ratios for parameter estimation . . . . . . . . . . . . 161 12.3 The Metropolis-Hastings algorithm for parameter estimation . 165 12.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 13 Markov Chain Monte Carlo Parameter Estimation 169 13.1 The recipe for MCMC . . . . . . . . . . . . . . . . . . . . . . . 169 13.2 MCMC parameter estimation with an empirical model . . . . . 170 13.3 MCMC parameter estimation with a differential equation model174 13.4 Timing your code . . . . . . . . . . . . . . . . . . . . . . . . . . 178 13.5 Further extensions to MCMC . . . . . . . . . . . . . . . . . . . 179 13.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 14 Information Criteria 183 14.1 Model assessment guidelines . . . . . . . . . . . . . . . . . . . . 184 14.2 Information criteria for assessing competing models . . . . . . . 186 14.3 A few cautionary notes . . . . . . . . . . . . . . . . . . . . . . . 187 14.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 III Stability Analysis for Differential Equations 191 15 Systems of Linear Differential Equations 193 15.1 Linear systems of differential equations and matrix notation . . 193 15.2 Equilibrium solutions. . . . . . . . . . . . . . . . . . . . . . . . 194 15.3 The phase plane . . . . . . . . . . . . . . . . . . . . . . . . . . 195 15.4 Non-equilibrium solutions and their stability. . . . . . . . . . . 196 15.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 16 Systems of Nonlinear Differential Equations 203 16.1 Introducing nonlinear systems of differential equations . . . . . 203 16.2 Zooming in on the phase plane . . . . . . . . . . . . . . . . . . 204 16.3 Determining equilibrium solutions with nullclines . . . . . . . . 206 16.4 Stability of an equilibrium solution . . . . . . . . . . . . . . . . 207

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.