Difference between revisions of "Sensitivity analysis functions"

Line 22: Line 22:
 
|-
 
|-
 
! <code>fuelCost: </code>
 
! <code>fuelCost: </code>
! <code>gasPrice * mpy / mpg </code>
+
! <code>gasPrice*mpy/mpg </code>
 
| Annual cost of fuel
 
| Annual cost of fuel
 
|}
 
|}
The probability density of fuelCost is shown below.
+
The probability density of <code>fuelCost</code> is shown below.
  
 
[[File:Chapter16_4.png]]
 
[[File:Chapter16_4.png]]
  
 
==Dydx(y, x)==
 
==Dydx(y, x)==
Returns the derivative of expression y with respect to variable x, evaluated at mid values. This function returns the ratio of the change in y to a small change in x that affects y. The “small change” is , or 1.0E-6 if x= 0.
+
Returns the derivative of expression '''y''' with respect to variable '''x''', evaluated at mid values. This function returns the ratio of the change in y to a small change in '''x''' that affects '''y'''. The “small change” is ''x/10000'', or 1.0E-6 if <code>x</code> = 0.
  
 
'''Library:''' Special
 
'''Library:''' Special
  
'''Examples:''' Because fuelCost depends on mpg, a small change in mpg seems to have a modest negative
+
'''Examples:''' Because <code>fuelCost</code> depends on <code>mpg</code>, a small change in <code>mpg</code> seems to have a modest negative effect on <code>fuelCost</code>:
effect on fuelCost:
 
  
 
  Dydx(fuelCost, mpg) &rarr; -19.7
 
  Dydx(fuelCost, mpg) &rarr; -19.7
  
The reverse is not true, because mpg is not dependent on fuelCost. That is, fuelCost does
+
The reverse is not true, because <code>mpg</code> is not dependent on <code>fuelCost</code>. That is, <code>fuelCost</code> does not cause any change in <code>mpg</code>:
not cause any change in mpg:
 
  
 
  Dydx(Mpg, Fuelcost) &rarr; 0
 
  Dydx(Mpg, Fuelcost) &rarr; 0
  
In this model of fuelCost, a small change in gasPrice has by far the largest effect of all its
+
In this model of <code>fuelCost</code>, a small change in <code>gasPrice</code> has by far the largest effect of all its inputs:
inputs:
 
  
 
  Dydx(fuelCost, gasPrice) &rarr; 428.6
 
  Dydx(fuelCost, gasPrice) &rarr; 428.6
Dydx(fuelCost, mpy) &rarr; 0.04643
+
Dydx(fuelCost, mpy) &rarr; 0.04643
  
 
<tip title="Tip">
 
<tip title="Tip">
When you evaluate DyDx() in mid mode, the mid value for x is varied and the mid value of y is evaluated. In prob mode, the sample of x is varied and the sample for y is computed in prob mode. Therefore, when y is a statistical function of x, care must be taken to ensure that the evaluation modes for x and y correspond. So, for example:
+
When you evaluate '''[[Dydx]]()''' in mid mode, the mid value for '''x''' is varied and the mid value of '''y''' is evaluated. In prob mode, the sample of '''x''' is varied and the sample for '''y''' is computed in prob mode. Therefore, when '''y''' is a statistical function of '''x''', care must be taken to ensure that the evaluation modes for '''x''' and '''y''' correspond. So, for example:
  
 
  Y := DyDx(Kurtosis(Normal(0, X)), X)
 
  Y := DyDx(Kurtosis(Normal(0, X)), X)
  
would not produce the expected result. In this case, when evaluating y in determ mode, Kurtosis evaluates its parameter, and thus x, in prob mode, resulting in a mis-match in computation modes. To get the desired result, you should explicitly use the mid value of x:
+
would not produce the expected result. In this case, when evaluating '''y''' in determ mode, Kurtosis evaluates its parameter, and thus '''x''', in prob mode, resulting in a mis-match in computation modes. To get the desired result, you should explicitly use the mid value of '''x''':
  
 
  Y := DyDx(Kurtosis(Normal(0, Mid(X))), X)
 
  Y := DyDx(Kurtosis(Normal(0, Mid(X))), X)
Line 61: Line 58:
  
 
==Elasticity(y, x)==
 
==Elasticity(y, x)==
Returns the percent change in variable y caused by a 1 percent change in a dependent variable x. Mathematically, writing ''y(x)'' to emphasize that y is a function of x, elasticity is defined as:
+
Returns the percent change in variable '''y''' caused by a 1 percent change in a dependent variable '''x'''. Mathematically, writing ''y(x)'' to emphasize that '''y''' is a function of '''x''', elasticity is defined as:
  
 
<center><math>
 
<center><math>
Line 67: Line 64:
 
</math></center>
 
</math></center>
  
When x is a positive scalar, but not when x is array-valued, Elasticity() is related to Dydx() in the
+
When '''x''' is a positive scalar, but not when '''x''' is array-valued, '''[[Elasticity]]()''' is related to '''[[Dydx]]()''' in the following manner:
following manner:
 
  
 
  Elasticity(y, x) = Dydx(y, x)*(x/y)
 
  Elasticity(y, x) = Dydx(y, x)*(x/y)
Line 75: Line 71:
  
 
'''Examples:'''  
 
'''Examples:'''  
 +
 
<code>Elasticity(fuelCost, mpg) &rarr; -1</code>
 
<code>Elasticity(fuelCost, mpg) &rarr; -1</code>
<code>Elasticity(fuelCost, gasprice) &rarr; 1</code>
 
  
A 1% change in variables mpg and gasPrice cause about the same degree of change in fuelcost, although in opposite directions.
+
<code>Elasticity(fuelCost, gasPrice) &rarr; 1</code>
  
mpg is inversely proportional to the value of fuelCost, while gasPrice is proportional to it.
+
A 1% change in variables <code>mpg</code> and <code>gasPrice</code> cause about the same degree of change in <code>fuelCost</code>, although in opposite directions.
  
<tip title="Tip"> When you evaluate Elasticity() in determ (mid) mode, the mid value for x is varied and the mid value of y is evaluated. In prob mode, the sample of x is varied and the sample for y is computed in prob mode. Therefore, when y is a statistical function of x, care must be taken to ensure that the evaluation modes for x and y correspond.
+
<code>mpg</code> is inversely proportional to the value of <code>fuelCost</code>, while <code>gasPrice</code> is proportional to it.
 +
 
 +
<tip title="Tip"> When you evaluate '''[[Elasticity]]()''' in determ (mid) mode, the mid value for '''x''' is varied and the mid value of '''y''' is evaluated. In prob mode, the sample of '''x''' is varied and the sample for '''y''' is computed in prob mode. Therefore, when '''y''' is a statistical function of '''x''', care must be taken to ensure that the evaluation modes for '''x''' and '''y''' correspond.
 
</Tip>
 
</Tip>
  
 
==Whatif(e, v, vNew)==
 
==Whatif(e, v, vNew)==
Returns the value of expression e when variable v is set to the value of vNew. v must be a variable. It lets you explore the effect of a change to a value without changing it permanently. It restores the original definition of v after evaluating Whatif() expression, so that there is no permanent change (and so causes no side effects).
+
Returns the value of expression '''e''' when variable '''v''' is set to the value of '''vNew'''. '''v''' must be a variable. It lets you explore the effect of a change to a value without changing it permanently. It restores the original definition of '''v''' after evaluating '''[[Whatif]]()''' expression, so that there is no permanent change (and so causes no side effects).
  
 
'''Library:''' Special
 
'''Library:''' Special
  
 
'''Example:'''  
 
'''Example:'''  
 +
 
<code>Fuelcost &rarr; 557.1</code>
 
<code>Fuelcost &rarr; 557.1</code>
  
Line 96: Line 95:
  
 
==WhatIfAll(e, vList, vNew)==
 
==WhatIfAll(e, vList, vNew)==
Like Whatif, but it lets you examine a set of changes to a list of variables, vList. It returns the mid value of e when each of variables in vList is assigned the value in vNew one at a time, with the remaining variables remaining at their nominal values. The result is indexed by vList. If vNew is indexed by vList, it assigns the corresponding value of vNew to each variable, letting you assign a different value to each variable in vList. WhatIfAll() is useful for performing ceteris paribus style sensitivity analysis, which varies one variable at a time, leaving the others at their initial value, such as in Tornado charts (see next section for an example).
+
Like '''Whatif''', but it lets you examine a set of changes to a list of variables, '''vList'''. It returns the mid value of '''e''' when each of variables in '''vList''' is assigned the value in '''vNew''' one at a time, with the remaining variables remaining at their nominal values. The result is indexed by '''vList'''. If '''vNew''' is indexed by '''vList''', it assigns the corresponding value of '''vNew''' to each variable, letting you assign a different value to each variable in '''vList'''. '''[[WhatIfAll]]()''' is useful for performing ''ceteris paribus'' style sensitivity analysis, which varies one variable at a time, leaving the others at their initial value, such as in Tornado charts (see next section for an example).
  
 
Suppose Z is a function of A, B, and C, and we wish to examine the effect on Z when each input is varied, one at a time, by 10% from its nominal value. Define:
 
Suppose Z is a function of A, B, and C, and we wish to examine the effect on Z when each input is varied, one at a time, by 10% from its nominal value. Define:
Line 106: Line 105:
  
 
'''Library:''' Special
 
'''Library:''' Special
 +
 
==See Also==
 
==See Also==
 +
* [[Dydx]]()
 +
* [[Elasticity]]()
 +
* [[Whatif]]()
 +
* [[WhatIfAll]]()
 +
 +
 
<footer>Importance analysis / {{PAGENAME}} / Tornado charts</footer>
 
<footer>Importance analysis / {{PAGENAME}} / Tornado charts</footer>

Revision as of 02:12, 18 December 2015

Sensitivity analysis enables you to examine the effect of a change in the value of an input variable on the values of its output variables. They do not require their parameters to be uncertain.

Examples: The examples in this section refer to the following variables:

gasPrice Normal(1.3, .3) Cost of gasoline per gallon within market fluctuations
mpy: 12K The average number of miles driven per year
mpg: Normal(28, 5) Fuel consumption averaged over driving conditions
fuelCost: gasPrice*mpy/mpg Annual cost of fuel

The probability density of fuelCost is shown below.

Chapter16 4.png

Dydx(y, x)

Returns the derivative of expression y with respect to variable x, evaluated at mid values. This function returns the ratio of the change in y to a small change in x that affects y. The “small change” is x/10000, or 1.0E-6 if x = 0.

Library: Special

Examples: Because fuelCost depends on mpg, a small change in mpg seems to have a modest negative effect on fuelCost:

Dydx(fuelCost, mpg) → -19.7

The reverse is not true, because mpg is not dependent on fuelCost. That is, fuelCost does not cause any change in mpg:

Dydx(Mpg, Fuelcost) → 0

In this model of fuelCost, a small change in gasPrice has by far the largest effect of all its inputs:

Dydx(fuelCost, gasPrice) → 428.6
Dydx(fuelCost, mpy) → 0.04643
Tip

When you evaluate Dydx() in mid mode, the mid value for x is varied and the mid value of y is evaluated. In prob mode, the sample of x is varied and the sample for y is computed in prob mode. Therefore, when y is a statistical function of x, care must be taken to ensure that the evaluation modes for x and y correspond. So, for example:

Y := DyDx(Kurtosis(Normal(0, X)), X)

would not produce the expected result. In this case, when evaluating y in determ mode, Kurtosis evaluates its parameter, and thus x, in prob mode, resulting in a mis-match in computation modes. To get the desired result, you should explicitly use the mid value of x:

Y := DyDx(Kurtosis(Normal(0, Mid(X))), X)

Elasticity(y, x)

Returns the percent change in variable y caused by a 1 percent change in a dependent variable x. Mathematically, writing y(x) to emphasize that y is a function of x, elasticity is defined as:

[math]\displaystyle{ Elasticity(y,x)=\lim_{u \to 0} \frac{1}{u} (\frac{y(x(1+u))-y(x)}{y(x)}) }[/math]

When x is a positive scalar, but not when x is array-valued, Elasticity() is related to Dydx() in the following manner:

Elasticity(y, x) = Dydx(y, x)*(x/y)

Library: Special

Examples:

Elasticity(fuelCost, mpg) → -1

Elasticity(fuelCost, gasPrice) → 1

A 1% change in variables mpg and gasPrice cause about the same degree of change in fuelCost, although in opposite directions.

mpg is inversely proportional to the value of fuelCost, while gasPrice is proportional to it.

Tip
When you evaluate Elasticity() in determ (mid) mode, the mid value for x is varied and the mid value of y is evaluated. In prob mode, the sample of x is varied and the sample for y is computed in prob mode. Therefore, when y is a statistical function of x, care must be taken to ensure that the evaluation modes for x and y correspond.

Whatif(e, v, vNew)

Returns the value of expression e when variable v is set to the value of vNew. v must be a variable. It lets you explore the effect of a change to a value without changing it permanently. It restores the original definition of v after evaluating Whatif() expression, so that there is no permanent change (and so causes no side effects).

Library: Special

Example:

Fuelcost → 557.1

Whatif(Fuelcost, Mpy, 14K) → 650

WhatIfAll(e, vList, vNew)

Like Whatif, but it lets you examine a set of changes to a list of variables, vList. It returns the mid value of e when each of variables in vList is assigned the value in vNew one at a time, with the remaining variables remaining at their nominal values. The result is indexed by vList. If vNew is indexed by vList, it assigns the corresponding value of vNew to each variable, letting you assign a different value to each variable in vList. WhatIfAll() is useful for performing ceteris paribus style sensitivity analysis, which varies one variable at a time, leaving the others at their initial value, such as in Tornado charts (see next section for an example).

Suppose Z is a function of A, B, and C, and we wish to examine the effect on Z when each input is varied, one at a time, by 10% from its nominal value. Define:

Variable Z := 10*A + B^2 + 5*C
Index L := [90%, 110%]
Variable V := [A, B, C]
MyTornado := WhatIfAll(Z, V, L*V)

Library: Special

See Also


Comments


You are not allowed to post comments.