# Exploring Modeling with Data and Differential Equations Using R

*Version 3.0.0*

# Welcome

This book is written for you, the student learning about modeling and differential equations. Perhaps you first encountered models, differential equations, and better yet, building plausible models from data in your calculus course.

This book sits “at the intersection” of several different mathematics courses: differential equations, linear algebra, statistics, calculus, data science - as well as the partner disciplines of biology, chemistry, physics, business, and economics. An important idea is one of *transference* where a differential equation model applied in one context can also be applied (perhaps with different variable names) in a separate context.

I intentionally emphasize models from biology and the environmental sciences, but throughout the text you can find examples from the other disciplines. In some cases I’ve created homework exercises based on sources that I have found useful for teaching (denoted with “Inspired by …”). I hope you see the connections of this content to your own intended major.

This book is divided into 4 parts:

- Models with differential equations
- Parameterizing models with data
- Stability analysis for differential equations
- Stochastic differential equations

You may notice the interwoven structure for this book: models are introduced first, followed by data analysis and parameter estimation, returning back to analyzing models, and ending with simulating random (stochastic) models.

Unsure what about all these topics mean? Do not worry! The topics are presented with a “modeling first” paradigm that first introduces models, and equally important, explains how data are used to inform a model. This “conversation” between models and data are important to help build plausibility and confidence in a model. Stability analysis helps to solidify the connection between models and parameters (which may change the underlying dynamical stability). Finally the notion of *randomness* is extended with the introduction of stochastic differential equations.

Unifying all of these approaches is the idea of developing workflows for analysis, visualization results, and interpreting any results in the context of the problem.

## Computational code

This book makes heavy use of the `R`

programming language, and unabashedly develops programming principles using the `tidyverse`

syntax and programming approach. This is intentional to facilitate direct connections to courses in introductory data science or data visualization. Throughout my years learning (and teaching) different programming languages, I have found `R`

to be the most versatile and adaptable. The `tidyverse`

syntax, in my opinion, has transformed my own thinking about sustainable computation and modeling processes - and I hope it does for you as well.

There is a companion `R`

package available called `demodelr`

to run programs and functions in the text (Zobitz 2022). Instructions to install this package are given in Chapter 2. The minimum version of `R`

used was Version 4.0.2 (2020-06-22) (R Core Team 2021) and `RStudio`

is Version 1.4.1717 (RStudio Team 2020).

The `demodelr`

package uses the following `R`

packages:

`tidyverse`

(and the associated packages) (Version 1.3.1) (Wickham et al. 2019)`GGally`

(Version 2.1.2) (Schloerke et al. 2021)`formula.tools`

(Version 1.7.1) (Brown 2018)`expm`

(Version 0.999-6) (Goulet et al. 2021)

## Questions? Comments? Issues?

Any errors or omissions are of my own accord, so please contact me at `zobitz@augsburg.edu`

. Feel free to file an issue with the `demodelr`

package to my github.

## About the cover

The photo on the back cover was taken by Shannon Zobitz during a hike at Orinoro Gorge in Finland. The photo is indicative of several things: (1) the journey ahead as you commence learning about modeling, differential equations, and `R`

, (2) the occasional roots in the path that may cause you to stumble (such as coding errors). Everyone makes them, so you are in good company. (3) the yellow markings on the trees indicate the way forward. The vector field image on the cover is an example of a spiral node, indicating my hope that the knowledge contained here spirals out and informs your future endeavors. May this textbook be the guide for you as you progress over the hill and onward. Let’s get started!

## Acknowledgments

This book has been developed over the course of several years in a variety of places: two continents, between meetings, in the early mornings, at coffee shops, or while waiting for practices to end. Special thanks are to the following:

**Augsburg University:**You have been my professional home for over a decade and given me the space and support to be intellectually creative in my teaching and scholarship. Special thanks to my Mathematics, Statistics, and Computer Science Department colleagues - it is a joy to work with all of you.**Augsburg University students:**Thank you for your interest and engagement in this topic, allowing me to test ideas in an upper division course titled (wait for it …)*Modeling and Differential Equations in the Biological and Natural Sciences*. While the course title is a mouthful, you provided concise, honest, and insightful feedback, shaping this text. I am forever indebted to you. Kiitos to students in the Fall 2019 and 2021 courses.**My family:**Shannon, Colin, Grant, and Phoebe for humoring me (and my occasional grumpiness) while this project has been completed.**Taylor & Francis:**Thank you for your confidence in me with this project, and to my editor Lara Spieker for shepherding the project and Robin Lloyd Starkes and her team for their careful copyediting.

### References

*Formula.tools: Programmatic Utilities for Manipulating Formulas, Expressions, Calls, Assignments and Other r Objects*. https://github.com/decisionpatterns/formula.tools.

*Expm: Matrix Exponential, Log, Etc*. http://R-Forge.R-project.org/projects/expm/.

*R: A Language and Environment for Statistical Computing*. Vienna, Austria: R Foundation for Statistical Computing. https://www.R-project.org/.

*RStudio: Integrated Development Environment for R*. Manual. Boston, MA: RStudio, PBC. http://www.rstudio.com/.

*GGally: Extension to Ggplot2*. https://CRAN.R-project.org/package=GGally.

*Journal of Open Source Software*4 (43): 1686. https://doi.org/10.21105/joss.01686.

*Demodelr: Simulating Differential Equations with Data*.