Last time | Next time |
These are the sinusoidal models of Fletcher's BG Climate Normals, by month (max, mean, min temperatures), plus a model for all the 1893-1992 record temperatures taken from the Fletcher data.
Proctor did a nice job on SIR 3
Our model predictions for Italy, May 9th:
Here are some regression results from Mathematica:
Let's take a moment and look over these results. Some observations:
dtrlm = LinearModelFit[data, {x}, x]Silas and I had to remove some missing values, which led to the ugly regression command
dtrlm = LinearModelFit[Cases[data, {_?NumericQ ..}], {x}, x]Mathematica strips off any non-numeric cases. There is nothing I can say about that command -- it's completely non-intuitive -- but I can say that I found it by googling something like "Mathematica handle missing cases regression" (or the like), and then looking for something from stackexchange
(* There are some missing values, hence this was suggested by Thanks to George2079: https://mathematica.stackexchange.com/questions/133355/linearmodelfit-and-missing-data *)
(I always try to embed "credit where credit is due" in code.)
By the way, better to use "adjusted" $R^2$ because it penalizes a model for using more parameters -- we can always get a better fit by adding an additional parameter. So you're basically saying how much additional bang do I get for that extra parameter?
So what we focus on here is a different question: is the slope significantly different from zero?
Fletcher stuff may appear as well. You should try to be up to speed on everything we've been doing, especially since Spring Break. I know that it's been rougher for some of you than for others.
There may be an InsightMaker component. That would seem reasonable, given all we've done.
Newton's method is a powerful numerical technique for solving the important (but trivial looking) equation \[ f(r)=0 \] for the "root" $x=r$. There may be no solution; there may be an infinite number of solutions (as in the example shown in the figure above).
Newton's method is iterative: that is, we start, do it once, and then restart, doing it again and again (until satisfied). In the end we have only an approximate root, but we hope that it suffices for our purposes: so do this, starting from your good guess $x_0$, until satisfied (let's say $N$ times):
\[ x_{n+1}=x_{n}-{\frac {f(x_{n})}{f'(x_{n})}} \] Then take $r \approx x_N$.
This is not an easy problem, in general, but with a good starting guess, and a little luck (plus the ability to compute derivatives) we may be able to find a useful root.
Non-linear regression is frequently done by simply iterating linear systems. It's a really cool example of a generalization similar to Newton's method. The trick is starting with a good guess.
But, when we gave it a little guidance (using some good approximations, some obtained by "almost linearizing" the system), the solution obtained and shown here --
Our job as a math modeler is frequently to fit data. There is often a "part 2", however: for example, now predict a value outside of the data set (extrapolation), or between data points (interpolation).
That made more sense, as the corn should asymptote, which the logistic function does.
This one says "do you know a function which is its own derivative up to a constant?" And there are two good answers: an exponential function, and $y(t)=0$. But the exponential turns out to be a lot more useful for modeling populations....
Usually we also provide an initial condition - $y(0)=y_0$ -- so that the solution is uniquely determined for all time: \[ y(t)=y_0 e^{\alpha t}. \]
If $\alpha > 0$, then the slope on the right-hand side of the differential equation is always positive; therefore the solution function must be always increasing.
The study of the sign of the right-hand side is thus of primary importance. A negative term is bleeding off $y$, whereas a positive term is building it up.
\[ \frac{dy}{dt}=b y\left(1-\frac{y}{K}\right) \]
Note that the sign of the rate of change is determined by $y$'s size relative to $K$: if $y(t)\gt K$, then the slope is negative, and $y$ decreases towards $K$; if $y(t)\lt K$, then the slope is positive, and $y$ increases towards $K$; if $y(t)=K$ (or $y(t)=0$), then the slope is 0, and $y$ is not changing (an equilibrium; $y(t)=K$ is stable, whereas $y(t)=0$ is unstable -- the difference is that, if you push $y$ away from the stable equilibrium, it will return to that equilibrium).
This equation has solutions \[ y(t)=\frac{K}{1-e^{-bt}e^{-Kc}} =\frac{K}{1-\left(1-\frac{K}{y_0}\right)e^{-bt}} =\frac{y_0K}{y_0-(y_0-K)e^{-bt}} \] that is, logistics -- the same function we used to fit the corn data. It takes a lot of staring to come up with a solution like that -- so there are also techniques in differential equations (separation of variables, in this case), that can also be used:).
Logistics are also used to model creatures living in an idyllic world, in which the world provides for their needs (at a level of population of $K$ -- if there are more than $K$, however, the population must die back to a supportable $K$; and if the population falls below $K$, then it will rise back up, because the environment will support a population of $K$.
This is the differential equation of a spring from physics, with its end at position $y(t)$: Newton said that $F=ma=m\frac{d^2y}{dt^2}$; Hooke said that the restorative force for a spring is $F=-ky$; equating the two, you get
\[ m\frac{d^2y}{dt^2}=-ky,\textrm{ or }\\ \frac{d^2y}{dt^2}=\left(\frac{-k}{m}\right)y(t)=-\alpha y \] (the value of $\alpha$ determines the period of the sine and cosine solutions). Springs "bounce" periodically.... Of course friction is the third force, and that's the one that brings all the fun to an end.
\[ \frac{dx}{dt}= \alpha x - \beta x y\\ \frac{dy}{dt}= \delta x y - \gamma y \]
In this case, $x$ is the prey, and $y$ the predator. We can rewrite the system in a couple of different ways, but one that relates us back to the logistic is this one:
\[ \frac{dx}{dt}= \alpha x \left(1 - \frac{x}{\left(\frac{\alpha x}{\beta y}\right)} \right)\\ \frac{dy}{dt}= (\delta x) y \left(1 - \frac{y}{\left(\frac{\delta x y}{\gamma}\right)}\right) \]
So that we can consider $K=\frac{\alpha x}{\beta y}$ as an "effective carrying capacity" for the prey -- and so long as this scaled ratio of prey to predator stays relatively constant, the prey would behave logistically. But since it's a moving target, so to speak, you might imagine that oscillations are possible (and the Lotka-Volterra system loves to oscillate!).
Similarly, the birth rate of the predator is actually a function of $x$ ($\delta x$), as is its "effective carrying capacity": $\frac{\delta x y}{\gamma}$.
We examined an interesting application of predator/prey models to lynx and hares up in Canada. Tyson, et al. were interested in capturing some data with a model that involved general predation, and specialist predation from three populations of predators (poor hares!).
They relied on models which are featured in the Bestiary of functions:
As we do non-linear model-fitting, we're relying on knowing a fair number of non-linear animals at "the function zoo" -- and why we'd choose one versus another. The important features, as we choose a "functional form" for a model, are things like
\[ \frac{dS}{dt} = -\alpha S I\\ \frac{dI}{dt} = \alpha S I - \beta I\\ \frac{dR}{dt} = \beta I \]
We also discovered the value in "flattening the curve" of the primary infection (as well as the danger of "squashing the curve" -- so that it simply comes back later on; we need a certain level of infection to attain a certain level of "herd immunity", to keep the outbreak from breaking out....).
So there are realistic lessons that we can learn from our models -- I hope that you appreciate those lessons. For example, you may remember in lab 2 how we squashed down too hard on infectivity with the social distancing from 30 to 110 days -- we dropped the infectivity from .45 to .10 during that time.
What happened was that we just put off the epidemic. It's exactly what this expert is explaining in her discussion of Covid-19 (which I got in my email feed this morning):
Herd immunity in California? A Stanford expert on why we're nowhere close: Dr Yvonne Maldonado explains why claims about early spread have been overblown and misleading
At Stanford University, located in Silicon Valley, researchers have been tracking early spread by pooling samples from patients with upper respiratory symptoms. In an initial study, the scientists found the presence of Covid-19 before mid-February was low; only two out of nearly 3,000 people with respiratory symptoms in early 2020 were later found to have had Covid-19.
Dr Yvonne Maldonado, epidemiologist and infectious disease specialist at Stanford Medicine, explained why the claims about early spread have been overblown and misleading. This conversation has been edited and condensed for clarity.
What does this mean for immunity in California? We're not "immune" in California, because we're already starting to get antibody tests, and we don't have a high rate of antibody prevalence in just the few tests that have been run. In the coming weeks, we plan to use our own Stanford tests to look at antibody levels, and we're just not going to see very high levels. As devastating as this epidemic is, around the world we estimate that about 5% or less of people have actually been infected.
So how do we move forward? With a disease like this, you probably need somewhere on the order of 60% or more people to have immunity in order to prevent an epidemic [ael: my emphasis]. Right now, if we're at less than 5%; you would need at least ten- to twelve-fold that level. The only way to get there is to vaccinate people or else have horrific transmissions[ael: my emphasis -- let the disease "burn itself out"], and we can't do the latter. So we're going to have to continue some social distancing efforts.
Predator/prey lab video summaries:
Here are the SIR lab summaries:
The exam will include a "timed portion" (which I hope you can begin at class time -- let me know if that's a problem), and a "take home" portion (involving an and/either/or of regression and InsightMaker).
Some good links that I might recommend (a few of which we'll focus on):
In particular, we will implement The SIR Model for Spread of Disease - The Differential Equation Model in InsightMaker.
(An excellent introduction to SIR models, from both the infectious disease and mathematical sides)
Questions:
This on-line estimator (i.e., a model!) allows one to estimate deaths, as well as death by age-category.