Modeling with ModelRisk objects | Vose Software

# Modeling with ModelRisk objects

Objects are one of the most powerful, and unique, features of ModelRisk.

There are three types of random variables in ModelRisk: probability distributions; time series and copulas. For each type of random variable, there are in general the following type of functions. Using a Normal distribution as an example:

=VoseNormal(1,2) -  generating random samples in your spreadsheet from a Normal distribution with mean = 1, and standard deviation = 2

=VoseNormalObject(1,2) - is an object function, returning "VoseNormal(1,2)" in your spreadsheet. The function allows you to simply specify the distribution you wish to work with.

There are other functions used when fitting distributions (or time series or copulas) to data:

=VoseNormalFit( {data} ) -  generating random samples in your spreadsheet from a Normal distribution that has been fit to a set of values {data}

=VoseNormalFitObject( {data} ) -  is another object function, returning"VoseNormal(m,s)" in your spreadsheet, where m and s are the best-fitting parameter values for the distribution fit to {data}.

{=VoseNormalFitP( {data} )} -  an array function of length 2 that returns the parameters (mean and standard deviation) of a Normal distribution that has been fit to a set of values {data}

The two functions of interest here are:

=VoseNormalObject(1,2)

=VoseNormalFitObject( {data} )

Both are returning into the Excel cell essentially a text string like "VoseNormal(1,2)". These cells can then be used by a wide variety of simulation and calculation ModelRisk functions. For example, imagine that we are expecting 150 customers to come to our sale, and that each customer will spend \$Lognormal(200, 300). In ModelRisk we can input this information like this:

In older simulation tools, to work out what the total revenue will be from the sale, we would have to add up 150 separate samples from this Lognormal distribution. But with ModelRisk, we can use one function:

The VoseAggregateMC takes two parameters: the first is the number of items to be summed; and the second is the probability distribution (provided as an object) of the size of a random item. Clicking the View Fucntion icon in the ModelRisk ribbon for this cell opens the VoseAggregateMC interface:

The algorithm behind this function will sample 150 times from the specified Lognormal distribution and add those values together to give a result. Note that to do so, the function needed to know what the distribution was, not be provided with a random sample from that distribution.

## Why use ModelRisk objects?

Whenever a ModelRisk function takes a distribution as argument rather than a sampled value from it, this argument should be provided as a distribution object function.

For each distribution, time series and copula in ModelRisk, there is a corresponding Object and a Fit Object function available for further use as an argument in other ModelRisk functions. Both types behave the same, but have their parameters specified in a different way: Object functions are directly specified by their parameters, and Fit Object functions are specified by the array of data they are fitted to, and ModelRisk then determines parameter values that best fit the data.

There is a Distribution Object function for every distribution in ModelRisk, including custom distributions (e.g. VoseCombined, VoseDeduct, VoseRiskEvent, VoseAggregateFFT). So all of these can be used further as argument in other ModelRisk functions.

It makes logical sense to differ between a distribution as a whole, and a random value sampled from that distribution. It would be conceptually wrong and inconsistent to have the same function playing both roles.

Using distribution Objects also has the advantage that you can keep your distributional assumptions in once place in the model, making it easier to maintain and update (analogous to keep your constants in one place).

## Example: calculating moments of a distribution

Looking at a simple example, the sense of modeling with objects - in particular the fact that they are separate functions - becomes clear immediately. To sample random values from a Normal(0,1) distribution - for example when doing MC simulation - you would insert this formula in a spreadsheet cell:

=VoseNormal(0,1)

On the other hand, if you need the statistical moments of that same distribution in your model, you would use the VoseMoments function, as shown in the following spreadsheet:

## Example: determine the shortest lifetime of a large set of lights

Imagine that 5,400 lights have been installed at an airfield. You know that the lifetime of a random bulb follows a Weibull(3.1, 7200) hour distribution.

How long will it be before a light fails? The model below gives the answer. In Cell C3 is the function for the lifetime of a random light:

=VoseWeibull(3.1,7200)

Cell C5 simulates from the distribution of the smallest of 7200 such lifetimes by using the VoseSmallest function:

Selecting this cell and clicking the View Function icon on the ModelRisk ribbon shows the interface for this function:

One can see that although an individual light has a lifetime of around 6000 hours, the first light will fail after around 400 hours.

## Objects in Objects

ModelRisk also has a range of special functions that convert a distribution object into another object. For example:

VoseCombinedObject

VoseDeductObject

VoseAggregateFFTObject

##### Time series and copula objects

Similarly to distribution objects, ModelRisk has time series objects and copula objects. For time series or copulas fitted to data there are also FitObject functions. Use these to create an object for a copula or time series in one place, and then use the VoseTimeSimulate and VoseCopulaSimulate functions to generate random values.

Using these of course provides the same advantage as distribution Objects: they allow you to keep the assumptions about Time Series or Copula model in one place in the spreadsheet. Imagine having used a Clayton copula for modeling correlation all through your model, and deciding later on it is better to switch to a Gumbel. If you set up your model correctly, this should only require a change in one cell.