Archive

Posts Tagged ‘arrays’

Modeling Bass Diffusion with Rivalry

February 18th, 2010

Karim Chichakly STELLA & iThink

This is the last of a three-part series on the Limits to Growth Archetype.  The first part can be accessed here and the second part here.

Last time, we explored the effects of Type 1 rivalry (rivalry between different companies in a developing market) on the Bass diffusion model by replicating the model structure.  This part will generalize this structure and add Type 2 rivalry (customers switching between brands).

Bass Diffusion with Type 1 Rivalry

To model the general case of an emerging market with multiple competitors, we can return to the original single company case and use arrays to add additional companies.  In this case, everything except Potential Customers needs to be arrayed, as shown below (and available by clicking here).

image

For this example, three companies will be competing for the pool of Potential Customers.  Each array has one-dimension, named Company, and that dimension has three elements, named A, B, and C, one for each company.  Although each different parameter, wom multiplier, fraction gained per $K, and marketing spend in $K, can be separately specified for each company, all three companies use the same values initially.  All three companies, however, do not enter the market at the same time.  Company A enters the market at the start of the simulation, company B enters six months later, and company C enters six months after that.

Recall that the marketing spend is the trigger for a company to start gaining customers.  Thus, the staggered market entrance can be modeled with the following equation for marketing spend in $K:

STEP(10, STARTTIME + (ARRAYIDX() – 1)*6)

The STEP function is used to start the marketing spend for each company at the desired time.  The ARRAYIDX function returns the integer index of the array element, so it will be 1 for company A, 2 for company B, and 3 for company C.  Thus, the offsets from the start of the simulation for the launch of each company’s marketing campaign are 0, 6, and 12, respectively.

This leads to the following behavior:

image

Note that under these circumstances, the first company to enter the market retains a leadership position.  However, companies B and C could anticipate this and market more strongly.  What if company B spent 50% more and company C spent 100% more than company A on marketing that is similarly effective?  This could be modeling by once again changing the equation for marketing spend in $K, this time to:

STEP(10 + (ARRAYIDX() – 1)*5, STARTTIME + (ARRAYIDX() – 1)*6)

Read more…

, , , ,

Modeling Customers Switching Between Brands – The General Case

October 23rd, 2009

Karim Chichakly Modeling Tips

This is the last installment of a four-part series.  The first three parts can be accessed by clicking on the links below.
Methods for Using Arrays Effectively

Modeling a Watershed with Arrays
Modeling Customers Switching Between Brands

Generalizing the Model

When I showed Steve Peterson (at Lexidyne) my brand switching model, he told me there is a more general version that separates the customer loss fraction from the fraction won by another competitor.  This has been presented in Pharmaceutical Product Strategy by Mark Paich, Corey Peck, and Jason Valant.

In my original formulation, the switching probability matrix was the product of these two variables.  However, in many practical cases, the data available comes from two different places and reflects these two separate components.  The revised model structure is shown below.

image

Instead of one composite switching probability, this model uses a switching out probability that is distinct from the switching in probability.  The switching out probability is a one-dimensional array that, for each product, contains the fraction of customers lost to rivals every time unit (in our case, month).  A sample for the five brands A, B, C, D, and E appears below.

Brand Fraction Lost
A 0.091
B 0.170
C 0.046
D 0.026
E 0.071

switching out probability

We can see from this table that Brand B is losing 17% of its customers to rivals each and every month!  Whoever is managing that product had better do something quickly.

The other side of the story has to do with which brand the customers are switching to.  The switching in probability matrix contains, for each brand, the fraction of lost customers that migrate to a rival brand.  Thus, each row of this matrix must add up to one (100% of lost customers).  A sample appears below.

From\To A B C D E
A 0.00 0.11 0.33 0.55 0.01
B 0.18 0.00 0.29 0.41 0.12
C 0.22 0.02 0.00 0.44 0.32
D 0.04 0.00 0.77 0.00 0.19
E 0.02 0.07 0.28 0.63 0.00

switching in probability

Note the diagonal will always be zero.

We can determine a lot of things from this table.  For example, brand B offers no competition to brand D, brand D is the biggest rival of all the other brands, and brand C is brand D’s biggest rival.

Read more…

, , ,

Modeling Customers Switching Between Brands

September 30th, 2009

Karim Chichakly Modeling Tips

This is the third installment of a four-part series.  The other three parts can be accessed by clicking on the links below.
Methods for Using Arrays Effectively

Modeling a Watershed with Arrays
Modeling Customers Switching Between Brands – The General Case

In the second post of this series, I showed how to selectively pull information from an array in order to route water through a watershed.  In this post, I will use the exact same technique to move customers between different product brands.

Switching Customers between Different Products

Business models often need to model gaining customers from, and losing customers to, competing products in a relatively mature market (what Kim Warren, in his excellent book Strategy Management Dynamics, calls “Type 2 Rivalry”).  These are often driven with statistical models developed through market research.  For this application, we need a matrix describing the probability of switching from product A to product B each time unit.  A sample appears in the table below.

From\To A B C D E
A 0.000 0.010 0.030 0.050 0.001
B 0.030 0.000 0.050 0.070 0.020
C 0.010 0.001 0.000 0.020 0.015
D 0.001 0.000 0.020 0.000 0.005
E 0.001 0.005 0.020 0.045 0.000

switching probability (units: dimensionless)

To read this table, locate the product the customer is presently using in the left column (say, B).  Read across that row (the second row, in this case) until you find the product the customer is switching to (say, C).  The number in that cell (in this case, 0.05 or 5%) is the probability the customer will switch from the first product to the second (from B to C) in this time unit.  If the model is running in months, as ours is, this table indicates that 5% of customers using product B switch to product C every month.

Of course, the values in the table do not need to be constant.  Often each cell will contain a regression equation based on various product characteristics – including market share, marketing effort, product features, and product quality – that evolve over the course of the simulation.

Note the diagonal is zero.  This means customers do not switch from one product to the same product.

Note also that the sum in any row cannot exceed 1.0, which represents 100% of the customers using that product.  It is quite normal for it to be below 1.0 because we do not include people who are not switching.  Some modelers find it easier to always have each row add up to 1.0.  If you desire to do this, fill the diagonal with the difference between 1.0 and the sum of the other columns.  For example, to do this for product A, replace the top left cell with 1.0 – (0.01 + 0.03 + 0.05 + 0.001) = 0.909 [for you Beatles fans].

Read more…

, , ,

Modeling a Watershed with Arrays

September 15th, 2009

Karim Chichakly Modeling Tips

This is the second installment of a four-part series.  The other three parts can be accessed by clicking on the links below.
Methods for Using Arrays Effectively

Modeling Customers Switching Between Brands
Modeling Customers Switching Between Brands – The General Case

This is the second installment of a multipart series.  The first part can be found by clicking here. Part 3 is available here.

In the first post of this series, I showed how to conditionally pull information from an array.  In this post, I will extend this concept to show how to route information through an arrayed model.  This is especially useful in spatial modeling applications.

Routing Water Through a Watershed

A common ecology application is the modeling of a watershed.  Part of such a model will necessarily involve a network of stream or river segments – called reaches – which feed each other.  It is desirable to implement this in a way that makes it easy to modify the reach network.  Using an explicit stock-flow network makes this very difficult.  However, it is relatively straightforward to use arrays of stocks and flows to build an easily configurable network.

Imagine a small watershed broken down into reaches as shown below:

clip_image001[6]

For our purposes, a new reach will need to be created at every junction point.  Therefore, in this example and from a topological point-of-view, it is not strictly necessary to treat reach 4 separately from reach 2 nor reach 5 separately from reach 3, but reaches 2 and 3 must be separate from reach 1.  There are, of course, other reasons to separate reach 4 from 2 and reach 5 from 3, for example, slope, channel width, length, etc.

Every reach flows into exactly one other reach at its head, but many reaches can flow into the head of the same reach.  This requires a many-to-one representation of the reach network.  This is accomplished quite easily with a routing map which, for each reach, contains the number of the reach that this reach flows into.  We also need someway to signify the outlet.  Since reach numbers start at one, we can use zero to signify the outlet.  Using these rules, the above network is completely represented in the following routing map:

Reach Flows into
1 0
2 1
3 1
4 2
5 3

The nice thing about this representation is that it fits nicely into a one-dimensional array where the array index is the reach number and the reach it flows into is the value stored in that array element.

The model itself uses one stock to represent each reach.   That stock has one inflow for water entering the reach and one outflow for water leaving the reach: (Download the zipped STELLA model here)

image

Read more…

, , ,

Methods for Using Arrays Effectively, Part 1

September 7th, 2009

Karim Chichakly Modeling Tips

This is the first installment of a four-part series.  The remaining three parts can be accessed by clicking on the links below.
Modeling a Watershed with Arrays
Modeling Customers Switching Between Brands
Modeling Customers Switching Between Brands – The General Case

Using arrays can be quite intimidating for most people. Many times, it is difficult to discover the correct way to formulate a problem in terms of arrays, especially when trying to do so in terms of single equations that can be applied to all elements of the array.

Consider the case where you might wish to count the number of occurrences of a value in an array. This can arise in many applications that need to track attributes, but is prevalent in spatially-explicit business applications. In such an application, you may associate a product code with a location and then want a count of the products of a given type. The following examples demonstrate a common way to extract conditional information from an array.

Finding the Number of Stations with a Given Status

Imagine you have a two-dimensional grid of fire stations in a city, called Stations, that stores one of four statuses:

0: no station in this sector
1: ready
2: away on a call
3: refitting

You consider the number of fire stations ready at any given moment to be an important metric. To calculate this, connect Stations to another two-dimensional array of the same size called ready stations. This will have a one in an array element if the station for that quadrant is ready and a zero otherwise.  Its equation is:

IF Stations[Y, X] = 1 THEN 1 ELSE 0  { station ready? }

Note this equations uses dimension names (i.e., Stations[Y, X]) rather than element names (e.g., Stations[1, 2]). This allows you to create just one equation for the entire array (with “Apply to All” turned on), rather than a separate equation for each individual array element (with “Apply to All” turned off). When “Apply to All” is turned on, the equation for each element of the array is automatically generated by substituting that element’s dimensions for the dimension name in the given equation. All of the examples in this post use dimension names.

The total number of ready stations is now just the sum of all of the elements in the array ready stations.  This is easily calculated by connecting ready stations to a scalar converter named total ready stations that has the equation

ARRAYSUM(ready_stations[*, *])

The model is shown below and can be downloaded by clicking here.

image

This general method can be used anytime we need to count the number of elements in an array based on some condition.  First, create an array that has its elements set to one if the array-based condition is met and zero otherwise (IF condition THEN 1 ELSE 0).  Then create a converter to sum the elements of this new array (using ARRAYSUM).  Remember to turn “Apply to All” on and use dimension names in the condition rather than element names.

Read more…

, ,

Matrix Arithmetic

July 14th, 2009

Karim Chichakly Modeling Tips

iThink and STELLA support a variety of matrix operations. In this post, I will explain the following common operations and how to perform them:Matrix Cube

In the examples provided, I use five different arrays of varying dimensions. They are all defined using the subscript name Dim3, which is size 3.

a: 3×3
b: 3×3
c: 3×3
d: 3×1 [one-dimensional]
e: 3×1 [one-dimensional]

I also use two arrays based on Dim3, as well as the subscript name Dim2, which is size 2.

s: 2×3
t: 3×2

Read more…

, ,

Spatial Modeling with isee Spatial Map

April 15th, 2009

Karim Chichakly Modeling Tips

Editor’s Note: This is part 3 of a 3-part series on spatial modeling in iThink and STELLA. Part 1 is available here. Part 2 is available here.



Last time, we explored a two dimensional diffusion problem by looking at a metal plate with constant heat applied to the center. The model is available here: 2d-diffusion. The results, using isee Spatial Map, of the start (left) and end (right) of a six-minute simulation are shown below.

2d-element-results

I am frequently asked how to set up Spatial Map. isee Spatial Map is a simple program that can be used to display any dataset as a two dimensional grid with specific colors assigned to data ranges. Since it is stand-alone, iThink and STELLA communicate with it through the Export Data functionality. If you wish to plot simulation results in Spatial Map, you must first set up a persistent link to a CSV file. This persistent link is always going to be from a table that contains just one element of the array you wish to view in Spatial Map.

In this example, a table named “Temp Export Table” was created to export the temperature data. The first element, temperature[1, 1], was placed in the table. There is a subtlety here that cannot be overlooked. I wish to plot the values of the stock T as it varies over time. Yet I export a different variable named “temperature”. Why is this?

This is necessary because although stocks can be exported in the format Spatial Map expects, the export settings that are compatible with Spatial Map only export their initial values no matter where the simulation is. If we export T, we will only ever see the initial conditions in Spatial Map. Thus, when displaying a stock in Spatial Map, and we almost always do display stocks, it is necessary to create a converter that is set identically equal to the stock. The converter will export its current values, and since it is equal to the stock, the stock’s current values will be exported. The converter used for this purpose in this sample model is named “temperature”.

Next it is necessary to set up the persistent link. Choose Export Data… from the Edit menu. The Export Type should already be set to Persistent and Dynamic. Under Export Data Source, select “Export variables in table” and choose the table with the array element in it from the pop-up menu. In this case, that table is called “Temp Export Table”. Also select “One set of values” under Interval. This forces the data to be export in the format required by Spatial Map. These settings are shown below.

spatial-export

To finish setting up the export, choose the CSV file to export to and press OK. For this model, the file is named “2D Diffusion.csv”. Note that all of this has already been set up in the attached sample, so you will not be able to set it up again. You can examine the settings, though, by choosing Manage Persistent Links in the Edit menu and then pressing the Edit link at the end of the “Temp Export Data” line in the Export block.

The value of “temperature” will now be exported once at the start of each run and once at the end. If you wish to see the simulation unfold in Spatial Map, it will be necessary to set a Pause interval, as dynamic links are also exported every time the simulation pauses. Under Runs Specs… in the Run menu, you can see that I have set the Pause Interval to 20. This forces the Spatial Map to update every 20 seconds during the simulation run. This also forces the user to keep pressing Run to advance the simulation.

Read more…

, , , , ,

Spatial Modeling in Two Dimensions

April 7th, 2009

Karim Chichakly Modeling Tips

Editor’s Note:  This is part 2 of a 3-part series on spatial modeling in iThink and STELLA.  Part 1 is available here.  Part 3 is available here.



Last time, we explored spatial modeling using the one-dimensional diffusion problem as an example.  Many spatial applications, however, require two dimensional formulations.  As an extension, we will now explore the two-dimensional diffusion problem.  Instead of a one-meter metal bar with constant heat applied at its ends, the two-dimensional diffusion problem looks at the response of a one-meter by one-meter metal plate with constant heat applied to its center.  We then watch the heat diffuse across the plate.

At first blush, one might think the two-dimensional case is much more difficult than the one-dimensional case.  In particular, if a grid is superimposed over the plate, each finite element on the plate has eight neighbors, as shown below.  It is tempting, therefore, to consider radiating heat in each of these eight directions.

2d-radiation

However, without looking at the two-dimensional diffusion equations, if we consider just the physical layout of this system, the four corners of the finite element only touch the four corner neighbors (1, 3, 5, and 7) at one point.  In contrast, the four sides of the finite element are shared with each of its four immediate neighbors (2, 4, 6, and 8).  This suggests that heat only radiates to (and from) these four neighbors, not all eight.  In fact, if we examine the two-dimensional diffusion equation, we find that there are only component contributions in the x- and the y-directions.  There are no contributions on the diagonal (which would appear in the equation as ∂2u/∂xy and ∂2u/∂yx terms).

Intuitively, then, we have a finite element that is very similar to the one-dimensional case.  We only need to add corresponding flows in the y-direction.  This leads to the following model with the individual finite elements arrayed.

2d-element-model

The array T is now two-dimensional, in x and in y.  In addition, dx can differ from dy, so the diffusion constant C must be broken down into its constituent parts Cx = k/dx2 and Cy = k/dy2.  This leads to the following set of equations for the radiant flows through the plate:

in left = Cx*T[X - 1, Y]                               in top = Cy*T[X, Y - 1]
out left
= Cx*T[X, Y]                                  out top = Cy*T[X, Y]
out right
= Cx*T[X, Y]                              out bottom = Cy*T[X, Y]
in right
= Cx*T[X + 1, Y]                          in right = Cy*T[X, Y + 1]

X and Y are dimension names for the elements in the x- and ­y-directions, respectively.

Using isee Spatial Map, it is possible to view the results of this diffusion across two dimensions.  Spatial Map displays an array as a one-dimensional or two-dimensional grid (depending on the array).  Each cell in the grid is filled with a color corresponding to the value in the corresponding cell of the array.  Below are two spatial maps.  The one on the left shows the initial conditions of the metal plate.  Note that heat only appears in the center of the plate, where it is being externally applied.  The map on the right shows the distribution of heat across the plate at the end of a six-minute simulation.

2d-element-results

The model is available here:  2d-diffusion.  It is already configured to use isee Spatial Map.  In the final installment of this 3-part series, I will describe how to set up isee Spatial Map.

, , , , ,