# Example Models

## Contents

- 1 Foxes and Hares
- 2 Party Problem
- 3 Rent vs. Buy
- 4 Marginal Abatement Graph
- 5 Solar Panel Analysis
- 6 Timber Post Compression Load Capacity
- 7 Transforming Dimensions by transform matrix, month to quarter
- 8 Items within Budget function
- 9 Convolution
- 10 Sampling from only feasible points
- 11 Grant Exclusion Model
- 12 Donor/Presenter Dashboard
- 13 Project Planner
- 14 California Power Plants
- 15 Dependency Tracker Module
- 16 Total Allowable Harvest
- 17 Earthquake Expenses
- 18 Regulation of Photosynthesis
- 19 Cross-Validation / Fitting Kernel Functions to Data
- 20 Statistical Bootstrapping
- 21 Compression Post Load Calculator
- 22 Daylighting Options in Building Design
- 23 Plane Catching Decision with Expected Value of Including Uncertainty
- 24 Marginal Analysis for Control of SO
_{2}emissions - 25 Electrical Generation and Transmission
- 26 Loan Policy Selection
- 27 Time-series re-indexing
- 28 Multi-lingual Influence Diagram
- 29 Smooth PDF plots using Kernel Density Estimation
- 30 Output and Input Columns in Same Table
- 31 Linearizing a discrete NSP
- 32 Neural Network
- 33 Extracting Data from an XML file
- 34 Vector Math
- 35 Color Map
- 36 See Also

You may find these example Analytica models useful to see what Analytica can do, and as inspiration or a starting point for your own models. They cover a wide variety of topics and techniques.

These examples supplement the example models that are installed with Analytica into the Examples folder.

You can are also invited to contribute your own models as examples. For how to do that, see Uploading Example Models.

## Foxes and Hares

**Description**: This model describes the dynamics of a predator/prey relationship. See Tutorial: Dynamic system model for details.

**Keywords**: Dynamic systems, dynamic simulation, feedback loops, cycles, ecosystem, predator prey models.

**Play**: Foxes and Hares model in Analytica Cloud Player

**Author**: Analytica team at Lumina

**Download**: Part of Desktop Analytica (Example Models > Tutorial Models)

## Party Problem

**Description**: This model shows how to model a decision tree to decide what is the best location to hold a party, depending on (uncertain) weather. See Tutorial: Decision trees for details.

**Keywords**: Decision analysis, decision tree, expected value, discrete probability distribution.

**Author**: Analytica team at Lumina

**Download:** Part of Desktop Analytica (Example Models > Decision Analysis > Party With Forecast.ana )

## Rent vs. Buy

**Description**: This model analyzes the costs and benefits of renting a home vs buying a home. See more at Tutorial: Open a model to browse, Tutorial: Reviewing a model and Tutorial: Analyzing a model

**Keywords**: Uncertainty, Monte Carlo simulation, appreciation, present value, finance.

**Play**: Rent vs. Buy model in Analytica Cloud Player

**Author**: Analytica team at Lumina

**Download**: Part of Desktop Analytica (Example Models > Tutorial Models)

## Marginal Abatement Graph

This model, along with the accompanying blog article, show how to set up a Marginal Abatement graph in Analytica.

**Keywords**: Graph methods, carbon price, energy efficiency, climate policy, optimal allocation, budget constraint.

**Author:** Lonnie Chrisman

**Download:** Marginal abatement home heating.ana

## Solar Panel Analysis

**Description:** Would it be cost effective to install solar panels on the roof of my house? This model explores this question for my situation in San Jose, California. An accompanying video documents the building of this model, and is a good example of the process one goes through when building any decision model.

The model explores how many panels I should install, and what the payoff is in terms of net present value, Internal rate of return and time to recoup cost. It also looks at whether I should postpone the start of the installation to take advantage of rapidly falling PV prices, or cash in on tax credits.

**Keywords**: Renewable energy, photovoltaics, net present value, internal rate of return, tax credits, agile modeling.

**Author:** Lonnie Chrisman

**Download:** Solar Panel Analysis.ana

## Timber Post Compression Load Capacity

**Description:** Here is a calculator for computing the maximum load that can be handled by a Douglas Fir - Larch post of a given size, grade, and composition in a construction setting.

**Keywords:**

**Author:** Lonnie Chrisman

**Download:** Post Compression Model

## Transforming Dimensions by transform matrix, month to quarter

**Description:** The model shows how to transform an array from a finer-grain index (e.g., Month) onto a coarser index (e.g., Quarter). We generally refer to this as aggregation. The model illustrates the direct use of Aggregate, as well as a method to do this used before Aggregate was added to Analytica in release 4.2.

**Webinar:** the Aggregate function.

**Keywords**: Aggregation, level of detail, days, weeks, months, quarters, years.

**Author:** Lonnie Chrisman

**Download:** Month to quarter.ana

## Items within Budget function

**Description:** Given a set of items, with a priority and a cost for each, the function Items_within_budget function selects out the highest priority items that fit within the fixed budget.

**Keywords:**

**Author:** Max Henrion

**Download**: Media:Items_within_budget.ana

## Convolution

**Description:** Convolution is used mostly for signal and systems analysis. It is a way to combine two time series. This model contains function Convolve(Y, Z, T, I), that computes the convolution of two time series. The model contains several examples of convolved functions.

A time series is a set of points, `(Y, T)`

, where `T`

is the ascending X-axis, and the set of points is indexed by `I`

. The values of `T`

do not have to be equally spaced. The function treats `Y`

and `Z`

as being equal to 0 outside the range of `T`

. The two time series here are the set of points `(Y, T)`

and the set of points `(Z, T)`

, where both sets of points are indexed by `I`

.

The mathematical definition of the convolution of two time series is the function given by:

- $ h(t) = \int y(u) z(t-u) dt $

**Keywords:** Signal analysis, systems analysis

**Author:** Lonnie Chrisman

**Download**: Convolution

## Sampling from only feasible points

**Description:** Consider this scenario. You have a bunch of chance variables, each defined by a distribution. They joint sample generated, however, contains some combinations of points that are (for one reason or another) physically impossible. We'll call those infeasible points. You'd like to eliminate those points from the sample and keep only the feasible points.

This module implements a button that will sample a collection of chance variables, then reset the sample size and keep only those sample points that are "feasible".

Obviously, this approach will work best when most of your samples are feasible. If you can handle the "infeasible" points in your model directly, by conditioning certain chance variables on others, that is far preferable. But there are certainly cases where this solution (although a bit of a kludge) is more readily usable.

The instructions for how to use this are in the module description field.

**Keywords**: Statistics, sampling, Importance sampling, feasibility, Monte Carlo simulation

**Author:** Lonnie Chrisman

**Download**: Media:Feasible_Sampler.ana

## Grant Exclusion Model

**Description:** This model tests a hypothesis about the distribution of an attribute of the marginal rejectee of a grant program, given the relevance of that attribute to award of the grant. It could be used by an organization to make decisions as to whether to fiscally-sponsor another organization that will use that fiscal sponsorship to apply for grants, by looking at the effect on the pool of grant recipients overall.

**Keywords:** Business analysis

**Download**: Media:Grant_exclusion.ANA

## Donor/Presenter Dashboard

**Description:** This model implements a continuous-time Markov chain in Analytica's discrete-time dynamic simulation environment. It supports immigration to, and emigration from, every node.

It can be used by an arts organization to probabilistically forecast future audience evolution, in both the short and the long (steady state) term. It also allows for uncertainty in the input parameters.

**Keywords:** Dynamic models, Markov processes

**Download:** Donor-Presenter Dashboard

## Project Planner

**Description:** This is a demo model that shows how to:

- Evaluate a set of R&D projects, including uncertain R&D costs, and uncertain revenues if it leads to release of a commercial product.
- Use multiattribute analysis to compare projects, including a hard attribute -- expected net present value -- and soft attributes -- strategic fit, staff development, and public good will.
- Compare cost, NPV, and multiattribute value for a selected portfolio of projects.
- Generate the best portfolio (ratio of NPV or multiattribute merit to cost) given a R&D budget.

The model linked here is only a test, and to an older version: File:Project priorities 2007 4.0.ANA

**Keywords:** Business models, cost analysis, net present value (NPV), uncertainty analysis

**Download:** Project Priorities 5 0.ana

## California Power Plants

**Description:** An example showing how to use Choice menus and Checkbox inside an Edit table. It also shows how to use the Cell default attribute to specify default values (including Choice menu and Checkbox with default selections) specified in "Default Plant Data" to be used when user creates a new row in the Edit table. This model shows how to demonstrates the use of choice pulldowns in edit tables. The model is created during a mini-tutorial on Inserting Choice Controls in Edit Table Cells elsewhere on this Wiki.

**Keywords:** Edit table, Choice menu, pulldown menu, checkbox, Power plants.

**Download:** California Power Plants.ana

## Dependency Tracker Module

**Description:** This module tracks dependencies through your model, updating the visual appearance of nodes so that you can quickly visualize the paths by which one variable influences another. You can also use it to provide a visual indication of which nodes are downstream (or upstream) from an indicated variable.

The module contains button scripts that change the bevel appearance of nodes in your model. To see how Variable `X`

influences Variable `Y`

, the script will bevel the nodes for all variables that are influenced by `X`

and influence `Y`

. Alternatively, you can bevel all nodes that are influenced by `X`

, or you can bevel all nodes that influence `Y`

.

In the image above, the path from `dp_ex_2`

through `dp_ex_4`

has been highlighted using the bevel style of the nodes. (The result of pressing the "Bevel all from Ancestor to Descendant" button)

**Keywords:** Dependency analysis

**Download:** Dependency Tracker.ana

## Total Allowable Harvest

**Description:** The problem applies to any population of fish or animal whose dynamics are poorly known but can be summarized in a simple model:

`N_t + 1 = N_t*Lambda - landed catch*(1 + loss rate)`

where «N_t» is the population size (number of individuals) at time *t*, «N_t+1» is the population size at time *t + 1*, «Lambda» is the intrinsic rate of increase and the «loss rate» is the percentage of fish or animals killed but not retrieved relative to the «landed catch», or catch secured.

The question here is to determine how many fish or animals can be caught (landed) annually so that the probability of the population declining X% in Y years (decline threshold) is less than Z% (risk tolerance).

Two models are available for download. One uses the Optimizer (NlpDefine) to find the maximum landed catch at the risk tolerance level for the given decline threshold. The other (for those using a version of Analytica without Optimizer) uses StepInterp in an iterative way to get that maximum landed catch.

**Keywords:** Population analysis, dynamic models, optimization analysis

**Author:** Models contributed by Pierre Richard

**Download:**

## Earthquake Expenses

**Description:** An example of risk analysis with time-dependence and costs shifted over time.

Certain organizations (insurance companies, large companies, governments) incur expenses following earthquakes. This simplified demo model can be used to answer questions such as:

- What is the probability of more than one quake in a specific 10 year period.
- What is the probability that in my time window my costs exceed $X?

Assumptions in this model:

- Earthquakes are Poisson events with mean rate of once every 10 years.
- Damage caused by such quake is lognormally distributed, with mean $10M adn stddev of $6M.
- Cost of damage gets incurred over the period of a year from the date of the quake as equipment is replaced and buildings are repaired over time: 20% in 1st quarter after quake, 50% in 2nd quarter, 20% in 3rd quarter, 10% in 4th quarter.

**Keywords:** Risk analysis, cost analysis

**Download**: Earthquake expenses.ana

## Regulation of Photosynthesis

A model of how photosynthesis is regulated inside a cyanobacteria. As light exposure varies over time (and you can experiment with various light intensity waveforms), it simulates the concentration levels of key transport molecules along the chain, through the PSII complex, plasto-quinone pool, PSI complex, down to metabolic oxidation. The dynamic response to light levels, or changes in light levels, over time becomes evident, and the impact of changes to metabolic demand can also be observed. In the graph of fluorescence above, we can see an indicator of how much energy is being absorbed, in three different cases (different light intensities). In the two higher intensity cases, photoinhibition is observed -- a protective mechanism of the cell that engages when more energy is coming in than can be utilized by the cell. Excess incoming energy, in the absense of photoinhibition, causes damage, particularly to the PSII complex.

This model uses node shapes for a different purpose than is normally seen in decision analysis models. In this model, ovals, instead of depicting chance variables, depict chemical reactions, where the value depicts the reaction rate, and rounded rectangles depict chemical concentrations.

Two models are attached. The first is a bit cleaner, and focused on the core transport chain, as described above. The second is less developed, but is focused more on genetic regulation processes.

**Keywords:** Photosynthesis, dynamic models

**Author:** Lonnie Chrisman

**Download:**

- Photosynthesis Regulation.ana - main regulation pathways
- Photosystem.ana - rough sketch of genetic regulation.

## Cross-Validation / Fitting Kernel Functions to Data

**Description:** When fitting a function to data, if you have too many free parameters relative to the number of points in your data set, you may "overfit" the data. When this happens, the fit to your training data may be very good, but the fit to new data points (beyond those used for training) may be very poor.

Cross-validation is a common technique to deal with this problem. With this technique, we set aside a fraction of the available data as a cross-validation set. Then we begin by fitting very simple functions to the data (with very few free parameters), successively increasing the number of free parameters, and seeing how the predictive performance changes on the cross-validation set. It is typical to see improvement on the cross-validation set for a while, followed by a deterioration of predictive performance on the cross-validation set once overfitting starts occurring.

This example model successively fits a non-linear kernel function to the residual error, and uses cross-validation to determine how many kernel functions should be used.

Requires Analytica Optimizer: The kernel fitting function (Kern_Fit) uses NlpDefine.

**Keywords:** Cross-validation, overfitting, non-linear kernel functions

**Author:** Lonnie Chrisman

**Download:** Cross-validation example.ana

## Statistical Bootstrapping

**Description:** Bootstrapping is a technique from statistics for estimating the sampling error present in a statistical estimator. The simplest version estimates sampling error by resampling the original data. This model demonstrates how this is accomplished in Analytica.

**Keywords:** Bootstrapping, sampling error, re-sampling

**Download:** Bootstrapping.ana

## Compression Post Load Calculator

**Description:** Computes the load that a Douglas-Fir Larch post can support in compression. Works for different timber types and grades and post sizes.

**Keywords:** Compression analysis

**Author:** Lonnie Chrisman

**Download:** Compression Post Load Capacity.ana

## Daylighting Options in Building Design

**Description:** A demonstration showing how to analyze lifecycle costs and savings from daylighting options in building design.

Analysis based on Nomograph Cost/Benefit Tool for Daylighting. adapted from S.E. Selkowitz and M. Gabel. 1984. "LBL Daylighting Nomographs," LBL-13534, Lawrence Berkeley Laboratory, Berkeley CA, 94704. (510) 486-6845.

**Keywords:** Engineering, cost-benefits analysis

**Author:** Max Henrion

**Download:** Daylighting analyzer.ana

## Plane Catching Decision with Expected Value of Including Uncertainty

**Description:** A simple model to assess what time I should leave my home to catch a plane, with uncertain driving time, walking from parking to gate (including security), and how long I need to be at the gate ahead of scheduled departure time. It uses a loss model based on minutes, assuming I value each extra minute snoozing in bed and set the loss if I miss the plane to 400 of those minutes.

It illustrates the EVIU (expected value of including uncertainty) i.e. the difference in expected value if I make a decision to minimize expected loss instead of decision to minimize time ignoring uncertainty (assuming each distribution is fixed at its mid value). For more details see "The Value of Knowing How Little You Know", Max Henrion, PhD Dissertation, Carnegie Mellon University, 1982.

**Keywords**: Decision theory, decision analysis, uncertainty, Monte Carlo simulation, value of information, EVPI, EVIU.

**Author:** Max Henrion

**Download:** media:Plane catching decision with EVIU.ana

## Marginal Analysis for Control of SO_{2} emissions

**Description:** Acid rain in eastern US and Canada caused by sulfur dioxide is emitted primarily by coal-burning electric-generating plants in the Midwestern U.S. This model demonstrates a marginal analysis a.k.a. benefit/cost analysis to determine the policy alternative that leads us to the most economically efficient level of cleanup.

**Keywords:** Environmental engineering, cost-benefit analysis, marginal analysis

**Author:** Surya Swamy

**Download:** Marginal Analysis for Control of SO2 Emissions.ana

## Electrical Generation and Transmission

**Description:** This model of an electrical network minimizes total cost of generation and transmission. Each node in the network has power generators and consumers (demand). Nodes are connected by transmission links. Each link has a maximum capacity in Watts and an admittance (the real part of impedance is assumed to be zero). Each generator has a min and max power and a marginal cost in $/KWh. The model uses a linear program to determine how much power each generator should produce so as to minimize total cost of generation and transmission, while satisfying demand and remaining within link constraints.

*Requires Analytica Optimizer*

**Keywords:** Electrical engineering, power generation and transmission

**Author:** Lonnie Chrisman

**Download:** Electrical Transmission.ana

## Loan Policy Selection

**Description:** A lender has a large pool of money to loan, but needs to decide what credit rating threshold to require and what interest rate (above prime) to charge. The optimal value is determined by market forces (competing lenders) and by the probability that the borrower defaults on the loan, which is a function of the economy and borrower's credit rating. The model can be used without the Analytica optimizer, in which case you can explore the decision space manually or use a parametric analysis to find the near optimal solution. Those with Analytica Optimizer can find the optimal solution (more quickly) using an NLP search.

**Best used with Analytica Optimizer**

**Keywords:** Creditworthiness, credit rating, default risk, risk analysis

**Author:** Lonnie Chrisman

**Download:** Loan policy selection.ANA

## Time-series re-indexing

**Description:** This model contains some examples of time-series re-indexing. It is intended to demonstrate some of these basic techniques.

In this example, actual measurements were collected at non-uniform time increments. Before analyzing these, we map these to a uniformly spaced time index (`Week`

), occurring on Monday of each week. The mapping is done using an interpolation. The evenly-spaced data is then used to forecast future behavior. We first forecast over an index containing only future time points (`Future_weeks`

), using a log-normal process model based on the historical weekly change. We then combine the historical data with the forecast on a common index (`Week`

). A prob-bands graph of the weekly_data result shows the range of uncertainty projected by the process model (you'll notice the uncertainty exists only for future forecasted values, not historical ones).

**Keywords:** Dynamic models, forecasting, time-series re-indexing

**Author:** Lonnie Chrisman

**Download:** Time-series-reindexing.ana

## Multi-lingual Influence Diagram

**Description:** Maintains a single influence diagram with Title and Description attributes in both English and French. With the change of a pull-down, the influence diagram and all object descriptions are instantly reflected in the language of choice.

If you change a title or description while viewing English, and then change to French, the change you made will become the English-language version of the description. Similarly if you make a change while viewing French.

**Keywords:** Multi-lingual models

**Author:** D. Rice, Lumina Decision Systems

**Download:** French-English.ana

## Smooth PDF plots using Kernel Density Estimation

**Description:** This example demonstrates a very simple fixed-width kernel density estimator to estimate a "smooth" probability density. The built-in PDF function in Analytica often has a choppy appearance due to the nature of histogramming -- it sets up a set of bins and counts how many points land in each bin. A kernel density estimator smooths this out, producing a less choppy PDF plot.

This smoothing is built into Analytica 4.4. You can select smoothing from the Uncertainty Setup dialog.

**Keywords:** Kernel density estimation, kernel density smoothing

**Author:** D. Rice, Lumina Decision Systems

**Download:** Kernel Density Estimation.ana

## Output and Input Columns in Same Table

**Description:** Presents an input table to a user, where one column is populated with computed output data, the other column with checkboxes for the user to select. Although the **Output Data** column isn't read only, as would be desired, a Check Attribute has been configured to complain if he does try to change values in that column. The model that uses these inputs would ignore any changes he makes to data in the **Output Data** column.

Populating the **Output Data** column requires the user to press a button, which runs a button script to populate that column. This button is presented on the top-level panel. If you change the input value, the output data will change, and then the button needs to be pressed to refresh the output data column.

**Keywords:** Data analysis

**Author:** D. Rice, Lumina Decision Systems

**Download:** Output and input columns.ana

## Linearizing a discrete NSP

**Description:** A cereal formulation model

A discrete mixed integer model that chooses product formulations to minimize total ingredient costs. This could be an NSP but it uses two methods to linearize: 1) Decision variable is constructed as a constrained Boolean array 2) Prices are defined as piecewise linear curves

**Keywords:** product formulation, cereal formulation

**Author:** P. Sanford, Lumina Decision Systems

**Download:** Cereal Formulation1.ana

## Neural Network

**Description:** A feed-forward neural network can be trained (fit to training data) using the Analytica Optimizer. This is essentially an example of non-linear regression. This model contains four sample data sets, and is set up to train a 2-layer feedforward sigmoid network to "learn" the concept represented by the data set(s), and then test how well it does across examples not appearing in the training set.

Developed during the Analytica User Group Webinar of 21-Apr-2011 -- see the webinar recording.

**Keywords:** Feed-forward neural networks, optimization analysis

**Author:** Lonnie Chrisman, Lumina Decision Systems

**Download:** Neural-Network.ana

## Extracting Data from an XML file

**Description:** Suppose you receive data in an XML format that you want to read into your model. This example demonstrates two methods for extracting data: Using a full XML DOM parser, or using regular expressions. The first method fully parses the XML structure, the second simply finds the data of interest by matching patterns, which can be easier for very simple data structures (as is often the case).

**Keywords:** Data extraction, xml, DOM parsing

**Author:** D. Rice, Lumina Decision Systems

**Download:** Parsing XML example.ana

## Vector Math

**Description:**
Functions used for computing geospatial coordinates and distances. Includes:

- A cross product of vectors function
- Functions to conversion between spherical and Cartesian coordinates in 3-D
- Functions to compute bearings from one latitude-longitude point to another
- Functions for finding distance between two latitude-longitude points along the great circle.
- Functions for finding the intersection of two great circles

**Keywords:** Geospatial analysis, GIS, vector analyisis

**Author:** Robert D. Brown III, Incite Decision Technologies, LLC

**Download:** Vector Math.ana

## Color Map

**Description:** A model which highlights Cell Formatting and Computed Cell Formats. Model result is a 'color map' wherein the cell fill color is computed based on three input variables (R, G, and B), the computed color is displayed in hexadecimal, and the font color of the hexadecimal color is determined by the cell fill color.

**Keywords:** Computed cell formatting

**Author:** Kimberley Mullins, Lumina Decision Systems

**Download:** Color map.ana

## See Also

- Additional libraries
- Uploading Example Models
- Example Models and Libraries
- Using Add Module... to import a Model file
- Import a module or library
- Tutorial: Sharing a model with ACP
- Obfuscated and Browse-Only Models
- Filed modules and libraries
- Working with Models, Modules, and Files in ADE
- Combining models into an integrated model
- Model file formats
- Model Licensing

Enable comment auto-refresher