# Estimating Model Parameters from External Data

### From Eclipsepedia

## Contents |

## Introduction

STEM provides a way for users to input data from CSV Files and Estimated model parameters in, for example, an SIR or SEIR model so that model will best approximate the input data. Model Parameter Estimation is a view that allows a user to estimate parameters for a (new) model based on existing data. Algorithms are now complete for parameter Estimation using SI, SIR, and SEIR models.

## Using the Estimator

1. Enter the Analysis Perspective 2. Click on the Estimator Tab 3. Click on the "Select" button to chose the directory that contains the data files you wish to analyze. These files should have the following format. 4. A dialog will launch allowing you to chose the folder. Select the folder by clicking "Select Scenario Folder" and then click "Next"

5. A second dialog will launch allowing you to chose from valid models appropriate to the data set you chose. If, for example, the data contains files for all S,E,I,R states, then any SEIR parameter estimator will appear on the list. Select an Estimator and click "Finish"

6. The Folder you chose will now show up on the "Scenario Folder" text field. Click "Estimate Parameters".

7. A bar chart graph will appear showing you estimates for the appropriate model parameters. In some case two bars will appear for each parameter as the estimator may determine the best estimate fits within a range of values. For more information on the estimation algorithms please see below.

# Mathematics

## SI Models and Parameter Estimation

Two equations define the SI model:

where:

β is the infection rate

α is the recovery rate (back to being susceptible)

Dividing through the dI/dt equation by I gives the following equation:

which can then be fit to a line y = βx - α, where x = S and y = dlnI/dt, using the method of least squares. This will give values for β and α and their standard deviations and variances.

## SIR Models and Parameter Estimation

Three equations define the SIR model:

where:

β is the infection rate

α is the immunity loss rate (alpha equal zero)

γ is the recovery rate

### Method One

Adding the first two equations together gives us the following equation:

which can be fit to a line z = αx - εy, where x = R and y = I, using the method of least squares. In this way, we can solve for α and ε and their respective standard deviations and variances.

Next we go on to fit the dS/dt equation to the line z = αx - βy, where x = IS and y = R, using the same method of least squares method. In this way we can solve for β and α and their standard deviations and variances.

### Method Two

When rearranged by simple algebra, the three SIR equations at the top turn into the following:

All three of the above equations are in the form y = mx + b, where:

Using the method of least squares, we can fit all three equations to a line (y = mx + b) and get the slope (m) and intercept (b) from each equation. The slopes and intercepts in each equation correspond to a parameter in the model equations.

## SEIR Models and Parameter Estimation

Four equations with four parameters define the SEIR model:

where:

β is the infection rate

α is the immunity loss rate

γ is the infectious recovery rate

ε is the incubation rate

P is the time varying total population, and S,E,I,R are the susceptible, exposed, infectious, and recovered populations respectively.

### Method One

When rearranged by simple algebra, the four equations above can be made into the following:

We can fit this equation to the line z = αx - γy, where z = dS/dt + dE/dt + dI/dt and x = R and y = I

Using the method of least squares, we can find the values for α and γ and the variance and the standard deviation for each.

Then we go onto the equation dE/dt = βSI - εE and fit this to the equation z = βx - εy, where z = dE/dt and x = SI and y = E.

Using the same method as above, we can find the values for β and ε and the variance and the standard deviation for each.

### Method Two

When rearranged by simple algebra, the four equations at the top turn into the following:

All four of the above equations are in the form y = mx + b, where:

Using the method of least squares, we can fit all four equations to a line (y = mx + b) and get the slope (m) and intercept (b) from each equation. The slopes and intercepts in each equation correspond to a parameter in the model equations.

### For Nonlinear Case

# Implementation

## Package

All of the analysis is in the package org.eclipse.stem.analysis and projects within

## Classes

### ModelParameters.java

This class holds all of the parameters that we want to estimate and their variances and standard deviations. It also holds the local population density, local population, and a reference population density of 100 for fixing the β parameter.

There is an empty constructor that initializes all values to zero, and there is a constructor for each method of SEIR and SIR.

To find the average of the parameters found from each location, the average() method averages using standard deviations to weight each parameter.

The same is done to find the standard deviation of the average of the parameters, calculateStdAvg().

The toString() method will return the values of all of the parameters and the standard deviations of each.

### ParameterEstimator.java

This class is an abstract class from which the subclasses inherits from.

Constants are set in this class that decide what derivative method will be used. The arrays for S, E, I, R, and t are also made.

### SEIRparameterEstimator.java

This class estimates the parameters for a SEIR model.

The estimate() method estimates parameters for a SEIR model using one of the mathematical methods and returns values for β, α, γ, and ε and their respective standard deviations and variances.

### NonlinearSEIRParameterEstimator.java

This class estimates the parameters for a SEIR model when beta is a function rather than a constant.

The estimate() method estimates parameters for a SEIR model using the mathematical method from above and returns values for β, α, γ, ε, and λ and their respective standard deviations and variances.

### SIRparameterEstimator.java

This class estimates the parameters for a SIR model.

The estimate() method estimates parameters for a SIR model using the method provided above and returns values for β, α, and ε and their standard deviations and variances.

### SIparameterEstimator.java

This class estimates the parameters for a SI model.

The estimate() method estimates parameters for a SI model using the method provided above and returns values for β and α and their standard deviations and variances.