 <?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.analytica.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=JHernandez2</id>
	<title>Analytica Docs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.analytica.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=JHernandez2"/>
	<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php/Special:Contributions/JHernandez2"/>
	<updated>2026-06-10T02:26:15Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.9</generator>
	<entry>
		<id>https://docs.analytica.com/index.php?title=User:Karenlee&amp;diff=36595</id>
		<title>User:Karenlee</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=User:Karenlee&amp;diff=36595"/>
		<updated>2015-11-06T19:12:53Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a page where I put things that I am testing. Look, I've even added some changes. EVEN MORE CHANGES. Here is some text for testing. &amp;lt;languages&amp;gt;&amp;lt;/languages&amp;gt;&lt;br /&gt;
==Header Breadcrumbs== &amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
Hand coded header tests update&lt;br /&gt;
{| style=&amp;quot;margin: 1em auto 1em auto;width: 100%;border:0;table-layout: fixed;&amp;quot; cellpadding=5&lt;br /&gt;
||  [[ADE User Guide]] ► [[ADE Server Class Reference]] ►  {{PAGENAME}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
Breadcrumb tag header tests &lt;br /&gt;
&amp;lt;breadcrumbs&amp;gt; 1 &amp;gt; 2 &amp;gt; 2.5 &amp;gt; 3&amp;gt; {{PAGENAME}}&amp;lt;/breadcrumbs&amp;gt;&lt;br /&gt;
&amp;lt;breadcrumbs&amp;gt; ADE User Guide &amp;gt; 1 &amp;gt; {{PAGENAME}}&amp;lt;/breadcrumbs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Footer Formatting== &amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
Hand coded footer&lt;br /&gt;
{| style=&amp;quot;margin: 1em auto 1em auto;width: 100%;border:0;table-layout: fixed;&amp;quot; cellpadding=5&lt;br /&gt;
| style=&amp;quot;text-align: right;&amp;quot; | [[Number formats]]&lt;br /&gt;
| style=&amp;quot;text-align: center; width:50px;&amp;quot;  | ◄&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; | {{PAGENAME}}&lt;br /&gt;
| style=&amp;quot;text-align: center;width:50px;&amp;quot; | ►&lt;br /&gt;
| style=&amp;quot;text-align: left;&amp;quot; | [[Display of constraint results]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
Footer tag&lt;br /&gt;
&amp;lt;footer&amp;gt;Number formats / {{PAGENAME}} / Next&amp;lt;/footer&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Table Test Formatting= &amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt; &amp;lt;/nowiki&amp;gt;These are test formats for some tables.&lt;br /&gt;
&lt;br /&gt;
==On Top== &amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;MDTable(T,Rows,Cols,[Car_type,Mpg],'average','n/a')&amp;lt;/tt&amp;gt; &amp;amp;rarr;&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;3&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Mpg &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:100px;&amp;quot; |'''Car_type &amp;amp;#9660; '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''26            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''30             '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''35           '''&lt;br /&gt;
|-&lt;br /&gt;
!'''VW''' &lt;br /&gt;
| | 2185 &lt;br /&gt;
| |1705 &lt;br /&gt;
|n/a&lt;br /&gt;
|-&lt;br /&gt;
!'''Honda '''&lt;br /&gt;
||2330 &lt;br /&gt;
||n/a &lt;br /&gt;
| |2210&lt;br /&gt;
|-&lt;br /&gt;
!'''BMW''' &lt;br /&gt;
|n/a &lt;br /&gt;
||2955 &lt;br /&gt;
||2835&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;tt&amp;gt;MDTable(T,Rows,Cols,[Car_type,Mpg],'average','n/a')&amp;lt;/tt&amp;gt; &amp;amp;rarr;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! !! colspan=&amp;quot;3&amp;quot; | Mpg &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
|'''Car_type &amp;amp;#9660;'''&lt;br /&gt;
|'''26'''&lt;br /&gt;
|'''30'''&lt;br /&gt;
|'''35'''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
|2185&lt;br /&gt;
|1705&lt;br /&gt;
|n/a&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2330&lt;br /&gt;
|n/a&lt;br /&gt;
|2210&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|n/a&lt;br /&gt;
|2955&lt;br /&gt;
|2835&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==On the Left==&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot;&lt;br /&gt;
|&amp;lt;tt&amp;gt;MDTable(T,Rows,Cols,[Car_type,Mpg],'average','n/a')&amp;lt;/tt&amp;gt; &amp;amp;rarr; ||&lt;br /&gt;
|&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! !! colspan=&amp;quot;3&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Mpg &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:125px;&amp;quot; | '''Car_type''' &amp;amp;#9660; &lt;br /&gt;
| style=&amp;quot;width:75px;&amp;quot; | '''26'''&lt;br /&gt;
| style=&amp;quot;width:75px;&amp;quot; | '''30'''&lt;br /&gt;
| style=&amp;quot;width:75px;&amp;quot; | '''35'''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW''' &lt;br /&gt;
|| 2185 ||1705 ||n/a&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda '''&lt;br /&gt;
||2330 ||n/a ||2210&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW''' &lt;br /&gt;
||n/a ||2955 ||2835&lt;br /&gt;
|}&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36591</id>
		<title>Analytica Optimizer Guide</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36591"/>
		<updated>2015-11-06T17:00:25Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This Guide explains how to use the Analytica Optimizer, which enhances Analytica with powerful functions for finding optimal decisions and solving difficult equations.[[Category: Analytica Optimizer Guide]]&lt;br /&gt;
&lt;br /&gt;
= Table of Contents =&lt;br /&gt;
# [[Introduction]]&lt;br /&gt;
#* Using the Analytica Optimizer Guide&lt;br /&gt;
#* Obtaining Analytica Optimizer&lt;br /&gt;
#* Activating Analytica Optimizer&lt;br /&gt;
#* Installing Add-On Engines to Analytica Optimizer&lt;br /&gt;
# Quick Start&lt;br /&gt;
#* Intro to Structured Optimization&lt;br /&gt;
#* Notation&lt;br /&gt;
#* The Optimum Can Example&lt;br /&gt;
#** Decisions&lt;br /&gt;
#** Constants&lt;br /&gt;
#** Variables&lt;br /&gt;
#** Constraints&lt;br /&gt;
#** Objectives&lt;br /&gt;
#** The DefineOptimization() function&lt;br /&gt;
#** Viewing the Optimization Object&lt;br /&gt;
#** Obtaining the Solution&lt;br /&gt;
#** Obtaining the Optimized Objective Value&lt;br /&gt;
#** Viewing Optimization Status&lt;br /&gt;
#** Copying Optimized Results to Definitions&lt;br /&gt;
#** Changing Variable Types (Domain)&lt;br /&gt;
#** Setting Bounds on Decision Values&lt;br /&gt;
#** Using Parametric Analysis with Optimization&lt;br /&gt;
#** The Initial Guess Attribute&lt;br /&gt;
#* Summary&lt;br /&gt;
# Optimization Characteristics&lt;br /&gt;
#* Introduction&lt;br /&gt;
#* Parts of an Optimization Problem: General Description&lt;br /&gt;
#* Identifying the Type of Optimization&lt;br /&gt;
#* Specific Optimization Characteristics&lt;br /&gt;
#* Continuous, Integer and Mixed-Integer Programs&lt;br /&gt;
#* Solving Simultaneous Equations&lt;br /&gt;
# Optimizing with Arrays&lt;br /&gt;
# Key Concepts: The Airline NLP Example&lt;br /&gt;
# Optimizer Attribute Reference&lt;br /&gt;
# Optimizer Function Reference&lt;br /&gt;
# Control Settings&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Poisson_distribution&amp;diff=36590</id>
		<title>Poisson distribution</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Poisson_distribution&amp;diff=36590"/>
		<updated>2015-11-06T16:59:15Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: /* Details */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[category:Distribution Functions]]&lt;br /&gt;
[[Category:Doc Status D]] &amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Poisson(mean) =&lt;br /&gt;
&lt;br /&gt;
The ''Poisson'' distribution represents the number of independent discrete random events that occur in a fixed period of time.  The parameter ''mean'' specifies the expected number of events in one time unit. &lt;br /&gt;
&lt;br /&gt;
You might use the ''Poisson'' distribution to model the number of sales per month of a low-volume product, or the number of airplane crashes per year.  Poisson is occassionally applied to non-time intervals, such as the number of cancerous cells in a given (small) volume of tissue, or the number of mutations in a given length of DNA.&lt;br /&gt;
&lt;br /&gt;
The ''poisson'' distribution assumes that each event occurs randomly and independently of all other events.  When the number of events follows a '''Poisson(mean:m)''' distribution, then the time between individual events follows an ''[[Exponential]](rate:1/m)'' distribution.&lt;br /&gt;
&lt;br /&gt;
= Details =&lt;br /&gt;
&lt;br /&gt;
The [[Variance|variance]] of a '''Poisson(mean:m)''' distribution is ''m'', the standard deviation is ''sqrt(m)'', the [[Skewness|skewness]] is ''1/sqrt(m)'' and the [[Kurtosis|kurtosis]] is ''1/m''.  The probability density is given by&lt;br /&gt;
&lt;br /&gt;
 P(k|m) = [[Exp]](-m) * mean^k / [[Factorial]](k)&lt;br /&gt;
&lt;br /&gt;
The cumulative probability for integer k&amp;gt;0 is:&lt;br /&gt;
&lt;br /&gt;
 F(k|m) = [[GammaFn]]( k+1,mean ) / [[Factorial]](k)&lt;br /&gt;
&lt;br /&gt;
These are computed by the [[Prob_Poisson]] and [[CumPoisson]] functions. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For large ''mean'' values, the ''Poisson(m)'' distribution approaches a [[Round]]([[Normal]](m,[[Sqrt]](m)))distribution.  This approximation is extremely close for m&amp;gt;50 and pretty close for m&amp;gt;10.  Of course, the [[Normal]] is a continuous distribution and the ''Poisson'' a discrete, hence a [[Round]] function is shown.&lt;br /&gt;
&lt;br /&gt;
= Parameter Estimation =&lt;br /&gt;
&lt;br /&gt;
Suppose you have historical data, ''Data'', indexed by ''I'', in the form of a positive count at each measurement, and you wish to estimate the parameter for the best-fit Poisson distribution.  The parameter can be estimated using:&lt;br /&gt;
:[[Mean]](Data,I)&lt;br /&gt;
&lt;br /&gt;
= Positive Poisson distribution =&lt;br /&gt;
&lt;br /&gt;
The Positive Poisson Distribution, also known as the '''Zero-Truncated Poisson (ZTP) distribution''' and the '''conditional Poisson distribution''', is the distribution obtained by conditioning on the constraint that the value is not zero. Hence, the sample consists of the positive integers.&lt;br /&gt;
&lt;br /&gt;
To generate a sample from the Positive Poisson distribution, using the pre-truncated mean &amp;lt;code&amp;gt;m&amp;lt;/code&amp;gt;, use the following expression&lt;br /&gt;
:&amp;lt;code&amp;gt;[[Poisson]]( m + [[Ln]](1 - [[Uniform]](0,1)*(1 - [[Exp]](-m)) ) ) + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
&lt;br /&gt;
* [[Prob_Poisson]](x,mean)&lt;br /&gt;
* [[CumPoisson]](x,mean)&lt;br /&gt;
* [[Exponential]](rate)&lt;br /&gt;
* [[Binomial]](n,p)&lt;br /&gt;
* [[NegativeBinomial]](r,p)&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36588</id>
		<title>Analytica Optimizer Guide</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36588"/>
		<updated>2015-11-06T03:43:25Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This Guide explains how to use the Analytica Optimizer, which enhances Analytica with powerful functions for finding optimal decisions and solving difficult equations.[[Category: Analytica Optimizer Guide]]&lt;br /&gt;
&lt;br /&gt;
= Table of Contents =&lt;br /&gt;
# [[Introduction]]&lt;br /&gt;
#* Using the Analytica Optimizer Guide&lt;br /&gt;
#* Obtaining Analytica Optimizer&lt;br /&gt;
#* Activating Analytica Optimizer&lt;br /&gt;
#* Installing Add-On Engines to Analytica Optimizer&lt;br /&gt;
# Quick Start&lt;br /&gt;
#* Intro to Structured Optimization&lt;br /&gt;
#* Notation&lt;br /&gt;
#* The Optimum Can Example&lt;br /&gt;
#** Decisions&lt;br /&gt;
#** Constants&lt;br /&gt;
#** Variables&lt;br /&gt;
#** Constraints&lt;br /&gt;
#** Objectives&lt;br /&gt;
#** The DefineOptimization() Function&lt;br /&gt;
#** Viewing the Optimization Object&lt;br /&gt;
#** Obtaining the Solution&lt;br /&gt;
#** Obtaining the Optimized Objective Value&lt;br /&gt;
#** Viewing Optimization Status&lt;br /&gt;
#** Copying Optimized Results to Definitions&lt;br /&gt;
#** Changing Variable Types (Domain)&lt;br /&gt;
#** Setting Bounds on Decision Values&lt;br /&gt;
#** Using Parametric Analysis with Optimization&lt;br /&gt;
#** The Initial Guess Attribute&lt;br /&gt;
#* Summary&lt;br /&gt;
# Optimization Characteristics&lt;br /&gt;
#* Introduction&lt;br /&gt;
#* Parts of an Optimization Problem: General Description&lt;br /&gt;
#* Identifying the Type of Optimization&lt;br /&gt;
#* Specific Optimization Characteristics&lt;br /&gt;
#* Continuous, Integer and Mixed-Integer Programs&lt;br /&gt;
#* Solving Simultaneous Equations&lt;br /&gt;
# Optimizing with Arrays&lt;br /&gt;
# Key Concepts: The Airline NLP Example&lt;br /&gt;
# Optimizer Attribute Reference&lt;br /&gt;
# Optimizer Function Reference&lt;br /&gt;
# Control Settings&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36587</id>
		<title>Analytica Optimizer Guide</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36587"/>
		<updated>2015-11-06T03:38:54Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category: Analytica Optimizer Guide]]&lt;br /&gt;
&lt;br /&gt;
= Table of Contents =&lt;br /&gt;
# Introduction&lt;br /&gt;
#* Using the Analytica Optimizer Guide&lt;br /&gt;
#* Obtaining Analytica Optimizer&lt;br /&gt;
#* Activating Analytica Optimizer&lt;br /&gt;
#* Installing Add-On Engines to Analytica Optimizer&lt;br /&gt;
# Quick Start&lt;br /&gt;
#* Intro to Structured Optimization&lt;br /&gt;
#* Notation&lt;br /&gt;
#* The Optimum Can Example&lt;br /&gt;
#** Decisions&lt;br /&gt;
#** Constants&lt;br /&gt;
#** Variables&lt;br /&gt;
#** Constraints&lt;br /&gt;
#** Objectives&lt;br /&gt;
#** The DefineOptimization() Function&lt;br /&gt;
#** Viewing the Optimization Object&lt;br /&gt;
#** Obtaining the Solution&lt;br /&gt;
#** Obtaining the Optimized Objective Value&lt;br /&gt;
#** Viewing Optimization Status&lt;br /&gt;
#** Copying Optimized Results to Definitions&lt;br /&gt;
#** Changing Variable Types (Domain)&lt;br /&gt;
#** Setting Bounds on Decision Values&lt;br /&gt;
#** Using Parametric Analysis with Optimization&lt;br /&gt;
#** The Initial Guess Attribute&lt;br /&gt;
#* Summary&lt;br /&gt;
# Optimization Characteristics&lt;br /&gt;
#* Introduction&lt;br /&gt;
#* Parts of an Optimization Problem: General Description&lt;br /&gt;
#* Identifying the Type of Optimization&lt;br /&gt;
#* Specific Optimization Characteristics&lt;br /&gt;
#* Continuous, Integer and Mixed-Integer Programs&lt;br /&gt;
#* Solving Simultaneous Equations&lt;br /&gt;
# Optimizing with Arrays&lt;br /&gt;
# Key Concepts: The Airline NLP Example&lt;br /&gt;
# Optimizer Attribute Reference&lt;br /&gt;
# Optimizer Function Reference&lt;br /&gt;
# Control Settings&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36586</id>
		<title>Analytica Optimizer Guide</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36586"/>
		<updated>2015-11-06T03:37:33Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category: Analytica Optimizer Guide]]&lt;br /&gt;
&amp;lt;breadcrumbs&amp;gt; Analytica Optimizer Guide &amp;gt; Table of Contents&amp;lt;/breadcrumbs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Table of Contents =&lt;br /&gt;
# Introduction&lt;br /&gt;
#* Using the Analytica Optimizer Guide&lt;br /&gt;
#* Obtaining Analytica Optimizer&lt;br /&gt;
#* Activating Analytica Optimizer&lt;br /&gt;
#* Installing Add-On Engines to Analytica Optimizer&lt;br /&gt;
# Quick Start&lt;br /&gt;
#* Intro to Structured Optimization&lt;br /&gt;
#* Notation&lt;br /&gt;
#* The Optimum Can Example&lt;br /&gt;
#** Decisions&lt;br /&gt;
#** Constants&lt;br /&gt;
#** Variables&lt;br /&gt;
#** Constraints&lt;br /&gt;
#** Objectives&lt;br /&gt;
#** The DefineOptimization() Function&lt;br /&gt;
#** Viewing the Optimization Object&lt;br /&gt;
#** Obtaining the Solution&lt;br /&gt;
#** Obtaining the Optimized Objective Value&lt;br /&gt;
#** Viewing Optimization Status&lt;br /&gt;
#** Copying Optimized Results to Definitions&lt;br /&gt;
#** Changing Variable Types (Domain)&lt;br /&gt;
#** Setting Bounds on Decision Values&lt;br /&gt;
#** Using Parametric Analysis with Optimization&lt;br /&gt;
#** The Initial Guess Attribute&lt;br /&gt;
#* Summary&lt;br /&gt;
# Optimization Characteristics&lt;br /&gt;
#* Introduction&lt;br /&gt;
#* Parts of an Optimization Problem: General Description&lt;br /&gt;
#* Identifying the Type of Optimization&lt;br /&gt;
#* Specific Optimization Characteristics&lt;br /&gt;
#* Continuous, Integer and Mixed-Integer Programs&lt;br /&gt;
#* Solving Simultaneous Equations&lt;br /&gt;
# Optimizing with Arrays&lt;br /&gt;
# Key Concepts: The Airline NLP Example&lt;br /&gt;
# Optimizer Attribute Reference&lt;br /&gt;
# Optimizer Function Reference&lt;br /&gt;
# Control Settings&lt;br /&gt;
&lt;br /&gt;
&amp;lt;footer&amp;gt; {{PAGENAME}} &amp;lt;/footer&amp;gt;&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36585</id>
		<title>Analytica Optimizer Guide</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36585"/>
		<updated>2015-11-06T03:21:23Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: /* Table of Contents */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Table of Contents =&lt;br /&gt;
# Introduction&lt;br /&gt;
#* Using the Analytica Optimizer Guide&lt;br /&gt;
#* Obtaining Analytica Optimizer&lt;br /&gt;
#* Activating Analytica Optimizer&lt;br /&gt;
#* Installing Add-On Engines to Analytica Optimizer&lt;br /&gt;
# Quick Start&lt;br /&gt;
#* Intro to Structured Optimization&lt;br /&gt;
#* Notation&lt;br /&gt;
#* The Optimum Can Example&lt;br /&gt;
#** Decisions&lt;br /&gt;
#** Constants&lt;br /&gt;
#** Variables&lt;br /&gt;
#** Constraints&lt;br /&gt;
#** Objectives&lt;br /&gt;
#** The DefineOptimization() Function&lt;br /&gt;
#** Viewing the Optimization Object&lt;br /&gt;
#** Obtaining the Solution&lt;br /&gt;
#** Obtaining the Optimized Objective Value&lt;br /&gt;
#** Viewing Optimization Status&lt;br /&gt;
#** Copying Optimized Results to Definitions&lt;br /&gt;
#** Changing Variable Types (Domain)&lt;br /&gt;
#** Setting Bounds on Decision Values&lt;br /&gt;
#** Using Parametric Analysis with Optimization&lt;br /&gt;
#** The Initial Guess Attribute&lt;br /&gt;
#* Summary&lt;br /&gt;
# Optimization Characteristics&lt;br /&gt;
#* Introduction&lt;br /&gt;
#* Parts of an Optimization Problem: General Description&lt;br /&gt;
#* Identifying the Type of Optimization&lt;br /&gt;
#* Specific Optimization Characteristics&lt;br /&gt;
#* Continuous, Integer and Mixed-Integer Programs&lt;br /&gt;
#* Solving Simultaneous Equations&lt;br /&gt;
# Optimizing with Arrays&lt;br /&gt;
# Key Concepts: The Airline NLP Example&lt;br /&gt;
# Optimizer Attribute Reference&lt;br /&gt;
# Optimizer Function Reference&lt;br /&gt;
# Control Settings&lt;br /&gt;
&amp;lt;!--==Introduction==&lt;br /&gt;
==== What is the Analytica Optimizer? ====&lt;br /&gt;
&lt;br /&gt;
===== Types of Optimization =====&lt;br /&gt;
&lt;br /&gt;
===== Premium Solver Specifications =====&lt;br /&gt;
&lt;br /&gt;
===== Optimize with Uncertain Values and Intelligent Arrays =====&lt;br /&gt;
&lt;br /&gt;
===== Compatibility with Other Analytica Editors =====&lt;br /&gt;
&lt;br /&gt;
==== Obtaining the Analytica Optimizer ====&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36584</id>
		<title>Analytica Optimizer Guide</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36584"/>
		<updated>2015-11-06T03:20:09Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Table of Contents ===&lt;br /&gt;
# Introduction&lt;br /&gt;
#* Using the Analytica Optimizer Guide&lt;br /&gt;
#* Obtaining Analytica Optimizer&lt;br /&gt;
#* Activating Analytica Optimizer&lt;br /&gt;
#* Installing Add-On Engines to Analytica Optimizer&lt;br /&gt;
# Quick Start&lt;br /&gt;
#* Intro to Structured Optimization&lt;br /&gt;
#* Notation&lt;br /&gt;
#* The Optimum Can Example&lt;br /&gt;
#** Decisions&lt;br /&gt;
#** Constants&lt;br /&gt;
#** Variables&lt;br /&gt;
#** Constraints&lt;br /&gt;
#** Objectives&lt;br /&gt;
#** The DefineOptimization() Function&lt;br /&gt;
#** Viewing the Optimization Object&lt;br /&gt;
#** Obtaining the Solution&lt;br /&gt;
#** Obtaining the Optimized Objective Value&lt;br /&gt;
#** Viewing Optimization Status&lt;br /&gt;
#** Copying Optimized Results to Definitions&lt;br /&gt;
#** Changing Variable Types (Domain)&lt;br /&gt;
#** Setting Bounds on Decision Values&lt;br /&gt;
#** Using Parametric Analysis with Optimization&lt;br /&gt;
#** The Initial Guess Attribute&lt;br /&gt;
#* Summary&lt;br /&gt;
# Optimization Characteristics&lt;br /&gt;
#* Introduction&lt;br /&gt;
#* Parts of an Optimization Problem: General Description&lt;br /&gt;
#* Identifying the Type of Optimization&lt;br /&gt;
#* Specific Optimization Characteristics&lt;br /&gt;
#* Continuous, Integer and Mixed-Integer Programs&lt;br /&gt;
#* Solving Simultaneous Equations&lt;br /&gt;
# Optimizing with Arrays&lt;br /&gt;
# Key Concepts: The Airline NLP Example&lt;br /&gt;
# Optimizer Attribute Reference&lt;br /&gt;
# Optimizer Function Reference&lt;br /&gt;
# Control Settings&lt;br /&gt;
&amp;lt;!--==Introduction==&lt;br /&gt;
==== What is the Analytica Optimizer? ====&lt;br /&gt;
&lt;br /&gt;
===== Types of Optimization =====&lt;br /&gt;
&lt;br /&gt;
===== Premium Solver Specifications =====&lt;br /&gt;
&lt;br /&gt;
===== Optimize with Uncertain Values and Intelligent Arrays =====&lt;br /&gt;
&lt;br /&gt;
===== Compatibility with Other Analytica Editors =====&lt;br /&gt;
&lt;br /&gt;
==== Obtaining the Analytica Optimizer ====&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36583</id>
		<title>Analytica Optimizer Guide</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36583"/>
		<updated>2015-11-06T03:16:32Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Table of Contents ===&lt;br /&gt;
# Introduction&lt;br /&gt;
#* Using the Analytica Optimizer Guide&lt;br /&gt;
#* Obtaining Analytica Optimizer&lt;br /&gt;
#* Activating Analytica Optimizer&lt;br /&gt;
#* Installing Add-On Engines to Analytica Optimizer&lt;br /&gt;
# Quick Start&lt;br /&gt;
#* Intro to Structured Optimization&lt;br /&gt;
#* Notation&lt;br /&gt;
#* The Optimum Can Example&lt;br /&gt;
#** Decisions&lt;br /&gt;
#** Constants&lt;br /&gt;
#** Variables&lt;br /&gt;
#** Constraints&lt;br /&gt;
#** Objectives&lt;br /&gt;
#** The DefineOptimization() Function&lt;br /&gt;
#** Viewing the Optimization Object&lt;br /&gt;
#** Obtaining the Solution&lt;br /&gt;
#** Obtaining the Optimized Objective Value&lt;br /&gt;
#** Viewing Optimization Status&lt;br /&gt;
#** Copying Optimized Results to Definitions&lt;br /&gt;
#** Changing Variable Types (Domain)&lt;br /&gt;
#** Setting Bounds on Decision Values&lt;br /&gt;
#** Using Parametric Analysis with Optimization&lt;br /&gt;
#** The Initial Guess Attribute&lt;br /&gt;
#* Summary&lt;br /&gt;
# Optimization Characteristics&lt;br /&gt;
#* Introduction&lt;br /&gt;
#* Parts of an Optimization Problem: General Description&lt;br /&gt;
#* Identifying the Type of Optimization&lt;br /&gt;
#* Specific Optimization Characteristics&lt;br /&gt;
#* Continuous, Integer and Mixed-Integer Programs&lt;br /&gt;
#* Solving Simultaneous Equations&lt;br /&gt;
# Optimizing with Arrays&lt;br /&gt;
# Key Concepts: The Airline NLP Example&lt;br /&gt;
# Optimizer Attribute Reference&lt;br /&gt;
# Optimizer Function Reference&lt;br /&gt;
# Control Settings&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
This Guide explains how to use the Analytica Optimizer, which enhances Analytica 4.6 with powerful functions for finding optimal decisions and solving difficult equations.&lt;br /&gt;
&lt;br /&gt;
It provides a Quick Start Tutorial in Chapter 1 and an introduction to the basic concepts of optimization, including linear, quadratic, and nonlinear programming in Chapter 2. Special topics for NLPs are also covered in Chapter 4. But, it's not a complete textbook on optimization. You might find it useful, especially for more challenging applications, to consult one of the many good textbooks on optimization.&lt;br /&gt;
&lt;br /&gt;
'''If you're new to Analytica'''&lt;br /&gt;
&lt;br /&gt;
You will find it easier if you first learn the essentials of Analytica before learning the Analytica Optimizer described here. Start with the Analytica Tutorial to learn the basics of interacting with Analytica and its modeling language, especially Chapter 5, Working with Arrays. It's important to have a good understanding of Intelligent Arrays to make good use of the Optimizer.&lt;br /&gt;
&lt;br /&gt;
'''If you're new to the Analytica Optimizer''' &lt;br /&gt;
&lt;br /&gt;
We suggest you start with Chapter 1, Quick Start, an introductory tutorial that takes you through the key steps to create a simple optimization. &lt;br /&gt;
Then you should go on to Chapter 2, Optimization characteristics, which explains the general principles of optimization and the types of optimization, including Linear Programming (LP), Quadratic Programming (QP), and Non-Linear Programming (NLP). We also recommend Chapter 3, Optimizing with Arrays to master optimization with parametric analysis. Chapter 4 explains how to use optimization in models having dynamic influences and Monte Carlo-based uncertainties.&lt;br /&gt;
&lt;br /&gt;
'''If you've used Analytica Optimizer 4.2 or earlier'''&lt;br /&gt;
&lt;br /&gt;
The 4.3 release of Analytica introduced Structured Optimization, a new set of features that eliminates many difficult steps previously required for structuring optimizations in Analytica. For example, it can use a set of decision variables of varying dimensions, instead of requiring you to combine and flatten them manually. It introduces Constraints as a new object class. It can discover automatically whether your objective is linear, quadratic, or nonlinear, and apply the appropriate solver engine --and a whole lot more. So if you’ve used the Optimizer before, we strongly recommend that you learn about these new features so you can take full advantage of them and then read Chapter 1, Quick Start, and Chapter 4, Optimizing with Intelligent Arrays (at least). Even though Analytica 4.4 still supports functions from releases 4.2 and earlier of Optimizer for backward compatibility, you will likely want to learn and use the new functions instead.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--==Introduction==&lt;br /&gt;
==== What is the Analytica Optimizer? ====&lt;br /&gt;
&lt;br /&gt;
===== Types of Optimization =====&lt;br /&gt;
&lt;br /&gt;
===== Premium Solver Specifications =====&lt;br /&gt;
&lt;br /&gt;
===== Optimize with Uncertain Values and Intelligent Arrays =====&lt;br /&gt;
&lt;br /&gt;
===== Compatibility with Other Analytica Editors =====&lt;br /&gt;
&lt;br /&gt;
==== Obtaining the Analytica Optimizer ====&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36582</id>
		<title>Analytica Optimizer Guide</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36582"/>
		<updated>2015-11-06T03:15:29Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Table of Contents&lt;br /&gt;
* Introduction&lt;br /&gt;
** Using the Analytica Optimizer Guide&lt;br /&gt;
** Obtaining Analytica Optimizer&lt;br /&gt;
** Activating Analytica Optimizer&lt;br /&gt;
** Installing Add-On Engines to Analytica Optimizer&lt;br /&gt;
* Quick Start&lt;br /&gt;
** Intro to Structured Optimization&lt;br /&gt;
** Notation&lt;br /&gt;
** The Optimum Can Example&lt;br /&gt;
*** Decisions&lt;br /&gt;
*** Constants&lt;br /&gt;
*** Variables&lt;br /&gt;
*** Constraints&lt;br /&gt;
*** Objectives&lt;br /&gt;
*** The DefineOptimization() Function&lt;br /&gt;
*** Viewing the Optimization Object&lt;br /&gt;
*** Obtaining the Solution&lt;br /&gt;
*** Obtaining the Optimized Objective Value&lt;br /&gt;
*** Viewing Optimization Status&lt;br /&gt;
*** Copying Optimized Results to Definitions&lt;br /&gt;
*** Changing Variable Types (Domain)&lt;br /&gt;
*** Setting Bounds on Decision Values&lt;br /&gt;
*** Using Parametric Analysis with Optimization&lt;br /&gt;
*** The Initial Guess Attribute&lt;br /&gt;
** Summary&lt;br /&gt;
* Optimization Characteristics&lt;br /&gt;
** Introduction&lt;br /&gt;
** Parts of an Optimization Problem: General Description&lt;br /&gt;
** Identifying the Type of Optimization&lt;br /&gt;
** Specific Optimization Characteristics&lt;br /&gt;
** Continuous, Integer and Mixed-Integer Programs&lt;br /&gt;
** Solving Simultaneous Equations&lt;br /&gt;
* Optimizing with Arrays&lt;br /&gt;
* Key Concepts: The Airline NLP Example&lt;br /&gt;
* Optimizer Attribute Reference&lt;br /&gt;
* Optimizer Function Reference&lt;br /&gt;
* Control Settings&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
This Guide explains how to use the Analytica Optimizer, which enhances Analytica 4.6 with powerful functions for finding optimal decisions and solving difficult equations.&lt;br /&gt;
&lt;br /&gt;
It provides a Quick Start Tutorial in Chapter 1 and an introduction to the basic concepts of optimization, including linear, quadratic, and nonlinear programming in Chapter 2. Special topics for NLPs are also covered in Chapter 4. But, it's not a complete textbook on optimization. You might find it useful, especially for more challenging applications, to consult one of the many good textbooks on optimization.&lt;br /&gt;
&lt;br /&gt;
'''If you're new to Analytica'''&lt;br /&gt;
&lt;br /&gt;
You will find it easier if you first learn the essentials of Analytica before learning the Analytica Optimizer described here. Start with the Analytica Tutorial to learn the basics of interacting with Analytica and its modeling language, especially Chapter 5, Working with Arrays. It's important to have a good understanding of Intelligent Arrays to make good use of the Optimizer.&lt;br /&gt;
&lt;br /&gt;
'''If you're new to the Analytica Optimizer''' &lt;br /&gt;
&lt;br /&gt;
We suggest you start with Chapter 1, Quick Start, an introductory tutorial that takes you through the key steps to create a simple optimization. &lt;br /&gt;
Then you should go on to Chapter 2, Optimization characteristics, which explains the general principles of optimization and the types of optimization, including Linear Programming (LP), Quadratic Programming (QP), and Non-Linear Programming (NLP). We also recommend Chapter 3, Optimizing with Arrays to master optimization with parametric analysis. Chapter 4 explains how to use optimization in models having dynamic influences and Monte Carlo-based uncertainties.&lt;br /&gt;
&lt;br /&gt;
'''If you've used Analytica Optimizer 4.2 or earlier'''&lt;br /&gt;
&lt;br /&gt;
The 4.3 release of Analytica introduced Structured Optimization, a new set of features that eliminates many difficult steps previously required for structuring optimizations in Analytica. For example, it can use a set of decision variables of varying dimensions, instead of requiring you to combine and flatten them manually. It introduces Constraints as a new object class. It can discover automatically whether your objective is linear, quadratic, or nonlinear, and apply the appropriate solver engine --and a whole lot more. So if you’ve used the Optimizer before, we strongly recommend that you learn about these new features so you can take full advantage of them and then read Chapter 1, Quick Start, and Chapter 4, Optimizing with Intelligent Arrays (at least). Even though Analytica 4.4 still supports functions from releases 4.2 and earlier of Optimizer for backward compatibility, you will likely want to learn and use the new functions instead.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--==Introduction==&lt;br /&gt;
==== What is the Analytica Optimizer? ====&lt;br /&gt;
&lt;br /&gt;
===== Types of Optimization =====&lt;br /&gt;
&lt;br /&gt;
===== Premium Solver Specifications =====&lt;br /&gt;
&lt;br /&gt;
===== Optimize with Uncertain Values and Intelligent Arrays =====&lt;br /&gt;
&lt;br /&gt;
===== Compatibility with Other Analytica Editors =====&lt;br /&gt;
&lt;br /&gt;
==== Obtaining the Analytica Optimizer ====&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36581</id>
		<title>Analytica Optimizer Guide</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36581"/>
		<updated>2015-11-06T02:49:51Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Table of Contents==&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
This Guide explains how to use the Analytica Optimizer, which enhances Analytica 4.6 with powerful functions for finding optimal decisions and solving difficult equations.&lt;br /&gt;
&lt;br /&gt;
It provides a Quick Start Tutorial in Chapter 1 and an introduction to the basic concepts of optimization, including linear, quadratic, and nonlinear programming in Chapter 2. Special topics for NLPs are also covered in Chapter 4. But, it's not a complete textbook on optimization. You might find it useful, especially for more challenging applications, to consult one of the many good textbooks on optimization.&lt;br /&gt;
&lt;br /&gt;
'''If you're new to Analytica'''&lt;br /&gt;
&lt;br /&gt;
You will find it easier if you first learn the essentials of Analytica before learning the Analytica Optimizer described here. Start with the Analytica Tutorial to learn the basics of interacting with Analytica and its modeling language, especially Chapter 5, Working with Arrays. It's important to have a good understanding of Intelligent Arrays to make good use of the Optimizer.&lt;br /&gt;
&lt;br /&gt;
'''If you're new to the Analytica Optimizer''' &lt;br /&gt;
&lt;br /&gt;
We suggest you start with Chapter 1, Quick Start, an introductory tutorial that takes you through the key steps to create a simple optimization. &lt;br /&gt;
Then you should go on to Chapter 2, Optimization characteristics, which explains the general principles of optimization and the types of optimization, including Linear Programming (LP), Quadratic Programming (QP), and Non-Linear Programming (NLP). We also recommend Chapter 3, Optimizing with Arrays to master optimization with parametric analysis. Chapter 4 explains how to use optimization in models having dynamic influences and Monte Carlo-based uncertainties.&lt;br /&gt;
&lt;br /&gt;
'''If you've used Analytica Optimizer 4.2 or earlier'''&lt;br /&gt;
&lt;br /&gt;
The 4.3 release of Analytica introduced Structured Optimization, a new set of features that eliminates many difficult steps previously required for structuring optimizations in Analytica. For example, it can use a set of decision variables of varying dimensions, instead of requiring you to combine and flatten them manually. It introduces Constraints as a new object class. It can discover automatically whether your objective is linear, quadratic, or nonlinear, and apply the appropriate solver engine --and a whole lot more. So if you’ve used the Optimizer before, we strongly recommend that you learn about these new features so you can take full advantage of them and then read Chapter 1, Quick Start, and Chapter 4, Optimizing with Intelligent Arrays (at least). Even though Analytica 4.4 still supports functions from releases 4.2 and earlier of Optimizer for backward compatibility, you will likely want to learn and use the new functions instead.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--==Introduction==&lt;br /&gt;
==== What is the Analytica Optimizer? ====&lt;br /&gt;
&lt;br /&gt;
===== Types of Optimization =====&lt;br /&gt;
&lt;br /&gt;
===== Premium Solver Specifications =====&lt;br /&gt;
&lt;br /&gt;
===== Optimize with Uncertain Values and Intelligent Arrays =====&lt;br /&gt;
&lt;br /&gt;
===== Compatibility with Other Analytica Editors =====&lt;br /&gt;
&lt;br /&gt;
==== Obtaining the Analytica Optimizer ====&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36580</id>
		<title>Analytica Optimizer Guide</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36580"/>
		<updated>2015-11-06T02:48:46Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Table of Contents=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
This Guide explains how to use the Analytica Optimizer, which enhances Analytica 4.6 with powerful functions for finding optimal decisions and solving difficult equations.&lt;br /&gt;
&lt;br /&gt;
It provides a Quick Start Tutorial in Chapter 1 and an introduction to the basic concepts of optimization, including linear, quadratic, and nonlinear programming in Chapter 2. Special topics for NLPs are also covered in Chapter 4. But, it's not a complete textbook on optimization. You might find it useful, especially for more challenging applications, to consult one of the many good textbooks on optimization.&lt;br /&gt;
&lt;br /&gt;
'''If you're new to Analytica'''&lt;br /&gt;
&lt;br /&gt;
You will find it easier if you first learn the essentials of Analytica before learning the Analytica Optimizer described here. Start with the Analytica Tutorial to learn the basics of interacting with Analytica and its modeling language, especially Chapter 5, Working with Arrays. It's important to have a good understanding of Intelligent Arrays to make good use of the Optimizer.&lt;br /&gt;
&lt;br /&gt;
'''If you're new to the Analytica Optimizer''' &lt;br /&gt;
&lt;br /&gt;
We suggest you start with Chapter 1, Quick Start, an introductory tutorial that takes you through the key steps to create a simple optimization. &lt;br /&gt;
Then you should go on to Chapter 2, Optimization characteristics, which explains the general principles of optimization and the types of optimization, including Linear Programming (LP), Quadratic Programming (QP), and Non-Linear Programming (NLP). We also recommend Chapter 3, Optimizing with Arrays to master optimization with parametric analysis. Chapter 4 explains how to use optimization in models having dynamic influences and Monte Carlo-based uncertainties.&lt;br /&gt;
&lt;br /&gt;
'''If you've used Analytica Optimizer 4.2 or earlier'''&lt;br /&gt;
&lt;br /&gt;
The 4.3 release of Analytica introduced Structured Optimization, a new set of features that eliminates many difficult steps previously required for structuring optimizations in Analytica. For example, it can use a set of decision variables of varying dimensions, instead of requiring you to combine and flatten them manually. It introduces Constraints as a new object class. It can discover automatically whether your objective is linear, quadratic, or nonlinear, and apply the appropriate solver engine --and a whole lot more. So if you’ve used the Optimizer before, we strongly recommend that you learn about these new features so you can take full advantage of them and then read Chapter 1, Quick Start, and Chapter 4, Optimizing with Intelligent Arrays (at least). Even though Analytica 4.4 still supports functions from releases 4.2 and earlier of Optimizer for backward compatibility, you will likely want to learn and use the new functions instead.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--==Introduction==&lt;br /&gt;
==== What is the Analytica Optimizer? ====&lt;br /&gt;
&lt;br /&gt;
===== Types of Optimization =====&lt;br /&gt;
&lt;br /&gt;
===== Premium Solver Specifications =====&lt;br /&gt;
&lt;br /&gt;
===== Optimize with Uncertain Values and Intelligent Arrays =====&lt;br /&gt;
&lt;br /&gt;
===== Compatibility with Other Analytica Editors =====&lt;br /&gt;
&lt;br /&gt;
==== Obtaining the Analytica Optimizer ====&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36579</id>
		<title>Analytica Optimizer Guide</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36579"/>
		<updated>2015-11-06T02:44:24Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
&lt;br /&gt;
This Guide explains how to use the Analytica Optimizer, which enhances Analytica 4.6 with powerful functions for finding optimal decisions and solving difficult equations.&lt;br /&gt;
&lt;br /&gt;
It provides a Quick Start Tutorial in Chapter 1 and an introduction to the basic concepts of optimization, including linear, quadratic, and nonlinear programming in Chapter 2. Special topics for NLPs are also covered in Chapter 4. But, it's not a complete textbook on optimization. You might find it useful, especially for more challenging applications, to consult one of the many good textbooks on optimization.&lt;br /&gt;
&lt;br /&gt;
'''If you're new to Analytica'''&lt;br /&gt;
&lt;br /&gt;
You will find it easier if you first learn the essentials of Analytica before learning the Analytica Optimizer described here. Start with the Analytica Tutorial to learn the basics of interacting with Analytica and its modeling language, especially Chapter 5, Working with Arrays. It's important to have a good understanding of Intelligent Arrays to make good use of the Optimizer.&lt;br /&gt;
&lt;br /&gt;
'''If you're new to the Analytica Optimizer''' &lt;br /&gt;
&lt;br /&gt;
We suggest you start with Chapter 1, Quick Start, an introductory tutorial that takes you through the key steps to create a simple optimization. &lt;br /&gt;
Then you should go on to Chapter 2, Optimization characteristics, which explains the general principles of optimization and the types of optimization, including Linear Programming (LP), Quadratic Programming (QP), and Non-Linear Programming (NLP). We also recommend Chapter 3, Optimizing with Arrays to master optimization with parametric analysis. Chapter 4 explains how to use optimization in models having dynamic influences and Monte Carlo-based uncertainties.&lt;br /&gt;
&lt;br /&gt;
'''If you've used Analytica Optimizer 4.2 or earlier'''&lt;br /&gt;
&lt;br /&gt;
The 4.3 release of Analytica introduced Structured Optimization, a new set of features that eliminates many difficult steps previously required for structuring optimizations in Analytica. For example, it can use a set of decision variables of varying dimensions, instead of requiring you to combine and flatten them manually. It introduces Constraints as a new object class. It can discover automatically whether your objective is linear, quadratic, or nonlinear, and apply the appropriate solver engine --and a whole lot more. So if you’ve used the Optimizer before, we strongly recommend that you learn about these new features so you can take full advantage of them and then read Chapter 1, Quick Start, and Chapter 4, Optimizing with Intelligent Arrays (at least). Even though Analytica 4.4 still supports functions from releases 4.2 and earlier of Optimizer for backward compatibility, you will likely want to learn and use the new functions instead.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--==Introduction==&lt;br /&gt;
==== What is the Analytica Optimizer? ====&lt;br /&gt;
&lt;br /&gt;
===== Types of Optimization =====&lt;br /&gt;
&lt;br /&gt;
===== Premium Solver Specifications =====&lt;br /&gt;
&lt;br /&gt;
===== Optimize with Uncertain Values and Intelligent Arrays =====&lt;br /&gt;
&lt;br /&gt;
===== Compatibility with Other Analytica Editors =====&lt;br /&gt;
&lt;br /&gt;
==== Obtaining the Analytica Optimizer ====&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Integration_with_data_and_applications&amp;diff=36562</id>
		<title>Integration with data and applications</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Integration_with_data_and_applications&amp;diff=36562"/>
		<updated>2015-11-05T22:29:36Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category: Analytica User Guide]]&lt;br /&gt;
&amp;lt;breadcrumbs&amp;gt; Analytica User Guide &amp;gt; {{PAGENAME}}&amp;lt;/breadcrumbs&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
OLE linking makes it possible to link data to and from external applications. With OLE linking, changes to inputs or results are automatically and instantaneously propagated between applications.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This chapter describes how to exchange data between Analytica and other applications via the following methods:&lt;br /&gt;
# [[Using the Standard Copy and Paste Commands]]&lt;br /&gt;
# [[Using OLE linking]]&lt;br /&gt;
# [[Reading and Writing Data in Excel worksheets]]&lt;br /&gt;
# [[Using the Import and Export Commands]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
These methods are explained in full detail on the next few pages.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;footer&amp;gt;Analytica User Guide / {{PAGENAME}} / Next&amp;lt;/footer&amp;gt;&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36557</id>
		<title>Analytica Optimizer Guide</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36557"/>
		<updated>2015-11-05T15:57:59Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This Guide explains how to use the Analytica Optimizer, which enhances Analytica 4.6 with powerful functions to find optimal decisions and solve equations.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
==== What is the Analytica Optimizer? ====&lt;br /&gt;
&lt;br /&gt;
===== Types of Optimization =====&lt;br /&gt;
&lt;br /&gt;
===== Premium Solver Specifications =====&lt;br /&gt;
&lt;br /&gt;
===== Optimize with Uncertain Values and Intelligent Arrays =====&lt;br /&gt;
&lt;br /&gt;
===== Compatibility with Other Analytica Editors =====&lt;br /&gt;
&lt;br /&gt;
==== Obtaining the Analytica Optimizer ====&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36556</id>
		<title>Analytica Optimizer Guide</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36556"/>
		<updated>2015-11-05T15:29:09Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This Guide explains how to use the Analytica Optimizer, which enhances Analytica 4.6 with powerful functions to find optimal decisions and solve equations.&lt;br /&gt;
&lt;br /&gt;
==Contents of the Analytica Optimizer Guide==&lt;br /&gt;
===Introduction===&lt;br /&gt;
&lt;br /&gt;
==== What is the Analytica Optimizer ====&lt;br /&gt;
&lt;br /&gt;
===== Types of Optimization =====&lt;br /&gt;
&lt;br /&gt;
===== Premium Solver Specifications =====&lt;br /&gt;
&lt;br /&gt;
===== Optimize with Uncertain Values and Intelligent Arrays =====&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36555</id>
		<title>Analytica Optimizer Guide</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Analytica_Optimizer_Guide&amp;diff=36555"/>
		<updated>2015-11-05T15:25:00Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: Created page with &amp;quot;This Guide explains how to use the Analytica Optimizer, which enhances Analytica 4.6 with powerful functions to find optimal decisions and solve equations.  ==Contents of the...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This Guide explains how to use the Analytica Optimizer, which enhances Analytica 4.6 with powerful functions to find optimal decisions and solve equations.&lt;br /&gt;
&lt;br /&gt;
==Contents of the Analytica Optimizer Guide==&lt;br /&gt;
===Introduction===&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Analytica_Docs&amp;diff=36554</id>
		<title>Analytica Docs</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Analytica_Docs&amp;diff=36554"/>
		<updated>2015-11-05T14:38:48Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki offers tips, FAQs, videos, examples, shared libraries, and detailed function documentation on Analytica. It goes way beyond the Analytica Tutorial and User Guides (including Optimizer and ADE User Guides). All content is contributed by Analytica users for each other. You are invited to add your own improvements!&lt;br /&gt;
&lt;br /&gt;
*[[Analytica User FAQs]]: Frequently Asked Questions about using Analytica.&lt;br /&gt;
*[[Analytica Libraries and Templates]] and [[Example Models]]: &lt;br /&gt;
*[[Analytica Modelers Guide]]: Hints and examples.&lt;br /&gt;
*[[Analytica Optimizer Guide]]&lt;br /&gt;
&lt;br /&gt;
*[[Analytica Reference]]: Complete details on selected features. &lt;br /&gt;
**[[:Category:Functions|Function Reference Index]] &lt;br /&gt;
**Key Analytica [[:Category:Concepts|Concepts]]&lt;br /&gt;
**[[Special:Uncategorizedcategories|Top Level Categories]] in this wiki&lt;br /&gt;
**[[Special:Categories|All Categories]] in this wiki&lt;br /&gt;
&lt;br /&gt;
*[[Analytica in the Classroom]]: Resources for using Analytica for teaching&lt;br /&gt;
&lt;br /&gt;
*[[Analytica User Group]]&amp;amp;nbsp;: Recorded videos of past webinars -- a great resource for learning key topics, basic and advanced.&lt;br /&gt;
**[[Analytica User Group/Past Topics|Archives of previous webinars]]&lt;br /&gt;
&lt;br /&gt;
*[[What's New in Analytica 4.6?]]: Released 24 May 2015. Get the latest release from [http://www.lumina.com/support/downloads/ Download Installers]&lt;br /&gt;
&amp;lt;!--*[[Beta Tester Page]]: Try out [[Analytica 4.6]].  Become a beta tester. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[Analytica Cloud Player]]: How to use ACP to share your models over the web.&lt;br /&gt;
&lt;br /&gt;
* [http://blog.lumina.com The Lumina Blog]&lt;br /&gt;
*[[Job Postings]]: Jobs available for Analytica users.&lt;br /&gt;
&lt;br /&gt;
*[[Enhancement Requests for Analytica]]: Here's what else I think Analytica should do.&lt;br /&gt;
&lt;br /&gt;
*[[Comments and suggestions for Analytica wiki]]: Here's how we can improve this Wiki.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
*[[How to edit Analytica wiki]]: Tips on how to edit and add to these documents.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
[[Analytica wiki outline]]&lt;br /&gt;
&lt;br /&gt;
You are invited to improve existing content and add your own  -- to benefit the Analytica user community that has contributed the existing content. You should have a password to log in if you have current support. (If not email info@lumina.com to get one.)   &lt;br /&gt;
&lt;br /&gt;
This Analytica wiki uses Mediawiki, the same engine that powers wikipedia.  If you have a comment or question on an existing page, you can add it on its ''discussion'' page. (Each page has a Discussion tab at the top.) If you can't find a page that addresses your question or have a general comment, add it to [[Comments and suggestions for Analytica wiki]]. Or, if you know a good answer to someone's question, feel free to provide it. Any contributions are welcome -- questions, corrections, tips, examples, or libraries you want to share. As with any wiki, all contributions are liable to be edited and improved by others. &lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
[[Image:Analytica logo tagline 500px.png]]&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36418</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36418"/>
		<updated>2015-11-03T23:55:24Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]]&amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rank(x, i)==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Rank(x,i)&amp;lt;/tt&amp;gt; returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter «i» is unnecessary. A one-dimensional array is returned, indexed by «Years». This array has a value of 1 where «Year» has the smallest value, a value of 2 where «Year» has the second smallest value, and so on.&lt;br /&gt;
 &amp;lt;tt&amp;gt;Rank(Years)&amp;lt;/tt&amp;gt; →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the example below, the Rank function works with a multidimensional table. Each car type is given a rank for each year, with the cheapest car in that year given 1 and the most expensive car in that year given 3. &lt;br /&gt;
 &amp;lt;tt&amp;gt;Rank(Car_prices, Car_type)&amp;lt;/tt&amp;gt; →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
| 1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
If two (or «n) values are equal, they receive the same rank and the next higher value receives a rank 2 (or n) higher. You can use an optional parameter, «Type», to control which rank is assigned to equal values. By default, the lowest rank is used, equivalent to «'''Rank(x, i, Type:-1)'''» Alternatively, «Rank(x, i, Type:0)»''' '''uses the mid-rank and «Rank(x, i, Type:1)»''' '''uses the upper-rank. «Rank(x, i, Type:Null)»''' '''assigns a unique rank to every element (the numbers 1 thru n) in which tied elements may have different ranks.&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
The example below shows how the Rank function handles duplicate values.&lt;br /&gt;
 Rank(NumRepairs,CarNum,Type:RankType) →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;7&amp;quot; | Rank Type '''&amp;amp;#9660;''', CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''6''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
|'''-1'''&lt;br /&gt;
|7&lt;br /&gt;
| 2&lt;br /&gt;
|6&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|1&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''0'''&lt;br /&gt;
|7&lt;br /&gt;
|3.5&lt;br /&gt;
|6&lt;br /&gt;
|3.5&lt;br /&gt;
|3.5&lt;br /&gt;
|1&lt;br /&gt;
|3.5&lt;br /&gt;
|-&lt;br /&gt;
|'''1'''&lt;br /&gt;
|7&lt;br /&gt;
|5&lt;br /&gt;
|6&lt;br /&gt;
|5&lt;br /&gt;
|5&lt;br /&gt;
|1&lt;br /&gt;
|5&lt;br /&gt;
|-&lt;br /&gt;
|'''Null'''&lt;br /&gt;
|7&lt;br /&gt;
|2&lt;br /&gt;
|6&lt;br /&gt;
|3&lt;br /&gt;
|4&lt;br /&gt;
|1&lt;br /&gt;
|6&lt;br /&gt;
|}&lt;br /&gt;
For «Type =: -1'''»''', lowest rank for the duplicate value is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: 0», mid rank value of the duplicates is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: 1», highest rank for the duplicate value is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: NULL», unique rank value is returned.&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, «Zebra'''»'''  gets a lower rank than «apply'''»'''.  In Analytica 4.2 or later, you can supply the optional parameter «caseInsensitive:true'''''»''''':&lt;br /&gt;
  [[Rank]](x,i, caseInsensitive:true)&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using «[[Rank]](-X, i)».&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter &lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](x, i, descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is referred to as a multi-key sort (or multi-key rank). The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, i.  You must then introduce a new index, ''«''keyIndex''»'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by «I»'' and «''keyIndex''»''.  For example, the following ranks by age, then, in case of a tie, by gender:&lt;br /&gt;
 [[Index..Do|&amp;lt;code&amp;gt;Index&amp;lt;/code&amp;gt;]]&amp;lt;code&amp;gt; keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]](Array(keyIndex,[age,gender]), i, keyIndex )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
&lt;br /&gt;
This example shows how multi-key rank can be calculated by passing the optional «keyIndex''»'' parameter to the rank function. The rank of the cars by the number of maintenance events using index «maintType''»'' as the «keyIndex''»'' is returned.&lt;br /&gt;
 Rank(NumMaintEvents, CarNum, KeyIndex: MaintType:RankType) →&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;7&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:100px;&amp;quot; |'''MaintType &amp;amp;#9660; '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''6'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
!'''Repair''' &lt;br /&gt;
| 10&lt;br /&gt;
| 4&lt;br /&gt;
| 9&lt;br /&gt;
| 4&lt;br /&gt;
| 4&lt;br /&gt;
| 1&lt;br /&gt;
| 4&lt;br /&gt;
|-&lt;br /&gt;
!'''Scheduled'''&lt;br /&gt;
| 0&lt;br /&gt;
| 2&lt;br /&gt;
| 0&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 0&lt;br /&gt;
| 5&lt;br /&gt;
|-&lt;br /&gt;
!'''Tires''' &lt;br /&gt;
| 0&lt;br /&gt;
| 2&lt;br /&gt;
| 0&lt;br /&gt;
| 0&lt;br /&gt;
| 1&lt;br /&gt;
| 0&lt;br /&gt;
| 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a ''«''[[NaN|NaN''»'']] value occurs in your data, [[Rank]] can either pass it through as a ''«''[[NaN|NaN''»'']] or assign it a numeric rank.  The optional ''«''passNaNs''»'' parameter controls this behavior.  The special value ''«''[[NaN|NaN''&amp;lt;nowiki/&amp;gt;'']]''[[NaN|»]]''  indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of ''«''[[NaN|NaN''»'']] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results. This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value. To pass NaNs, include the optional parameter ''«''passNaNs:true''».''&lt;br /&gt;
 [[Rank]](x, i, passNaNs:true).&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter. When this is not specified, null values are assigned a rank (with «[[Null|Null»]]''''' '''''coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36401</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36401"/>
		<updated>2015-11-03T04:18:00Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]]&amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rank(x, i)==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Rank(x,i)&amp;lt;/tt&amp;gt; returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter «i» is unnecessary. A one-dimensional array is returned, indexed by «Years». This array has a value of 1 where «Year» has the smallest value, a value of 2 where «Year» has the second smallest value, and so on.&lt;br /&gt;
 &amp;lt;tt&amp;gt;Rank(Years)&amp;lt;/tt&amp;gt; →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the example below, the Rank function works with a multidimensional table. Each car type is given a rank for each year, with the cheapest car in that year given 1 and the most expensive car in that year given 3. &lt;br /&gt;
 &amp;lt;tt&amp;gt;Rank(Car_prices, Car_type)&amp;lt;/tt&amp;gt; →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
| 1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
If two (or «n) values are equal, they receive the same rank and the next higher value receives a rank 2 (or n) higher. You can use an optional parameter, «Type», to control which rank is assigned to equal values. By default, the lowest rank is used, equivalent to «'''Rank(x, i, Type:-1)'''» Alternatively, «Rank(x, i, Type:0)»''' '''uses the mid-rank and «Rank(x, i, Type:1)»''' '''uses the upper-rank. «Rank(x, i, Type:Null)»''' '''assigns a unique rank to every element (the numbers 1 thru n) in which tied elements may have different ranks.&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
The example below shows how the Rank function handles duplicate values.&lt;br /&gt;
&lt;br /&gt;
For «Type =: -1'''»''', lowest rank for the duplicate value is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: 0», mid rank value of the duplicates is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: 1», highest rank for the duplicate value is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: NULL», Unique rank value is returned.&lt;br /&gt;
 Rank(NumRepairs,CarNum,Type:RankType) →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;7&amp;quot; | Rank Type '''&amp;amp;#9660;''', CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''6''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
|'''-1'''&lt;br /&gt;
|7&lt;br /&gt;
| 2&lt;br /&gt;
|6&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|1&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''0'''&lt;br /&gt;
|7&lt;br /&gt;
|3.5&lt;br /&gt;
|6&lt;br /&gt;
|3.5&lt;br /&gt;
|3.5&lt;br /&gt;
|1&lt;br /&gt;
|3.5&lt;br /&gt;
|-&lt;br /&gt;
|'''1'''&lt;br /&gt;
|7&lt;br /&gt;
|5&lt;br /&gt;
|6&lt;br /&gt;
|5&lt;br /&gt;
|5&lt;br /&gt;
|1&lt;br /&gt;
|5&lt;br /&gt;
|-&lt;br /&gt;
|'''Null'''&lt;br /&gt;
|7&lt;br /&gt;
|2&lt;br /&gt;
|6&lt;br /&gt;
|3&lt;br /&gt;
|4&lt;br /&gt;
|1&lt;br /&gt;
|6&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, «Zebra'''»'''  gets a lower rank than «apply'''»'''.  In Analytica 4.2 or later, you can supply the optional parameter «caseInsensitive:true'''''»''''':&lt;br /&gt;
  [[Rank]](x,i, caseInsensitive:true)&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using «[[Rank]](-X, i)».&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter &lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](x, i, descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is referred to as a multi-key sort (or multi-key rank). The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, i.  You must then introduce a new index, ''«''keyIndex''»'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by «I»'' and «''keyIndex''»''.  For example, the following ranks by age, then, in case of a tie, by gender:&lt;br /&gt;
 [[Index..Do|&amp;lt;code&amp;gt;Index&amp;lt;/code&amp;gt;]]&amp;lt;code&amp;gt; keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]](Array(keyIndex,[age,gender]), i, keyIndex )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
&lt;br /&gt;
This example shows how multi-key rank can be calculated by passing the optional «keyIndex''»'' parameter to the rank function. The rank of the cars by the number of maintenance events using index «maintType''»'' as the «keyIndex''»'' is returned.&lt;br /&gt;
 Rank(NumMaintEvents, CarNum, KeyIndex: MaintType:RankType) →&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;7&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:100px;&amp;quot; |'''MaintType &amp;amp;#9660; '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''6'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
!'''Repair''' &lt;br /&gt;
| 10&lt;br /&gt;
| 4&lt;br /&gt;
| 9&lt;br /&gt;
| 4&lt;br /&gt;
| 4&lt;br /&gt;
| 1&lt;br /&gt;
| 4&lt;br /&gt;
|-&lt;br /&gt;
!'''Scheduled'''&lt;br /&gt;
| 0&lt;br /&gt;
| 2&lt;br /&gt;
| 0&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 0&lt;br /&gt;
| 5&lt;br /&gt;
|-&lt;br /&gt;
!'''Tires''' &lt;br /&gt;
| 0&lt;br /&gt;
| 2&lt;br /&gt;
| 0&lt;br /&gt;
| 0&lt;br /&gt;
| 1&lt;br /&gt;
| 0&lt;br /&gt;
| 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a ''«''[[NaN|NaN''»'']] value occurs in your data, [[Rank]] can either pass it through as a ''«''[[NaN|NaN''»'']] or assign it a numeric rank.  The optional ''«''passNaNs''»'' parameter controls this behavior.  The special value ''«''[[NaN|NaN''&amp;lt;nowiki/&amp;gt;'']]''[[NaN|»]]''  indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of ''«''[[NaN|NaN''»'']] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results. This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value. To pass NaNs, include the optional parameter ''«''passNaNs:true''».''&lt;br /&gt;
 [[Rank]](x, i, passNaNs:true).&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter. When this is not specified, null values are assigned a rank (with «[[Null|Null»]]''''' '''''coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36400</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36400"/>
		<updated>2015-11-03T04:16:48Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]]&amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rank(x, i)==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Rank(x,i)&amp;lt;/tt&amp;gt; returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter «i» is unnecessary. A one-dimensional array is returned, indexed by «Years». This array has a value of 1 where «Year» has the smallest value, a value of 2 where «Year» has the second smallest value, and so on.&lt;br /&gt;
 &amp;lt;tt&amp;gt;Rank(Years)&amp;lt;/tt&amp;gt; →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the example below, the Rank function works with a multidimensional table. Each car type is given a rank for each year, with the cheapest car in that year given 1 and the most expensive car in that year given 3. &lt;br /&gt;
 &amp;lt;tt&amp;gt;Rank(Car_prices, Car_type)&amp;lt;/tt&amp;gt; →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
| 1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
If two (or «n) values are equal, they receive the same rank and the next higher value receives a rank 2 (or n) higher. You can use an optional parameter, «Type», to control which rank is assigned to equal values. By default, the lowest rank is used, equivalent to «'''Rank(x, i, Type:-1)'''» Alternatively, «Rank(x, i, Type:0)»''' '''uses the mid-rank and «Rank(x, i, Type:1)»''' '''uses the upper-rank. «Rank(x, i, Type:Null)»''' '''assigns a unique rank to every element (the numbers 1 thru n) in which tied elements may have different ranks.&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
The example below shows how the Rank function handles duplicate values.&lt;br /&gt;
&lt;br /&gt;
For «Type =: -1'''»''', lowest rank for the duplicate value is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: 0», mid rank value of the duplicates is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: 1», highest rank for the duplicate value is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: NULL», Unique rank value is returned.&lt;br /&gt;
 Rank(NumRepairs,CarNum,Type:RankType) →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;7&amp;quot; | Rank Type '''&amp;amp;#9660;''', CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''6''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
|'''-1'''&lt;br /&gt;
|7&lt;br /&gt;
| 2&lt;br /&gt;
|6&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|1&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''0'''&lt;br /&gt;
|7&lt;br /&gt;
|3.5&lt;br /&gt;
|6&lt;br /&gt;
|3.5&lt;br /&gt;
|3.5&lt;br /&gt;
|1&lt;br /&gt;
|3.5&lt;br /&gt;
|-&lt;br /&gt;
|'''1'''&lt;br /&gt;
|7&lt;br /&gt;
|5&lt;br /&gt;
|6&lt;br /&gt;
|5&lt;br /&gt;
|5&lt;br /&gt;
|1&lt;br /&gt;
|5&lt;br /&gt;
|-&lt;br /&gt;
|'''Null'''&lt;br /&gt;
|7&lt;br /&gt;
|2&lt;br /&gt;
|6&lt;br /&gt;
|3&lt;br /&gt;
|4&lt;br /&gt;
|1&lt;br /&gt;
|6&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, «Zebra'''»'''  gets a lower rank than «apply'''»'''.  In Analytica 4.2 or later, you can supply the optional parameter «caseInsensitive:true'''''»''''':&lt;br /&gt;
  [[Rank]](D,I, caseInsensitive:true)&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using «[[Rank]](-X, i)».&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter &lt;br /&gt;
 [[Rank]](X, i, descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is referred to as a multi-key sort (or multi-key rank). The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, i.  You must then introduce a new index, ''«''keyIndex''»'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by «I»'' and «''keyIndex''»''.  For example, the following ranks by age, then, in case of a tie, by gender:&lt;br /&gt;
 [[Index..Do|&amp;lt;code&amp;gt;Index&amp;lt;/code&amp;gt;]]&amp;lt;code&amp;gt; keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]](Array(keyIndex,[age,gender]), i, keyIndex )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
&lt;br /&gt;
This example shows how multi-key rank can be calculated by passing the optional «keyIndex''»'' parameter to the rank function. The rank of the cars by the number of maintenance events using index «maintType''»'' as the «keyIndex''»'' is returned.&lt;br /&gt;
 Rank(NumMaintEvents, CarNum, KeyIndex: MaintType:RankType) →&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;7&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:100px;&amp;quot; |'''MaintType &amp;amp;#9660; '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''6'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
!'''Repair''' &lt;br /&gt;
| 10&lt;br /&gt;
| 4&lt;br /&gt;
| 9&lt;br /&gt;
| 4&lt;br /&gt;
| 4&lt;br /&gt;
| 1&lt;br /&gt;
| 4&lt;br /&gt;
|-&lt;br /&gt;
!'''Scheduled'''&lt;br /&gt;
| 0&lt;br /&gt;
| 2&lt;br /&gt;
| 0&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 0&lt;br /&gt;
| 5&lt;br /&gt;
|-&lt;br /&gt;
!'''Tires''' &lt;br /&gt;
| 0&lt;br /&gt;
| 2&lt;br /&gt;
| 0&lt;br /&gt;
| 0&lt;br /&gt;
| 1&lt;br /&gt;
| 0&lt;br /&gt;
| 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a ''«''[[NaN|NaN''»'']] value occurs in your data, [[Rank]] can either pass it through as a ''«''[[NaN|NaN''»'']] or assign it a numeric rank.  The optional ''«''passNaNs''»'' parameter controls this behavior.  The special value ''«''[[NaN|NaN''&amp;lt;nowiki/&amp;gt;'']]''[[NaN|»]]''  indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of ''«''[[NaN|NaN''»'']] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results. This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value. To pass NaNs, include the optional parameter ''«''passNaNs:true''».''&lt;br /&gt;
 [[Rank]](x, i, passNaNs:true).&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter. When this is not specified, null values are assigned a rank (with «[[Null|Null»]]''''' '''''coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36382</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36382"/>
		<updated>2015-11-01T10:56:10Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]]&amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rank(x, i)==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Rank(x,i)&amp;lt;/tt&amp;gt; returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter «i» is unnecessary. A one-dimensional array is returned, indexed by «Years». This array has a value of 1 where «Year» has the smallest value, a value of 2 where «Year» has the second smallest value, and so on.&lt;br /&gt;
 &amp;lt;tt&amp;gt;Rank(Years)&amp;lt;/tt&amp;gt; →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the example below, the Rank function works with a multidimensional table. Each car type is given a rank for each year, with the cheapest car in that year given 1 and the most expensive car in that year given 3. &lt;br /&gt;
 &amp;lt;tt&amp;gt;Rank(Car_prices, Car_type)&amp;lt;/tt&amp;gt; →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
| 1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
If two (or «n) values are equal, they receive the same rank and the next higher value receives a rank 2 (or n) higher. You can use an optional parameter, «Type», to control which rank is assigned to equal values. By default, the lowest rank is used, equivalent to «'''Rank(x, i, Type:-1)'''» Alternatively, «Rank(x, i, Type:0)»''' '''uses the mid-rank and «Rank(x, i, Type:1)»''' '''uses the upper-rank. «Rank(x, i, Type:Null)»''' '''assigns a unique rank to every element (the numbers 1 thru n) in which tied elements may have different ranks.&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
The example below shows how the Rank function handles duplicate values.&lt;br /&gt;
&lt;br /&gt;
For «Type =: -1'''»''', lowest rank for the duplicate value is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: 0», mid rank value of the duplicates is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: 1», highest rank for the duplicate value is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: NULL», Unique rank value is returned.&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;7&amp;quot; | Rank Type '''&amp;amp;#9660;''', CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''6''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
|'''-1'''&lt;br /&gt;
|7&lt;br /&gt;
| 2&lt;br /&gt;
|6&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|1&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''0'''&lt;br /&gt;
|7&lt;br /&gt;
|3.5&lt;br /&gt;
|6&lt;br /&gt;
|3.5&lt;br /&gt;
|3.5&lt;br /&gt;
|1&lt;br /&gt;
|3.5&lt;br /&gt;
|-&lt;br /&gt;
|'''1'''&lt;br /&gt;
|7&lt;br /&gt;
|5&lt;br /&gt;
|6&lt;br /&gt;
|5&lt;br /&gt;
|5&lt;br /&gt;
|1&lt;br /&gt;
|5&lt;br /&gt;
|-&lt;br /&gt;
|'''Null'''&lt;br /&gt;
|7&lt;br /&gt;
|2&lt;br /&gt;
|6&lt;br /&gt;
|3&lt;br /&gt;
|4&lt;br /&gt;
|1&lt;br /&gt;
|6&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, «Zebra'''»'''  gets a lower rank than «apply'''»'''.  In Analytica 4.2 or later, you can supply the optional parameter «caseInsensitive:true'''''»''''':&lt;br /&gt;
  [[Rank]](D,I, caseInsensitive:true)&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using «[[Rank]](-X, i)».&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter &lt;br /&gt;
 [[Rank]](X, i, descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is referred to as a multi-key sort (or multi-key rank). The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, i.  You must then introduce a new index, ''«''keyIndex''»'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by «I»'' and «''keyIndex''»''.  For example, the following ranks by age, then, in case of a tie, by gender:&lt;br /&gt;
 [[Index..Do|&amp;lt;code&amp;gt;Index&amp;lt;/code&amp;gt;]]&amp;lt;code&amp;gt; keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]](Array(keyIndex,[age,gender]), i, keyIndex )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
&lt;br /&gt;
This example shows how multi-key rank can be calculated by passing the optional «keyIndex''»'' parameter to the rank function. The rank of the cars by the number of maintenance events using index «maintType''»'' as the «keyIndex''»'' is returned.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;7&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:100px;&amp;quot; |'''MaintType &amp;amp;#9660; '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''6'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
!'''Repair''' &lt;br /&gt;
| 10&lt;br /&gt;
| 4&lt;br /&gt;
| 9&lt;br /&gt;
| 4&lt;br /&gt;
| 4&lt;br /&gt;
| 1&lt;br /&gt;
| 4&lt;br /&gt;
|-&lt;br /&gt;
!'''Scheduled'''&lt;br /&gt;
| 0&lt;br /&gt;
| 2&lt;br /&gt;
| 0&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 0&lt;br /&gt;
| 5&lt;br /&gt;
|-&lt;br /&gt;
!'''Tires''' &lt;br /&gt;
| 0&lt;br /&gt;
| 2&lt;br /&gt;
| 0&lt;br /&gt;
| 0&lt;br /&gt;
| 1&lt;br /&gt;
| 0&lt;br /&gt;
| 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a ''«''[[NaN|NaN''»'']] value occurs in your data, [[Rank]] can either pass it through as a ''«''[[NaN|NaN''»'']] or assign it a numeric rank.  The optional ''«''passNaNs''»'' parameter controls this behavior.  The special value ''«''[[NaN|NaN''&amp;lt;nowiki/&amp;gt;'']]''[[NaN|»]]''  indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of ''«''[[NaN|NaN''»'']] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results. This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value. To pass NaNs, include the optional parameter ''«''passNaNs:true''».''&lt;br /&gt;
 [[Rank]](x, i, passNaNs:true).&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter. When this is not specified, null values are assigned a rank (with «[[Null|Null»]]''''' '''''coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36381</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36381"/>
		<updated>2015-11-01T10:51:22Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]]&amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rank(x, i)==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Rank(x,i)&amp;lt;/tt&amp;gt; returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter «i» is unnecessary. A one-dimensional array is returned, indexed by «Years». This array has a value of 1 where «Year» has the smallest value, a value of 2 where «Year» has the second smallest value, and so on.&lt;br /&gt;
 &amp;lt;tt&amp;gt;Rank(Years)&amp;lt;/tt&amp;gt; →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the example below, the Rank function works with a multidimensional table. Each car type is given a rank for each year, with the cheapest car in that year given 1 and the most expensive car in that year given 3. &lt;br /&gt;
 &amp;lt;tt&amp;gt;Rank(Car_prices, Car_type)&amp;lt;/tt&amp;gt; →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
| 1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
If two (or «n) values are equal, they receive the same rank and the next higher value receives a rank 2 (or n) higher. You can use an optional parameter, «Type», to control which rank is assigned to equal values. By default, the lowest rank is used, equivalent to «'''Rank(x, i, Type:-1)'''» Alternatively, «Rank(x, i, Type:0)»''' '''uses the mid-rank and «Rank(x, i, Type:1)»''' '''uses the upper-rank. «Rank(x, i, Type:Null)»''' '''assigns a unique rank to every element (the numbers 1 thru n) in which tied elements may have different ranks.&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
The example below shows how the Rank function handles duplicate values.&lt;br /&gt;
&lt;br /&gt;
For «Type =: -1'''»''', lowest rank for the duplicate value is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: 0», mid rank value of the duplicates is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: 1», highest rank for the duplicate value is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: NULL», Unique rank value is returned.&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;7&amp;quot; | Rank Type '''&amp;amp;#9660;''', CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''6'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
|'''-1'''&lt;br /&gt;
|7&lt;br /&gt;
| 2&lt;br /&gt;
|6&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|1&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''0'''&lt;br /&gt;
|7&lt;br /&gt;
|3.5&lt;br /&gt;
|6&lt;br /&gt;
|3.5&lt;br /&gt;
|3.5&lt;br /&gt;
|1&lt;br /&gt;
|3.5&lt;br /&gt;
|-&lt;br /&gt;
|'''1'''&lt;br /&gt;
|7&lt;br /&gt;
|5&lt;br /&gt;
|6&lt;br /&gt;
|5&lt;br /&gt;
|5&lt;br /&gt;
|1&lt;br /&gt;
|5&lt;br /&gt;
|-&lt;br /&gt;
|'''Null'''&lt;br /&gt;
|7&lt;br /&gt;
|2&lt;br /&gt;
|6&lt;br /&gt;
|3&lt;br /&gt;
|4&lt;br /&gt;
|1&lt;br /&gt;
|6&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, «Zebra'''»'''  gets a lower rank than «apply'''»'''.  In Analytica 4.2 or later, you can supply the optional parameter «''caseInsensitive:true'''»''''':&lt;br /&gt;
  [[Rank]](D,I, caseInsensitive:true)&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using «[[Rank]](-X, i)».&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter &lt;br /&gt;
 [[Rank]](X, i, descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is referred to as a multi-key sort (or multi-key rank). The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, ''I''.  You must then introduce a new index, ''«''keyIndex''»'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by «I»'' and «''keyIndex''»''.  For example, the following ranks by age, then, in case of a tie, by gender:&lt;br /&gt;
 [[Index..Do|&amp;lt;code&amp;gt;Index&amp;lt;/code&amp;gt;]]&amp;lt;code&amp;gt; keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]](Array(keyIndex,[age,gender]), i, keyIndex )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
&lt;br /&gt;
This example shows how multi-key rank can be calculated by passing the optional «keyIndex''»'' parameter to the rank function. The rank of the cars by the number of maintenance events using index «maintType''»'' as the «keyIndex''»'' is returned.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;7&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:100px;&amp;quot; |'''MaintType &amp;amp;#9660; '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''6'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
!'''Repair''' &lt;br /&gt;
| 10&lt;br /&gt;
| 4&lt;br /&gt;
| 9&lt;br /&gt;
| 4&lt;br /&gt;
| 4&lt;br /&gt;
| 1&lt;br /&gt;
| 4&lt;br /&gt;
|-&lt;br /&gt;
!'''Scheduled'''&lt;br /&gt;
| 0&lt;br /&gt;
| 2&lt;br /&gt;
| 0&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 0&lt;br /&gt;
| 5&lt;br /&gt;
|-&lt;br /&gt;
!'''Tires''' &lt;br /&gt;
| 0&lt;br /&gt;
| 2&lt;br /&gt;
| 0&lt;br /&gt;
| 0&lt;br /&gt;
| 1&lt;br /&gt;
| 0&lt;br /&gt;
| 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a ''«''[[NaN]] value occurs in your data, [[Rank]] can either pass it through as a [[NaN]] or assign it a numeric rank.  The optional ''«passNaNs»'' parameter controls this behavior.  The special value [[NaN]] indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of ''«''[[NaN]] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results. This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value.  To pass NaNs, include the optional parameter ''«''passNaNs:true''».''&lt;br /&gt;
 [[Rank]](x, i, passNaNs:true).&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter. When this is not specified, Null values are assigned a rank (with «[[Null|Null»]]''''' '''''coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36380</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36380"/>
		<updated>2015-11-01T10:50:19Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]]&amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rank(x, i)==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Rank(x,i)&amp;lt;/tt&amp;gt; returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter «i» is unnecessary. A one-dimensional array is returned, indexed by «Years». This array has a value of 1 where «Year» has the smallest value, a value of 2 where «Year» has the second smallest value, and so on.&lt;br /&gt;
 &amp;lt;tt&amp;gt;Rank(Years)&amp;lt;/tt&amp;gt; →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the example below, the Rank function works with a multidimensional table. Each car type is given a rank for each year, with the cheapest car in that year given 1 and the most expensive car in that year given 3. &lt;br /&gt;
 &amp;lt;tt&amp;gt;Rank(Car_prices, Car_type)&amp;lt;/tt&amp;gt; →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
| 1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
If two (or «n) values are equal, they receive the same rank and the next higher value receives a rank 2 (or n) higher. You can use an optional parameter, «Type», to control which rank is assigned to equal values. By default, the lowest rank is used, equivalent to «'''Rank(x, i, Type:-1)'''» Alternatively, «Rank(x, i, Type:0)»''' '''uses the mid-rank and «Rank(x, i, Type:1)»''' '''uses the upper-rank. «Rank(x, i, Type:Null)»''' '''assigns a unique rank to every element (the numbers 1 thru n) in which tied elements may have different ranks.&lt;br /&gt;
&lt;br /&gt;
====== Example ======&lt;br /&gt;
The example below shows how the Rank function handles duplicate values.&lt;br /&gt;
&lt;br /&gt;
For «Type =: -1'''»''', lowest rank for the duplicate value is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: 0», mid rank value of the duplicates is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: 1», highest rank for the duplicate value is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: NULL», Unique rank value is returned.&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;7&amp;quot; | Rank Type '''&amp;amp;#9660;''', CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''6'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
|'''-1'''&lt;br /&gt;
|7&lt;br /&gt;
| 2&lt;br /&gt;
|6&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|1&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''0'''&lt;br /&gt;
|7&lt;br /&gt;
|3.5&lt;br /&gt;
|6&lt;br /&gt;
|3.5&lt;br /&gt;
|3.5&lt;br /&gt;
|1&lt;br /&gt;
|3.5&lt;br /&gt;
|-&lt;br /&gt;
|'''1'''&lt;br /&gt;
|7&lt;br /&gt;
|5&lt;br /&gt;
|6&lt;br /&gt;
|5&lt;br /&gt;
|5&lt;br /&gt;
|1&lt;br /&gt;
|5&lt;br /&gt;
|-&lt;br /&gt;
|'''Null'''&lt;br /&gt;
|7&lt;br /&gt;
|2&lt;br /&gt;
|6&lt;br /&gt;
|3&lt;br /&gt;
|4&lt;br /&gt;
|1&lt;br /&gt;
|6&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, «Zebra'''»'''  gets a lower rank than «apply'''»'''.  In Analytica 4.2 or later, you can supply the optional parameter «''caseInsensitive:true'''»''''':&lt;br /&gt;
  [[Rank]](D,I, caseInsensitive:true)&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using «[[Rank]](-X, i)».&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter &lt;br /&gt;
 [[Rank]](X, i, descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is referred to as a multi-key sort (or multi-key rank). The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, ''I''.  You must then introduce a new index, ''«''keyIndex''»'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by «I»'' and «''keyIndex''»''.  For example, the following ranks by age, then, in case of a tie, by gender:&lt;br /&gt;
 [[Index..Do|&amp;lt;code&amp;gt;Index&amp;lt;/code&amp;gt;]]&amp;lt;code&amp;gt; keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]](Array(keyIndex,[age,gender]), i, keyIndex )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
&lt;br /&gt;
This example shows how multi-key rank can be calculated by passing the optional «keyIndex''»'' parameter to the rank function. The rank of the cars by the number of maintenance events using index «maintType''»'' as the «keyIndex''»'' is returned.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;7&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:100px;&amp;quot; |'''MaintType &amp;amp;#9660; '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''6'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
!'''Repair''' &lt;br /&gt;
| 10&lt;br /&gt;
| 4&lt;br /&gt;
| 9&lt;br /&gt;
| 4&lt;br /&gt;
| 4&lt;br /&gt;
| 1&lt;br /&gt;
| 4&lt;br /&gt;
|-&lt;br /&gt;
!'''Scheduled'''&lt;br /&gt;
| 0&lt;br /&gt;
| 2&lt;br /&gt;
| 0&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 0&lt;br /&gt;
| 5&lt;br /&gt;
|-&lt;br /&gt;
!'''Tires''' &lt;br /&gt;
| 0&lt;br /&gt;
| 2&lt;br /&gt;
| 0&lt;br /&gt;
| 0&lt;br /&gt;
| 1&lt;br /&gt;
| 0&lt;br /&gt;
| 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a ''«''[[NaN]] value occurs in your data, [[Rank]] can either pass it through as a [[NaN]] or assign it a numeric rank.  The optional ''«passNaNs»'' parameter controls this behavior.  The special value [[NaN]] indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of ''«''[[NaN]] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results. This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value.  To pass NaNs, include the optional parameter ''«''passNaNs:true''».''&lt;br /&gt;
 [[Rank]](x, i, passNaNs:true).&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter. When this is not specified, Null values are assigned a rank (with «[[Null|Null»]]''''' '''''coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36379</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36379"/>
		<updated>2015-11-01T10:49:01Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]]&amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rank(x, i)==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Rank(x,i)&amp;lt;/tt&amp;gt; returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter «i» is unnecessary. A one-dimensional array is returned, indexed by «Years». This array has a value of 1 where «Year» has the smallest value, a value of 2 where «Year» has the second smallest value, and so on.&lt;br /&gt;
 &amp;lt;tt&amp;gt;Rank(Years)&amp;lt;/tt&amp;gt; →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the example below, the Rank function works with a multidimensional table. Each car type is given a rank for each year, with the cheapest car in that year given 1 and the most expensive car in that year given 3. &lt;br /&gt;
 &amp;lt;tt&amp;gt;Rank(Car_prices, Car_type)&amp;lt;/tt&amp;gt; →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
| 1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
If two (or «n) values are equal, they receive the same rank and the next higher value receives a rank 2 (or n) higher. You can use an optional parameter, «Type», to control which rank is assigned to equal values. By default, the lowest rank is used, equivalent to «'''Rank(x, i, Type:-1)'''» Alternatively, «Rank(x, i, Type:0)»''' '''uses the mid-rank and «Rank(x, i, Type:1)»''' '''uses the upper-rank. «Rank(x, i, Type:Null)»''' '''assigns a unique rank to every element (the numbers 1 thru n) in which tied elements may have different ranks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;====Example====&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example below shows how the Rank function handles duplicate values.&lt;br /&gt;
&lt;br /&gt;
For «Type =: -1'''»''', lowest rank for the duplicate value is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: 0», mid rank value of the duplicates is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: 1», highest rank for the duplicate value is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: NULL», Unique rank value is returned.&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;7&amp;quot; | Rank Type '''&amp;amp;#9660;''', CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''6'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
|'''-1'''&lt;br /&gt;
|7&lt;br /&gt;
| 2&lt;br /&gt;
|6&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|1&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''0'''&lt;br /&gt;
|7&lt;br /&gt;
|3.5&lt;br /&gt;
|6&lt;br /&gt;
|3.5&lt;br /&gt;
|3.5&lt;br /&gt;
|1&lt;br /&gt;
|3.5&lt;br /&gt;
|-&lt;br /&gt;
|'''1'''&lt;br /&gt;
|7&lt;br /&gt;
|5&lt;br /&gt;
|6&lt;br /&gt;
|5&lt;br /&gt;
|5&lt;br /&gt;
|1&lt;br /&gt;
|5&lt;br /&gt;
|-&lt;br /&gt;
|'''Null'''&lt;br /&gt;
|7&lt;br /&gt;
|2&lt;br /&gt;
|6&lt;br /&gt;
|3&lt;br /&gt;
|4&lt;br /&gt;
|1&lt;br /&gt;
|6&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, «Zebra'''»'''  gets a lower rank than «apply'''»'''.  In Analytica 4.2 or later, you can supply the optional parameter «''caseInsensitive:true'''»''''':&lt;br /&gt;
  [[Rank]](D,I, caseInsensitive:true)&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using «[[Rank]](-X, i)».&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter &lt;br /&gt;
 [[Rank]](X, i, descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is referred to as a multi-key sort (or multi-key rank). The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, ''I''.  You must then introduce a new index, ''«''keyIndex''»'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by «I»'' and «''keyIndex''»''.  For example, the following ranks by age, then, in case of a tie, by gender:&lt;br /&gt;
 [[Index..Do|&amp;lt;code&amp;gt;Index&amp;lt;/code&amp;gt;]]&amp;lt;code&amp;gt; keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]](Array(keyIndex,[age,gender]), i, keyIndex )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
&lt;br /&gt;
This example shows how multi-key rank can be calculated by passing the optional «keyIndex''»'' parameter to the rank function. The rank of the cars by the number of maintenance events using index «maintType''»'' as the «keyIndex''»'' is returned.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;7&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:100px;&amp;quot; |'''MaintType &amp;amp;#9660; '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''6'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
!'''Repair''' &lt;br /&gt;
| 10&lt;br /&gt;
| 4&lt;br /&gt;
| 9&lt;br /&gt;
| 4&lt;br /&gt;
| 4&lt;br /&gt;
| 1&lt;br /&gt;
| 4&lt;br /&gt;
|-&lt;br /&gt;
!'''Scheduled'''&lt;br /&gt;
| 0&lt;br /&gt;
| 2&lt;br /&gt;
| 0&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 0&lt;br /&gt;
| 5&lt;br /&gt;
|-&lt;br /&gt;
!'''Tires''' &lt;br /&gt;
| 0&lt;br /&gt;
| 2&lt;br /&gt;
| 0&lt;br /&gt;
| 0&lt;br /&gt;
| 1&lt;br /&gt;
| 0&lt;br /&gt;
| 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a ''«''[[NaN]] value occurs in your data, [[Rank]] can either pass it through as a [[NaN]] or assign it a numeric rank.  The optional ''«passNaNs»'' parameter controls this behavior.  The special value [[NaN]] indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of ''«''[[NaN]] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results. This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value.  To pass NaNs, include the optional parameter ''«''passNaNs:true''».''&lt;br /&gt;
 [[Rank]](x, i, passNaNs:true).&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter. When this is not specified, Null values are assigned a rank (with «[[Null|Null»]]''''' '''''coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36378</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36378"/>
		<updated>2015-11-01T10:48:16Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]]&amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rank(x, i)==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Rank(x,i)&amp;lt;/tt&amp;gt; returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter «i» is unnecessary. A one-dimensional array is returned, indexed by «Years». This array has a value of 1 where «Year» has the smallest value, a value of 2 where «Year» has the second smallest value, and so on.&lt;br /&gt;
 &amp;lt;tt&amp;gt;Rank(Years)&amp;lt;/tt&amp;gt; →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the example below, the Rank function works with a multidimensional table. Each car type is given a rank for each year, with the cheapest car in that year given 1 and the most expensive car in that year given 3. &lt;br /&gt;
 &amp;lt;tt&amp;gt;Rank(Car_prices, Car_type)&amp;lt;/tt&amp;gt; →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
| 1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
If two (or «n) values are equal, they receive the same rank and the next higher value receives a rank 2 (or n) higher. You can use an optional parameter, «Type», to control which rank is assigned to equal values. By default, the lowest rank is used, equivalent to «'''Rank(x, i, Type:-1)'''» Alternatively, «Rank(x, i, Type:0)»''' '''uses the mid-rank and «Rank(x, i, Type:1)»''' '''uses the upper-rank. «Rank(x, i, Type:Null)»''' '''assigns a unique rank to every element (the numbers 1 thru n) in which tied elements may have different ranks.&lt;br /&gt;
&lt;br /&gt;
The example below shows how the Rank function handles duplicate values.&lt;br /&gt;
&lt;br /&gt;
For «Type =: -1'''»''', lowest rank for the duplicate value is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: 0», mid rank value of the duplicates is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: 1», highest rank for the duplicate value is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: NULL», Unique rank value is returned.&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;7&amp;quot; | Rank Type '''&amp;amp;#9660;''', CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''6'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
|'''-1'''&lt;br /&gt;
|7&lt;br /&gt;
| 2&lt;br /&gt;
|6&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|1&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''0'''&lt;br /&gt;
|7&lt;br /&gt;
|3.5&lt;br /&gt;
|6&lt;br /&gt;
|3.5&lt;br /&gt;
|3.5&lt;br /&gt;
|1&lt;br /&gt;
|3.5&lt;br /&gt;
|-&lt;br /&gt;
|'''1'''&lt;br /&gt;
|7&lt;br /&gt;
|5&lt;br /&gt;
|6&lt;br /&gt;
|5&lt;br /&gt;
|5&lt;br /&gt;
|1&lt;br /&gt;
|5&lt;br /&gt;
|-&lt;br /&gt;
|'''Null'''&lt;br /&gt;
|7&lt;br /&gt;
|2&lt;br /&gt;
|6&lt;br /&gt;
|3&lt;br /&gt;
|4&lt;br /&gt;
|1&lt;br /&gt;
|6&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, «Zebra'''»'''  gets a lower rank than «apply'''»'''.  In Analytica 4.2 or later, you can supply the optional parameter «''caseInsensitive:true'''»''''':&lt;br /&gt;
  [[Rank]](D,I, caseInsensitive:true)&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using «[[Rank]](-X, i)».&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter &lt;br /&gt;
 [[Rank]](X, i, descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is referred to as a multi-key sort (or multi-key rank). The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, ''I''.  You must then introduce a new index, ''«''keyIndex''»'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by «I»'' and «''keyIndex''»''.  For example, the following ranks by age, then, in case of a tie, by gender:&lt;br /&gt;
 [[Index..Do|&amp;lt;code&amp;gt;Index&amp;lt;/code&amp;gt;]]&amp;lt;code&amp;gt; keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]](Array(keyIndex,[age,gender]), i, keyIndex )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
&lt;br /&gt;
This example shows how multi-key rank can be calculated by passing the optional «keyIndex''»'' parameter to the rank function. The rank of the cars by the number of maintenance events using index «maintType''»'' as the «keyIndex''»'' is returned.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;7&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:100px;&amp;quot; |'''MaintType &amp;amp;#9660; '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''6'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
!'''Repair''' &lt;br /&gt;
| 10&lt;br /&gt;
| 4&lt;br /&gt;
| 9&lt;br /&gt;
| 4&lt;br /&gt;
| 4&lt;br /&gt;
| 1&lt;br /&gt;
| 4&lt;br /&gt;
|-&lt;br /&gt;
!'''Scheduled'''&lt;br /&gt;
| 0&lt;br /&gt;
| 2&lt;br /&gt;
| 0&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 0&lt;br /&gt;
| 5&lt;br /&gt;
|-&lt;br /&gt;
!'''Tires''' &lt;br /&gt;
| 0&lt;br /&gt;
| 2&lt;br /&gt;
| 0&lt;br /&gt;
| 0&lt;br /&gt;
| 1&lt;br /&gt;
| 0&lt;br /&gt;
| 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a ''«''[[NaN]] value occurs in your data, [[Rank]] can either pass it through as a [[NaN]] or assign it a numeric rank.  The optional ''«passNaNs»'' parameter controls this behavior.  The special value [[NaN]] indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of ''«''[[NaN]] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results. This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value.  To pass NaNs, include the optional parameter ''«''passNaNs:true''».''&lt;br /&gt;
 [[Rank]](x, i, passNaNs:true).&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter. When this is not specified, Null values are assigned a rank (with «[[Null|Null»]]''''' '''''coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36377</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36377"/>
		<updated>2015-11-01T10:43:53Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]]&amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rank(x, i)==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Rank(x,i)&amp;lt;/tt&amp;gt; returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter «i» is unnecessary. A one-dimensional array is returned, indexed by «Years». This array has a value of 1 where «Year» has the smallest value, a value of 2 where «Year» has the second smallest value, and so on.&lt;br /&gt;
 &amp;lt;tt&amp;gt;Rank(Years)&amp;lt;/tt&amp;gt; →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the example below, the Rank function works with a multidimensional table. Each car type is given a rank for each year, with the cheapest car in that year given 1 and the most expensive car in that year given 3. &lt;br /&gt;
 &amp;lt;tt&amp;gt;Rank(Car_prices, Car_type)&amp;lt;/tt&amp;gt; →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
| 1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
If two (or «n) values are equal, they receive the same rank and the next higher value receives a rank 2 (or n) higher. You can use an optional parameter, «Type», to control which rank is assigned to equal values. By default, the lowest rank is used, equivalent to «'''Rank(x, i, Type:-1)'''» Alternatively, «Rank(x, i, Type:0)»''' '''uses the mid-rank and «Rank(x, i, Type:1)»''' '''uses the upper-rank. «Rank(x, i, Type:Null)»''' '''assigns a unique rank to every element (the numbers 1 thru n) in which tied elements may have different ranks.&lt;br /&gt;
&lt;br /&gt;
The example below shows how the Rank function handles duplicate values.&lt;br /&gt;
&lt;br /&gt;
For «Type =: -1'''»''', lowest rank for the duplicate value is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: 0», mid rank value of the duplicates is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: 1», highest rank for the duplicate value is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type =: NULL», Unique rank value is returned.&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;7&amp;quot; | Rank Type '''&amp;amp;#9660;''', CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''6'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
|'''-1'''&lt;br /&gt;
|7&lt;br /&gt;
| 2&lt;br /&gt;
|6&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|1&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''0'''&lt;br /&gt;
|7&lt;br /&gt;
|3.5&lt;br /&gt;
|6&lt;br /&gt;
|3.5&lt;br /&gt;
|3.5&lt;br /&gt;
|1&lt;br /&gt;
|3.5&lt;br /&gt;
|-&lt;br /&gt;
|'''1'''&lt;br /&gt;
|7&lt;br /&gt;
|5&lt;br /&gt;
|6&lt;br /&gt;
|5&lt;br /&gt;
|5&lt;br /&gt;
|1&lt;br /&gt;
|5&lt;br /&gt;
|-&lt;br /&gt;
|'''Null'''&lt;br /&gt;
|7&lt;br /&gt;
|2&lt;br /&gt;
|6&lt;br /&gt;
|3&lt;br /&gt;
|4&lt;br /&gt;
|1&lt;br /&gt;
|6&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, «Zebra'''»'''  gets a lower rank than «apply'''»'''.  In Analytica 4.2 or later, you can supply the optional parameter «''caseInsensitive:true'''»''''':&lt;br /&gt;
  [[Rank]](D,I, caseInsensitive:true)&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using «[[Rank]](-X, i)».&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter &lt;br /&gt;
 [[Rank]](X, i, descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is referred to as a multi-key sort (or multi-key rank). The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, ''I''.  You must then introduce a new index, ''«''keyIndex''»'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by «I»'' and «''keyIndex''»''.  For example, the following ranks by age, then, in case of a tie, by gender:&lt;br /&gt;
 [[Index..Do|&amp;lt;code&amp;gt;Index&amp;lt;/code&amp;gt;]]&amp;lt;code&amp;gt; keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]](Array(keyIndex,[age,gender]), i, keyIndex )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a ''«''[[NaN]] value occurs in your data, [[Rank]] can either pass it through as a [[NaN]] or assign it a numeric rank.  The optional ''«passNaNs»'' parameter controls this behavior.  The special value [[NaN]] indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of ''«''[[NaN]] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results. This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value.  To pass NaNs, include the optional parameter ''«''passNaNs:true''».''&lt;br /&gt;
 [[Rank]](x, i, passNaNs:true).&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter. When this is not specified, Null values are assigned a rank (with «[[Null|Null»]]''''' '''''coming after all numeric values).&lt;br /&gt;
===Multi-Key Example===&lt;br /&gt;
This example shows how multi-key rank can be calculated by passing the optional «keyIndex''»'' parameter to the rank function. The rank of the cars by the number of maintenance events using index «maintType''»'' as the «keyIndex''»'' is returned.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Rank(NumMaintEvents, CarNum, KeyIndex:MaintType) →&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| 7 || 4 || 6 || 2 || 3 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36376</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36376"/>
		<updated>2015-11-01T10:15:35Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: /* Type */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]]&amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rank(x, i)==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Rank(x,i)&amp;lt;/tt&amp;gt; returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter «i» is unnecessary. A one-dimensional array is returned, indexed by «Years». This array has a value of 1 where «Year» has the smallest value, a value of 2 where «Year» has the second smallest value, and so on.&lt;br /&gt;
 &amp;lt;tt&amp;gt;Rank(Years)&amp;lt;/tt&amp;gt; →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the example below, the Rank function works with a multidimensional table. Each car type is given a rank for each year, with the cheapest car in that year given 1 and the most expensive car in that year given 3. &lt;br /&gt;
 &amp;lt;tt&amp;gt;Rank(Car_prices, Car_type)&amp;lt;/tt&amp;gt; →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
| 1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
If two (or «n) values are equal, they receive the same rank and the next higher value receives a rank 2 (or n) higher. You can use an optional parameter, «'''Type»''', to control which rank is assigned&lt;br /&gt;
to equal values. By default, the lowest rank is used, equivalent to «'''Rank(x, i, Type:-1)'''» Alternatively, «'''Rank(x, i, Type:0)» '''uses the mid-rank and «'''Rank(x, i, Type:1)» '''uses the upper-rank. «'''Rank(x, i, Type:Null)» '''assigns a unique rank to every element (the numbers 1 thru «n») in which tied elements may have different ranks.&lt;br /&gt;
&lt;br /&gt;
The example below shows how the Rank function handles duplicate values.&lt;br /&gt;
 For «Type = -1'''»''', lowest rank for the duplicate value is returned.&lt;br /&gt;
&lt;br /&gt;
For «Type = 0», mid rank value of the duplicates is returned.&lt;br /&gt;
&lt;br /&gt;
 For «Type = 1'''»''', highest rank for the duplicate value is returned.&lt;br /&gt;
&lt;br /&gt;
 For «Type = NULL'''»''', Unique rank value is returned.&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;7&amp;quot; | Rank Type '''&amp;amp;#9660;''', CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''6'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
|'''-1'''&lt;br /&gt;
|7&lt;br /&gt;
| 2&lt;br /&gt;
|6&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|1&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''0'''&lt;br /&gt;
|7&lt;br /&gt;
|3.5&lt;br /&gt;
|6&lt;br /&gt;
|3.5&lt;br /&gt;
|3.5&lt;br /&gt;
|1&lt;br /&gt;
|3.5&lt;br /&gt;
|-&lt;br /&gt;
|'''1'''&lt;br /&gt;
|7&lt;br /&gt;
|5&lt;br /&gt;
|6&lt;br /&gt;
|5&lt;br /&gt;
|5&lt;br /&gt;
|1&lt;br /&gt;
|5&lt;br /&gt;
|-&lt;br /&gt;
|'''Null'''&lt;br /&gt;
|7&lt;br /&gt;
|2&lt;br /&gt;
|6&lt;br /&gt;
|3&lt;br /&gt;
|4&lt;br /&gt;
|1&lt;br /&gt;
|6&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, &amp;lt;nowiki&amp;gt;&amp;lt;tt&amp;gt;Zebra &amp;lt;/tt&amp;gt;&amp;lt;/nowiki&amp;gt; gets a lower rank than &amp;lt;nowiki&amp;gt;&amp;lt;tt&amp;gt;apply&amp;lt;/tt&amp;gt;&amp;lt;/nowiki&amp;gt;.  In Analytica 4.2 or later, you can supply the optional parameter «''caseInsensitive:true'''»''''':&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](D,I, caseInsensitive:true)&lt;br /&gt;
&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](-X, i)&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](X, i, descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is referred to as a multi-key sort (or multi-key rank). The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, ''I''.  You must then introduce a new index, «''keyIndex'''»''''', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by «''I'''''»''''''' and «''keyIndex'''''»'''''''.  For example, the following ranks by age, then, in case of a tie, by gender:&lt;br /&gt;
 [[Index..Do|&amp;lt;code&amp;gt;Index&amp;lt;/code&amp;gt;]]&amp;lt;code&amp;gt; keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]](Array(keyIndex,[age,gender]), i, keyIndex )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a [[NaN]] value occurs in your data, [[Rank]] can either pass it through as a [[NaN]] or assign it a numeric rank.  The optional ''passNaNs'' parameter controls this behavior.  The special value [[NaN]] indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of [[NaN]] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results.  This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value.  To pass NaNs, include the optional parameter: &amp;lt;&amp;lt;nowiki&amp;gt;&amp;lt;tt&amp;gt;&amp;lt;/nowiki&amp;gt;[[Rank]](x, i, passNaNs:true)&amp;lt;nowiki&amp;gt;&amp;lt;/tt&amp;gt;&amp;lt;/nowiki&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](x, i, passNulls:true). &lt;br /&gt;
When this is not specified, Null values are assigned a rank (with «[[Null|Null'''''»''''']]''''' '''''coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
===Multi-Key Example===&lt;br /&gt;
This example shows how multi-key rank can be calculated by passing the optional «keyIndex'''''''»''''''' parameter to the rank frunction. The rank of the cars by the number of maintenance events using index «maintType'''''''»''''''' as the «keyIndex'''''''»''''''' is returned.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Rank(NumMaintEvents, CarNum, KeyIndex:MaintType) →&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| 7 || 4 || 6 || 2 || 3 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36375</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36375"/>
		<updated>2015-11-01T10:12:46Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: /* Multi-Key Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]]&amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rank(x, i)==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Rank(x,i)&amp;lt;/tt&amp;gt; returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter «i» is unnecessary. A one-dimensional array is returned, indexed by «Years». This array has a value of 1 where «Year» has the smallest value, a value of 2 where «Year» has the second smallest value, and so on.&lt;br /&gt;
 &amp;lt;tt&amp;gt;Rank(Years)&amp;lt;/tt&amp;gt; →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the example below, the Rank function works with a multidimensional table. Each car type is given a rank for each year, with the cheapest car in that year given 1 and the most expensive car in that year given 3. &lt;br /&gt;
 &amp;lt;tt&amp;gt;Rank(Car_prices, Car_type)&amp;lt;/tt&amp;gt; →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
| 1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
If two (or «n) values are equal, they receive the same rank and the next higher value receives a rank 2 (or n) higher. You can use an optional parameter, «'''Type»''', to control which rank is assigned&lt;br /&gt;
to equal values. By default, the lowest rank is used, equivalent to «'''Rank(x, i, Type:-1)'''» Alternatively, «'''Rank(x, i, Type:0)» '''uses the mid-rank and «'''Rank(x, i, Type:1)» '''uses the upper-rank. «'''Rank(x, i, Type:Null)» '''assigns a unique rank to every element (the numbers 1 thru «n») in which tied elements may have different ranks.&lt;br /&gt;
&lt;br /&gt;
The example below shows how the Rank function handles duplicate values.&lt;br /&gt;
 For «Type = -1'''»''', lowest rank for the duplicate value is returned.&lt;br /&gt;
&lt;br /&gt;
 For «Type = 0'''»''', mid rank value of the duplicates is returned.&lt;br /&gt;
&lt;br /&gt;
 For «Type = 1'''»''', highest rank for the duplicate value is returned.&lt;br /&gt;
&lt;br /&gt;
 For «Type = NULL'''»''', Unique rank value is returned.&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;7&amp;quot; | Rank Type '''&amp;amp;#9660;''', CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''6'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
|'''-1'''&lt;br /&gt;
|7&lt;br /&gt;
| 2&lt;br /&gt;
|6&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|1&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''0'''&lt;br /&gt;
|7&lt;br /&gt;
|3.5&lt;br /&gt;
|6&lt;br /&gt;
|3.5&lt;br /&gt;
|3.5&lt;br /&gt;
|1&lt;br /&gt;
|3.5&lt;br /&gt;
|-&lt;br /&gt;
|'''1'''&lt;br /&gt;
|7&lt;br /&gt;
|5&lt;br /&gt;
|6&lt;br /&gt;
|5&lt;br /&gt;
|5&lt;br /&gt;
|1&lt;br /&gt;
|5&lt;br /&gt;
|-&lt;br /&gt;
|'''Null'''&lt;br /&gt;
|7&lt;br /&gt;
|2&lt;br /&gt;
|6&lt;br /&gt;
|3&lt;br /&gt;
|4&lt;br /&gt;
|1&lt;br /&gt;
|6&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, &amp;lt;nowiki&amp;gt;&amp;lt;tt&amp;gt;Zebra &amp;lt;/tt&amp;gt;&amp;lt;/nowiki&amp;gt; gets a lower rank than &amp;lt;nowiki&amp;gt;&amp;lt;tt&amp;gt;apply&amp;lt;/tt&amp;gt;&amp;lt;/nowiki&amp;gt;.  In Analytica 4.2 or later, you can supply the optional parameter «''caseInsensitive:true'''»''''':&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](D,I, caseInsensitive:true)&lt;br /&gt;
&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](-X, i)&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](X, i, descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is referred to as a multi-key sort (or multi-key rank). The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, ''I''.  You must then introduce a new index, «''keyIndex'''»''''', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by «''I'''''»''''''' and «''keyIndex'''''»'''''''.  For example, the following ranks by age, then, in case of a tie, by gender:&lt;br /&gt;
 [[Index..Do|&amp;lt;code&amp;gt;Index&amp;lt;/code&amp;gt;]]&amp;lt;code&amp;gt; keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]](Array(keyIndex,[age,gender]), i, keyIndex )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a [[NaN]] value occurs in your data, [[Rank]] can either pass it through as a [[NaN]] or assign it a numeric rank.  The optional ''passNaNs'' parameter controls this behavior.  The special value [[NaN]] indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of [[NaN]] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results.  This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value.  To pass NaNs, include the optional parameter: &amp;lt;&amp;lt;nowiki&amp;gt;&amp;lt;tt&amp;gt;&amp;lt;/nowiki&amp;gt;[[Rank]](x, i, passNaNs:true)&amp;lt;nowiki&amp;gt;&amp;lt;/tt&amp;gt;&amp;lt;/nowiki&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](x, i, passNulls:true). &lt;br /&gt;
When this is not specified, Null values are assigned a rank (with «[[Null|Null'''''»''''']]''''' '''''coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
===Multi-Key Example===&lt;br /&gt;
This example shows how multi-key rank can be calculated by passing the optional «keyIndex'''''''»''''''' parameter to the rank frunction. The rank of the cars by the number of maintenance events using index «maintType'''''''»''''''' as the «keyIndex'''''''»''''''' is returned.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Rank(NumMaintEvents, CarNum, KeyIndex:MaintType) →&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| 7 || 4 || 6 || 2 || 3 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36374</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36374"/>
		<updated>2015-11-01T10:11:46Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]]&amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rank(x, i)==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Rank(x,i)&amp;lt;/tt&amp;gt; returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter «i» is unnecessary. A one-dimensional array is returned, indexed by «Years». This array has a value of 1 where «Year» has the smallest value, a value of 2 where «Year» has the second smallest value, and so on.&lt;br /&gt;
 &amp;lt;tt&amp;gt;Rank(Years)&amp;lt;/tt&amp;gt; →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the example below, the Rank function works with a multidimensional table. Each car type is given a rank for each year, with the cheapest car in that year given 1 and the most expensive car in that year given 3. &lt;br /&gt;
 &amp;lt;tt&amp;gt;Rank(Car_prices, Car_type)&amp;lt;/tt&amp;gt; →&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
| 1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
If two (or «n) values are equal, they receive the same rank and the next higher value receives a rank 2 (or n) higher. You can use an optional parameter, «'''Type»''', to control which rank is assigned&lt;br /&gt;
to equal values. By default, the lowest rank is used, equivalent to «'''Rank(x, i, Type:-1)'''» Alternatively, «'''Rank(x, i, Type:0)» '''uses the mid-rank and «'''Rank(x, i, Type:1)» '''uses the upper-rank. «'''Rank(x, i, Type:Null)» '''assigns a unique rank to every element (the numbers 1 thru «n») in which tied elements may have different ranks.&lt;br /&gt;
&lt;br /&gt;
The example below shows how the Rank function handles duplicate values.&lt;br /&gt;
 For «Type = -1'''»''', lowest rank for the duplicate value is returned.&lt;br /&gt;
&lt;br /&gt;
 For «Type = 0'''»''', mid rank value of the duplicates is returned.&lt;br /&gt;
&lt;br /&gt;
 For «Type = 1'''»''', highest rank for the duplicate value is returned.&lt;br /&gt;
&lt;br /&gt;
 For «Type = NULL'''»''', Unique rank value is returned.&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;7&amp;quot; | Rank Type '''&amp;amp;#9660;''', CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''6'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
|'''-1'''&lt;br /&gt;
|7&lt;br /&gt;
| 2&lt;br /&gt;
|6&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|1&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''0'''&lt;br /&gt;
|7&lt;br /&gt;
|3.5&lt;br /&gt;
|6&lt;br /&gt;
|3.5&lt;br /&gt;
|3.5&lt;br /&gt;
|1&lt;br /&gt;
|3.5&lt;br /&gt;
|-&lt;br /&gt;
|'''1'''&lt;br /&gt;
|7&lt;br /&gt;
|5&lt;br /&gt;
|6&lt;br /&gt;
|5&lt;br /&gt;
|5&lt;br /&gt;
|1&lt;br /&gt;
|5&lt;br /&gt;
|-&lt;br /&gt;
|'''Null'''&lt;br /&gt;
|7&lt;br /&gt;
|2&lt;br /&gt;
|6&lt;br /&gt;
|3&lt;br /&gt;
|4&lt;br /&gt;
|1&lt;br /&gt;
|6&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, &amp;lt;nowiki&amp;gt;&amp;lt;tt&amp;gt;Zebra &amp;lt;/tt&amp;gt;&amp;lt;/nowiki&amp;gt; gets a lower rank than &amp;lt;nowiki&amp;gt;&amp;lt;tt&amp;gt;apply&amp;lt;/tt&amp;gt;&amp;lt;/nowiki&amp;gt;.  In Analytica 4.2 or later, you can supply the optional parameter «''caseInsensitive:true'''»''''':&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](D,I, caseInsensitive:true)&lt;br /&gt;
&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](-X, i)&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](X, i, descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is referred to as a multi-key sort (or multi-key rank). The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, ''I''.  You must then introduce a new index, «''keyIndex'''»''''', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by «''I'''''»''''''' and «''keyIndex'''''»'''''''.  For example, the following ranks by age, then, in case of a tie, by gender:&lt;br /&gt;
 [[Index..Do|&amp;lt;code&amp;gt;Index&amp;lt;/code&amp;gt;]]&amp;lt;code&amp;gt; keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]](Array(keyIndex,[age,gender]), i, keyIndex )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a [[NaN]] value occurs in your data, [[Rank]] can either pass it through as a [[NaN]] or assign it a numeric rank.  The optional ''passNaNs'' parameter controls this behavior.  The special value [[NaN]] indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of [[NaN]] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results.  This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value.  To pass NaNs, include the optional parameter: &amp;lt;&amp;lt;nowiki&amp;gt;&amp;lt;tt&amp;gt;&amp;lt;/nowiki&amp;gt;[[Rank]](x, i, passNaNs:true)&amp;lt;nowiki&amp;gt;&amp;lt;/tt&amp;gt;&amp;lt;/nowiki&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](x, i, passNulls:true). &lt;br /&gt;
When this is not specified, Null values are assigned a rank (with «[[Null|Nul'''''''»''''''']] coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
===Multi-Key Example===&lt;br /&gt;
This example shows how multi-key rank can be calculated by passing the optional «keyIndex'''''''»''''''' parameter to the rank frunction. The rank of the cars by the number of maintenance events using index «maintType'''''''»''''''' as the «keyIndex'''''''»''''''' is returned.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Rank(NumMaintEvents, CarNum, KeyIndex:MaintType) →&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| 7 || 4 || 6 || 2 || 3 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36373</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36373"/>
		<updated>2015-11-01T09:50:19Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]]&amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rank(x, i)==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Rank(x,i)&amp;lt;/tt&amp;gt; returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter «i» is unnecessary. A one-dimensional array is returned, indexed by «Years». This array has a value of 1 where «Year» has the smallest value, a value of 2 where «Year» has the second smallest value, and so on.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Rank(Years)&amp;lt;/tt&amp;gt; → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the example below, the Rank function works with a multidimensional table. Each car type is given a rank for each year, with the cheapest car in that year given &amp;lt;nowiki&amp;gt;&amp;lt;tt&amp;gt;1&amp;lt;/tt&amp;gt;&amp;lt;/nowiki&amp;gt; and the most expensive car in that year given &amp;lt;nowiki&amp;gt;&amp;lt;tt&amp;gt;3&amp;lt;&amp;lt;/tt&amp;gt;&amp;lt;/nowiki&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Rank(Car_prices, Car_type)&amp;lt;/tt&amp;gt; → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
| 1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
If two (or N) values are equal, they receive the same rank and the next higher value receives a rank 2 (or N) higher. You&lt;br /&gt;
can use an optional parameter, '''Type''', to control which rank is assigned&lt;br /&gt;
to equal values. By default, the lowest rank is used, equivalent to '''Rank(x, i, Type:-1)'''. Alternatively, '''Rank(x, i, Type:0) '''uses the mid-rank and '''Rank(x, i, Type:1) '''uses the upper-rank. '''Rank(x, i, Type:Null) '''assigns a unique rank to every element (the numbers 1 thru N) in which tied elements may have different ranks.&lt;br /&gt;
&lt;br /&gt;
The example below shows how the Rank function handles duplicate values.&lt;br /&gt;
For Type = -1, lowest rank for the duplicate value is returned.&lt;br /&gt;
For Type = 0, mid rank value of the duplicates is returned.&lt;br /&gt;
For Type = 1, highest rank for the duplicate value is returned.&lt;br /&gt;
For Type = NULL, Unique rank value is returned.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;7&amp;quot; | Rank Type '''&amp;amp;#9660;''', CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''6'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
|'''-1'''&lt;br /&gt;
|7&lt;br /&gt;
| 2&lt;br /&gt;
|6&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|1&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''0'''&lt;br /&gt;
|7&lt;br /&gt;
|3.5&lt;br /&gt;
|6&lt;br /&gt;
|3.5&lt;br /&gt;
|3.5&lt;br /&gt;
|1&lt;br /&gt;
|3.5&lt;br /&gt;
|-&lt;br /&gt;
|'''1'''&lt;br /&gt;
|7&lt;br /&gt;
|5&lt;br /&gt;
|6&lt;br /&gt;
|5&lt;br /&gt;
|5&lt;br /&gt;
|1&lt;br /&gt;
|5&lt;br /&gt;
|-&lt;br /&gt;
|'''Null'''&lt;br /&gt;
|7&lt;br /&gt;
|2&lt;br /&gt;
|6&lt;br /&gt;
|3&lt;br /&gt;
|4&lt;br /&gt;
|1&lt;br /&gt;
|6&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, &amp;quot;Zebra&amp;quot; gets a lower rank than &amp;quot;apply&amp;quot;.  In Analytica 4.2 or later, you can supply the optional parameter ''caseInsensitive:true'':&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](D,I, caseInsensitive:true)&lt;br /&gt;
&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](-X, i)&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](X, i, descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is referred to as a multi-key sort (or multi-key rank). The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, ''I''.  You must then introduce a new index, ''keyIndex'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by ''I'' and ''keyIndex''.  For example, the following ranks by age, then for ties by gender:&lt;br /&gt;
 [[Index..Do|&amp;lt;code&amp;gt;Index&amp;lt;/code&amp;gt;]]&amp;lt;code&amp;gt; keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]](Array(keyIndex,[age,gender]), i, keyIndex )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a [[NaN]] value occurs in your data, [[Rank]] can either pass it through as a [[NaN]] or assign it a numeric rank.  The optional ''passNaNs'' parameter controls this behavior.  The special value [[NaN]] indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of [[NaN]] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results.  This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value.  To pass NaNs, include the optional parameter: [[Rank]](x, i, passNaNs:true)&lt;br /&gt;
&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](x, i, passNulls:true). &lt;br /&gt;
When this is not specified, Null values are assigned a rank (with [[Null]] coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
===Optional Type Parameter Examples===&lt;br /&gt;
&lt;br /&gt;
This example shows how the Rank function handles duplicate values.&lt;br /&gt;
For Type = -1, lowest rank for the duplicate value is returned.&lt;br /&gt;
For Type = 0, mid rank value of the duplicates is returned.&lt;br /&gt;
For Type = 1, highest rank for the duplicate value is returned.&lt;br /&gt;
For Type = NULL, Unique rank value is returned. &lt;br /&gt;
&lt;br /&gt;
Index Rank Type := [-1,0,1, Null] &lt;br /&gt;
&lt;br /&gt;
Rank(NumRepairs,CarNum,Type:RankType) →      &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! -1&lt;br /&gt;
| 7 || 2 || 6 || 2 || 2 || 1 || 2 &lt;br /&gt;
|-&lt;br /&gt;
! 0&lt;br /&gt;
| 7 || 3.5 || 6 || 3.5 || 3.5 || 1 || 3.5&lt;br /&gt;
|-&lt;br /&gt;
! 1&lt;br /&gt;
| 7 || 5 || 6 || 5 || 5 || 1 || 5&lt;br /&gt;
|-&lt;br /&gt;
! Null&lt;br /&gt;
| 7 || 2 || 6 || 3|| 4 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Multi-Key Example===&lt;br /&gt;
Rank(NumMaintEvents,CarNum,KeyIndex:MaintType) →&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| 7 || 4 || 6 || 2 || 3 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36372</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36372"/>
		<updated>2015-11-01T09:48:42Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]]&amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rank(x, i)==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Rank(x,i)&amp;lt;/tt&amp;gt; returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter «i» is unnecessary. A one-dimensional array is returned, indexed by «Years». This array has a value of 1 where «Year» has the smallest value, a value of 2 where «Year» has the second smallest value, and so on.&lt;br /&gt;
&lt;br /&gt;
Rank(Years) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the example below, the Rank function works with a multidimensional table. Each car type is given a rank for each year, with the cheapest car in that year given &amp;lt;nowiki&amp;gt;&amp;lt;tt&amp;gt;1&amp;lt;/tt&amp;gt;&amp;lt;/nowiki&amp;gt; and the most expensive car in that year given &amp;lt;nowiki&amp;gt;&amp;lt;tt&amp;gt;3&amp;lt;&amp;lt;/tt&amp;gt;&amp;lt;/nowiki&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&amp;lt;tt&amp;gt;Rank(Car_prices, Car_type)&amp;lt;/tt&amp;gt;&amp;lt;/nowiki&amp;gt; → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
| 1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
If two (or N) values are equal, they receive the same rank and the next higher value receives a rank 2 (or N) higher. You&lt;br /&gt;
can use an optional parameter, '''Type''', to control which rank is assigned&lt;br /&gt;
to equal values. By default, the lowest rank is used, equivalent to '''Rank(x, i, Type:-1)'''. Alternatively, '''Rank(x, i, Type:0) '''uses the mid-rank and '''Rank(x, i, Type:1) '''uses the upper-rank. '''Rank(x, i, Type:Null) '''assigns a unique rank to every element (the numbers 1 thru N) in which tied elements may have different ranks.&lt;br /&gt;
&lt;br /&gt;
The example below shows how the Rank function handles duplicate values.&lt;br /&gt;
For Type = -1, lowest rank for the duplicate value is returned.&lt;br /&gt;
For Type = 0, mid rank value of the duplicates is returned.&lt;br /&gt;
For Type = 1, highest rank for the duplicate value is returned.&lt;br /&gt;
For Type = NULL, Unique rank value is returned.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;7&amp;quot; | Rank Type '''&amp;amp;#9660;''', CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''6'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
|'''-1'''&lt;br /&gt;
|7&lt;br /&gt;
| 2&lt;br /&gt;
|6&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|1&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''0'''&lt;br /&gt;
|7&lt;br /&gt;
|3.5&lt;br /&gt;
|6&lt;br /&gt;
|3.5&lt;br /&gt;
|3.5&lt;br /&gt;
|1&lt;br /&gt;
|3.5&lt;br /&gt;
|-&lt;br /&gt;
|'''1'''&lt;br /&gt;
|7&lt;br /&gt;
|5&lt;br /&gt;
|6&lt;br /&gt;
|5&lt;br /&gt;
|5&lt;br /&gt;
|1&lt;br /&gt;
|5&lt;br /&gt;
|-&lt;br /&gt;
|'''Null'''&lt;br /&gt;
|7&lt;br /&gt;
|2&lt;br /&gt;
|6&lt;br /&gt;
|3&lt;br /&gt;
|4&lt;br /&gt;
|1&lt;br /&gt;
|6&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, &amp;quot;Zebra&amp;quot; gets a lower rank than &amp;quot;apply&amp;quot;.  In Analytica 4.2 or later, you can supply the optional parameter ''caseInsensitive:true'':&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](D,I, caseInsensitive:true)&lt;br /&gt;
&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](-X, i)&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](X, i, descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is referred to as a multi-key sort (or multi-key rank). The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, ''I''.  You must then introduce a new index, ''keyIndex'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by ''I'' and ''keyIndex''.  For example, the following ranks by age, then for ties by gender:&lt;br /&gt;
 [[Index..Do|&amp;lt;code&amp;gt;Index&amp;lt;/code&amp;gt;]]&amp;lt;code&amp;gt; keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]](Array(keyIndex,[age,gender]), i, keyIndex )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a [[NaN]] value occurs in your data, [[Rank]] can either pass it through as a [[NaN]] or assign it a numeric rank.  The optional ''passNaNs'' parameter controls this behavior.  The special value [[NaN]] indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of [[NaN]] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results.  This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value.  To pass NaNs, include the optional parameter: [[Rank]](x, i, passNaNs:true)&lt;br /&gt;
&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](x, i, passNulls:true). &lt;br /&gt;
When this is not specified, Null values are assigned a rank (with [[Null]] coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
===Optional Type Parameter Examples===&lt;br /&gt;
&lt;br /&gt;
This example shows how the Rank function handles duplicate values.&lt;br /&gt;
For Type = -1, lowest rank for the duplicate value is returned.&lt;br /&gt;
For Type = 0, mid rank value of the duplicates is returned.&lt;br /&gt;
For Type = 1, highest rank for the duplicate value is returned.&lt;br /&gt;
For Type = NULL, Unique rank value is returned. &lt;br /&gt;
&lt;br /&gt;
Index Rank Type := [-1,0,1, Null] &lt;br /&gt;
&lt;br /&gt;
Rank(NumRepairs,CarNum,Type:RankType) →      &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! -1&lt;br /&gt;
| 7 || 2 || 6 || 2 || 2 || 1 || 2 &lt;br /&gt;
|-&lt;br /&gt;
! 0&lt;br /&gt;
| 7 || 3.5 || 6 || 3.5 || 3.5 || 1 || 3.5&lt;br /&gt;
|-&lt;br /&gt;
! 1&lt;br /&gt;
| 7 || 5 || 6 || 5 || 5 || 1 || 5&lt;br /&gt;
|-&lt;br /&gt;
! Null&lt;br /&gt;
| 7 || 2 || 6 || 3|| 4 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Multi-Key Example===&lt;br /&gt;
Rank(NumMaintEvents,CarNum,KeyIndex:MaintType) →&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| 7 || 4 || 6 || 2 || 3 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36371</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36371"/>
		<updated>2015-11-01T09:45:05Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]]&amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rank(x, i)==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Rank(x,i)&amp;lt;/tt&amp;gt; returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter &amp;quot;I&amp;quot; is unnecessary. A one-dimensional array is returned, indexed by &amp;quot;Years&amp;quot;. This array has a value of 1 where &amp;quot;Year&amp;quot; has the smallest value, a value of 2 where &amp;quot;Year&amp;quot; has the second smallest value, and so on.&lt;br /&gt;
&lt;br /&gt;
Rank(Years) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the example below, the Rank function works with a multidimensional table. Each car type is given a rank for each year, with the cheapest car in that year given &amp;quot;1&amp;quot; and the most expensive car in that year given &amp;quot;3&amp;quot; &lt;br /&gt;
&lt;br /&gt;
Rank(Car_prices, Car_type) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
| 1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
If two (or N) values are equal, they receive the same rank and the next higher value receives a rank 2 (or N) higher. You&lt;br /&gt;
can use an optional parameter, '''Type''', to control which rank is assigned&lt;br /&gt;
to equal values. By default, the lowest rank is used, equivalent to '''Rank(x, i, Type:-1)'''. Alternatively, '''Rank(x, i, Type:0) '''uses the mid-rank and '''Rank(x, i, Type:1) '''uses the upper-rank. '''Rank(x, i, Type:Null) '''assigns a unique rank to every element (the numbers 1 thru N) in which tied elements may have different ranks.&lt;br /&gt;
&lt;br /&gt;
The example below shows how the Rank function handles duplicate values.&lt;br /&gt;
For Type = -1, lowest rank for the duplicate value is returned.&lt;br /&gt;
For Type = 0, mid rank value of the duplicates is returned.&lt;br /&gt;
For Type = 1, highest rank for the duplicate value is returned.&lt;br /&gt;
For Type = NULL, Unique rank value is returned.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;7&amp;quot; | Rank Type '''&amp;amp;#9660;''', CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''6'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
|'''-1'''&lt;br /&gt;
|7&lt;br /&gt;
| 2&lt;br /&gt;
|6&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|1&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''0'''&lt;br /&gt;
|7&lt;br /&gt;
|3.5&lt;br /&gt;
|6&lt;br /&gt;
|3.5&lt;br /&gt;
|3.5&lt;br /&gt;
|1&lt;br /&gt;
|3.5&lt;br /&gt;
|-&lt;br /&gt;
|'''1'''&lt;br /&gt;
|7&lt;br /&gt;
|5&lt;br /&gt;
|6&lt;br /&gt;
|5&lt;br /&gt;
|5&lt;br /&gt;
|1&lt;br /&gt;
|5&lt;br /&gt;
|-&lt;br /&gt;
|'''Null'''&lt;br /&gt;
|7&lt;br /&gt;
|2&lt;br /&gt;
|6&lt;br /&gt;
|3&lt;br /&gt;
|4&lt;br /&gt;
|1&lt;br /&gt;
|6&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, &amp;quot;Zebra&amp;quot; gets a lower rank than &amp;quot;apply&amp;quot;.  In Analytica 4.2 or later, you can supply the optional parameter ''caseInsensitive:true'':&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](D,I, caseInsensitive:true)&lt;br /&gt;
&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](-X, i)&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](X, i, descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is referred to as a multi-key sort (or multi-key rank). The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, ''I''.  You must then introduce a new index, ''keyIndex'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by ''I'' and ''keyIndex''.  For example, the following ranks by age, then for ties by gender:&lt;br /&gt;
 [[Index..Do|&amp;lt;code&amp;gt;Index&amp;lt;/code&amp;gt;]]&amp;lt;code&amp;gt; keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]](Array(keyIndex,[age,gender]), i, keyIndex )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a [[NaN]] value occurs in your data, [[Rank]] can either pass it through as a [[NaN]] or assign it a numeric rank.  The optional ''passNaNs'' parameter controls this behavior.  The special value [[NaN]] indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of [[NaN]] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results.  This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value.  To pass NaNs, include the optional parameter: [[Rank]](x, i, passNaNs:true)&lt;br /&gt;
&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](x, i, passNulls:true). &lt;br /&gt;
When this is not specified, Null values are assigned a rank (with [[Null]] coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
===Optional Type Parameter Examples===&lt;br /&gt;
&lt;br /&gt;
This example shows how the Rank function handles duplicate values.&lt;br /&gt;
For Type = -1, lowest rank for the duplicate value is returned.&lt;br /&gt;
For Type = 0, mid rank value of the duplicates is returned.&lt;br /&gt;
For Type = 1, highest rank for the duplicate value is returned.&lt;br /&gt;
For Type = NULL, Unique rank value is returned. &lt;br /&gt;
&lt;br /&gt;
Index Rank Type := [-1,0,1, Null] &lt;br /&gt;
&lt;br /&gt;
Rank(NumRepairs,CarNum,Type:RankType) →      &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! -1&lt;br /&gt;
| 7 || 2 || 6 || 2 || 2 || 1 || 2 &lt;br /&gt;
|-&lt;br /&gt;
! 0&lt;br /&gt;
| 7 || 3.5 || 6 || 3.5 || 3.5 || 1 || 3.5&lt;br /&gt;
|-&lt;br /&gt;
! 1&lt;br /&gt;
| 7 || 5 || 6 || 5 || 5 || 1 || 5&lt;br /&gt;
|-&lt;br /&gt;
! Null&lt;br /&gt;
| 7 || 2 || 6 || 3|| 4 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Multi-Key Example===&lt;br /&gt;
Rank(NumMaintEvents,CarNum,KeyIndex:MaintType) →&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| 7 || 4 || 6 || 2 || 3 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36370</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36370"/>
		<updated>2015-11-01T09:39:08Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: /* Optional Type Parameter Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]]&amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rank(x, i)==&lt;br /&gt;
&lt;br /&gt;
Rank(x,i) returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter &amp;quot;I&amp;quot; is unnecessary. A one-dimensional array is returned, indexed by &amp;quot;Years&amp;quot;. This array has a value of 1 where &amp;quot;Year&amp;quot; has the smallest value, a value of 2 where &amp;quot;Year&amp;quot; has the second smallest value, and so on.&lt;br /&gt;
&lt;br /&gt;
Rank(Years) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the example below, the Rank function works with a multidimensional table. Each car type is given a rank for each year, with the cheapest car in that year given &amp;quot;1&amp;quot; and the most expensive car in that year given &amp;quot;3&amp;quot; &lt;br /&gt;
&lt;br /&gt;
Rank(Car_prices, Car_type) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
| 1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
If two (or N) values are equal, they receive the same rank and the next higher value receives a rank 2 (or N) higher. You&lt;br /&gt;
can use an optional parameter, '''Type''', to control which rank is assigned&lt;br /&gt;
to equal values. By default, the lowest rank is used, equivalent to '''Rank(x, i, Type:-1)'''. Alternatively, '''Rank(x, i, Type:0) '''uses the mid-rank and '''Rank(x, i, Type:1) '''uses the upper-rank. '''Rank(x, i, Type:Null) '''assigns a unique rank to every element (the numbers 1 thru N) in which tied elements may have different ranks.&lt;br /&gt;
&lt;br /&gt;
The example below shows how the Rank function handles duplicate values.&lt;br /&gt;
For Type = -1, lowest rank for the duplicate value is returned.&lt;br /&gt;
For Type = 0, mid rank value of the duplicates is returned.&lt;br /&gt;
For Type = 1, highest rank for the duplicate value is returned.&lt;br /&gt;
For Type = NULL, Unique rank value is returned.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;7&amp;quot; | Rank Type '''&amp;amp;#9660;''', CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''6'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
|'''-1'''&lt;br /&gt;
|7&lt;br /&gt;
| 2&lt;br /&gt;
|6&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|1&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''0'''&lt;br /&gt;
|7&lt;br /&gt;
|3.5&lt;br /&gt;
|6&lt;br /&gt;
|3.5&lt;br /&gt;
|3.5&lt;br /&gt;
|1&lt;br /&gt;
|3.5&lt;br /&gt;
|-&lt;br /&gt;
|'''1'''&lt;br /&gt;
|7&lt;br /&gt;
|5&lt;br /&gt;
|6&lt;br /&gt;
|5&lt;br /&gt;
|5&lt;br /&gt;
|1&lt;br /&gt;
|5&lt;br /&gt;
|-&lt;br /&gt;
|'''Null'''&lt;br /&gt;
|7&lt;br /&gt;
|2&lt;br /&gt;
|6&lt;br /&gt;
|3&lt;br /&gt;
|4&lt;br /&gt;
|1&lt;br /&gt;
|6&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, &amp;quot;Zebra&amp;quot; gets a lower rank than &amp;quot;apply&amp;quot;.  In Analytica 4.2 or later, you can supply the optional parameter ''caseInsensitive:true'':&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](D,I, caseInsensitive:true)&lt;br /&gt;
&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](-X, i)&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](X, i, descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is referred to as a multi-key sort (or multi-key rank). The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, ''I''.  You must then introduce a new index, ''keyIndex'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by ''I'' and ''keyIndex''.  For example, the following ranks by age, then for ties by gender:&lt;br /&gt;
 [[Index..Do|&amp;lt;code&amp;gt;Index&amp;lt;/code&amp;gt;]]&amp;lt;code&amp;gt; keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]](Array(keyIndex,[age,gender]), i, keyIndex )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a [[NaN]] value occurs in your data, [[Rank]] can either pass it through as a [[NaN]] or assign it a numeric rank.  The optional ''passNaNs'' parameter controls this behavior.  The special value [[NaN]] indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of [[NaN]] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results.  This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value.  To pass NaNs, include the optional parameter: [[Rank]](x, i, passNaNs:true)&lt;br /&gt;
&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](x, i, passNulls:true). &lt;br /&gt;
When this is not specified, Null values are assigned a rank (with [[Null]] coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
===Optional Type Parameter Examples===&lt;br /&gt;
&lt;br /&gt;
This example shows how the Rank function handles duplicate values.&lt;br /&gt;
For Type = -1, lowest rank for the duplicate value is returned.&lt;br /&gt;
For Type = 0, mid rank value of the duplicates is returned.&lt;br /&gt;
For Type = 1, highest rank for the duplicate value is returned.&lt;br /&gt;
For Type = NULL, Unique rank value is returned. &lt;br /&gt;
&lt;br /&gt;
Index RankType := [-1,0,1, Null] &lt;br /&gt;
&lt;br /&gt;
Rank(NumRepairs,CarNum,Type:RankType) →      &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! -1&lt;br /&gt;
| 7 || 2 || 6 || 2 || 2 || 1 || 2 &lt;br /&gt;
|-&lt;br /&gt;
! 0&lt;br /&gt;
| 7 || 3.5 || 6 || 3.5 || 3.5 || 1 || 3.5&lt;br /&gt;
|-&lt;br /&gt;
! 1&lt;br /&gt;
| 7 || 5 || 6 || 5 || 5 || 1 || 5&lt;br /&gt;
|-&lt;br /&gt;
! Null&lt;br /&gt;
| 7 || 2 || 6 || 3|| 4 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Multi-Key Example===&lt;br /&gt;
Rank(NumMaintEvents,CarNum,KeyIndex:MaintType) →&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| 7 || 4 || 6 || 2 || 3 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36369</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36369"/>
		<updated>2015-11-01T06:45:25Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]]&amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rank(x, i)==&lt;br /&gt;
&lt;br /&gt;
Rank(x,i) returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter &amp;quot;I&amp;quot; is unnecessary. A one-dimensional array is returned, indexed by &amp;quot;Years&amp;quot;. This array has a value of 1 where &amp;quot;Year&amp;quot; has the smallest value, a value of 2 where &amp;quot;Year&amp;quot; has the second smallest value, and so on.&lt;br /&gt;
&lt;br /&gt;
Rank(Years) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the example below, the Rank function works with a multidimensional table. Each car type is given a rank for each year, with the cheapest car in that year given &amp;quot;1&amp;quot; and the most expensive car in that year given &amp;quot;3&amp;quot; &lt;br /&gt;
&lt;br /&gt;
Rank(Car_prices, Car_type) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
| 1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
If two (or N) values are equal, they receive the same rank and the next higher value receives a rank 2 (or N) higher. You&lt;br /&gt;
can use an optional parameter, '''Type''', to control which rank is assigned&lt;br /&gt;
to equal values. By default, the lowest rank is used, equivalent to '''Rank(x, i, Type:-1)'''. Alternatively, '''Rank(x, i, Type:0) '''uses the mid-rank and '''Rank(x, i, Type:1) '''uses the upper-rank. '''Rank(x, i, Type:Null) '''assigns a unique rank to every element (the numbers 1 thru N) in which tied elements may have different ranks.&lt;br /&gt;
&lt;br /&gt;
The example below shows how the Rank function handles duplicate values.&lt;br /&gt;
For Type = -1, lowest rank for the duplicate value is returned.&lt;br /&gt;
For Type = 0, mid rank value of the duplicates is returned.&lt;br /&gt;
For Type = 1, highest rank for the duplicate value is returned.&lt;br /&gt;
For Type = NULL, Unique rank value is returned.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;7&amp;quot; | Rank Type '''&amp;amp;#9660;''', CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''6'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
|'''-1'''&lt;br /&gt;
|7&lt;br /&gt;
| 2&lt;br /&gt;
|6&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|1&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''0'''&lt;br /&gt;
|7&lt;br /&gt;
|3.5&lt;br /&gt;
|6&lt;br /&gt;
|3.5&lt;br /&gt;
|3.5&lt;br /&gt;
|1&lt;br /&gt;
|3.5&lt;br /&gt;
|-&lt;br /&gt;
|'''1'''&lt;br /&gt;
|7&lt;br /&gt;
|5&lt;br /&gt;
|6&lt;br /&gt;
|5&lt;br /&gt;
|5&lt;br /&gt;
|1&lt;br /&gt;
|5&lt;br /&gt;
|-&lt;br /&gt;
|'''Null'''&lt;br /&gt;
|7&lt;br /&gt;
|2&lt;br /&gt;
|6&lt;br /&gt;
|3&lt;br /&gt;
|4&lt;br /&gt;
|1&lt;br /&gt;
|6&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, &amp;quot;Zebra&amp;quot; gets a lower rank than &amp;quot;apply&amp;quot;.  In Analytica 4.2 or later, you can supply the optional parameter ''caseInsensitive:true'':&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](D,I, caseInsensitive:true)&lt;br /&gt;
&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](-X, i)&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](X, i, descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is referred to as a multi-key sort (or multi-key rank). The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, ''I''.  You must then introduce a new index, ''keyIndex'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by ''I'' and ''keyIndex''.  For example, the following ranks by age, then for ties by gender:&lt;br /&gt;
 [[Index..Do|&amp;lt;code&amp;gt;Index&amp;lt;/code&amp;gt;]]&amp;lt;code&amp;gt; keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]](Array(keyIndex,[age,gender]), i, keyIndex )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a [[NaN]] value occurs in your data, [[Rank]] can either pass it through as a [[NaN]] or assign it a numeric rank.  The optional ''passNaNs'' parameter controls this behavior.  The special value [[NaN]] indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of [[NaN]] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results.  This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value.  To pass NaNs, include the optional parameter: [[Rank]](x, i, passNaNs:true)&lt;br /&gt;
&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](x, i, passNulls:true). &lt;br /&gt;
When this is not specified, Null values are assigned a rank (with [[Null]] coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
===Optional Type Parameter Examples===&lt;br /&gt;
&lt;br /&gt;
This example shows how the Rank function handles duplicate values.&lt;br /&gt;
For Type = -1, lowest rank for the duplicate value is returned.&lt;br /&gt;
For Type = 0, mid rank value of the duplicates is returned.&lt;br /&gt;
For Type = 1, highest rank for the duplicate value is returned.&lt;br /&gt;
For Type = NULL, Unique rank value is returned. &lt;br /&gt;
&lt;br /&gt;
Index RankType := [-1,0,1, Null] &lt;br /&gt;
&lt;br /&gt;
Rank(NumRepairs,CarNum,Type:RankType →      &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! -1&lt;br /&gt;
| 7 || 2 || 6 || 2 || 2 || 1 || 2 &lt;br /&gt;
|-&lt;br /&gt;
! 0&lt;br /&gt;
| 7 || 3.5 || 6 || 3.5 || 3.5 || 1 || 3.5&lt;br /&gt;
|-&lt;br /&gt;
! 1&lt;br /&gt;
| 7 || 5 || 6 || 5 || 5 || 1 || 5&lt;br /&gt;
|-&lt;br /&gt;
! Null&lt;br /&gt;
| 7 || 2 || 6 || 3|| 4 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Multi-Key Example===&lt;br /&gt;
Rank(NumMaintEvents,CarNum,KeyIndex:MaintType) →&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| 7 || 4 || 6 || 2 || 3 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36368</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36368"/>
		<updated>2015-11-01T06:43:51Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]]&amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rank(x, i)==&lt;br /&gt;
&lt;br /&gt;
Rank(x,i) returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter &amp;quot;I&amp;quot; is unnecessary. A one-dimensional array is returned, indexed by &amp;quot;Years&amp;quot;. This array has a value of 1 where &amp;quot;Year&amp;quot; has the smallest value, a value of 2 where &amp;quot;Year&amp;quot; has the second smallest value, and so on.&lt;br /&gt;
&lt;br /&gt;
Rank(Years) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the example below, the Rank function works with a multidimensional table. Each car type is given a rank for each year, with the cheapest car in that year given &amp;quot;1&amp;quot; and the most expensive car in that year given &amp;quot;3&amp;quot; &lt;br /&gt;
&lt;br /&gt;
Rank(Car_prices, Car_type) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
| 1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
If two (or N) values are equal, they receive the same rank and the next higher value receives a rank 2 (or N) higher. You&lt;br /&gt;
can use an optional parameter, '''Type''', to control which rank is assigned&lt;br /&gt;
to equal values. By default, the lowest rank is used, equivalent to '''Rank(x, i, Type:-1)'''. Alternatively, '''Rank(x, i, Type:0) '''uses the mid-rank and '''Rank(x, i, Type:1) '''uses the upper-rank. '''Rank(x, i, Type:Null) '''assigns a unique rank to every element (the numbers 1 thru N) in which tied elements may have different ranks.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;7&amp;quot; | Rank Type '''&amp;amp;#9660;''', CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''6'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''7'''&lt;br /&gt;
|-&lt;br /&gt;
|'''-1'''&lt;br /&gt;
|7&lt;br /&gt;
| 2&lt;br /&gt;
|6&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|1&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''0'''&lt;br /&gt;
|7&lt;br /&gt;
|3.5&lt;br /&gt;
|6&lt;br /&gt;
|3.5&lt;br /&gt;
|3.5&lt;br /&gt;
|1&lt;br /&gt;
|3.5&lt;br /&gt;
|-&lt;br /&gt;
|'''1'''&lt;br /&gt;
|7&lt;br /&gt;
|5&lt;br /&gt;
|6&lt;br /&gt;
|5&lt;br /&gt;
|5&lt;br /&gt;
|1&lt;br /&gt;
|5&lt;br /&gt;
|-&lt;br /&gt;
|'''Null'''&lt;br /&gt;
|7&lt;br /&gt;
|2&lt;br /&gt;
|6&lt;br /&gt;
|3&lt;br /&gt;
|4&lt;br /&gt;
|1&lt;br /&gt;
|6&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, &amp;quot;Zebra&amp;quot; gets a lower rank than &amp;quot;apply&amp;quot;.  In Analytica 4.2 or later, you can supply the optional parameter ''caseInsensitive:true'':&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](D,I, caseInsensitive:true)&lt;br /&gt;
&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](-X, i)&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](X, i, descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is referred to as a multi-key sort (or multi-key rank). The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, ''I''.  You must then introduce a new index, ''keyIndex'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by ''I'' and ''keyIndex''.  For example, the following ranks by age, then for ties by gender:&lt;br /&gt;
 [[Index..Do|&amp;lt;code&amp;gt;Index&amp;lt;/code&amp;gt;]]&amp;lt;code&amp;gt; keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]](Array(keyIndex,[age,gender]), i, keyIndex )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a [[NaN]] value occurs in your data, [[Rank]] can either pass it through as a [[NaN]] or assign it a numeric rank.  The optional ''passNaNs'' parameter controls this behavior.  The special value [[NaN]] indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of [[NaN]] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results.  This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value.  To pass NaNs, include the optional parameter: [[Rank]](x, i, passNaNs:true)&lt;br /&gt;
&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](x, i, passNulls:true). &lt;br /&gt;
When this is not specified, Null values are assigned a rank (with [[Null]] coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
===Optional Type Parameter Examples===&lt;br /&gt;
&lt;br /&gt;
This example shows how the Rank function handles duplicate values.&lt;br /&gt;
For Type = -1, lowest rank for the duplicate value is returned.&lt;br /&gt;
For Type = 0, mid rank value of the duplicates is returned.&lt;br /&gt;
For Type = 1, highest rank for the duplicate value is returned.&lt;br /&gt;
For Type = NULL, Unique rank value is returned. &lt;br /&gt;
&lt;br /&gt;
Index RankType := [-1,0,1, Null] &lt;br /&gt;
&lt;br /&gt;
Rank(NumRepairs,CarNum,Type:RankType →      &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! -1&lt;br /&gt;
| 7 || 2 || 6 || 2 || 2 || 1 || 2 &lt;br /&gt;
|-&lt;br /&gt;
! 0&lt;br /&gt;
| 7 || 3.5 || 6 || 3.5 || 3.5 || 1 || 3.5&lt;br /&gt;
|-&lt;br /&gt;
! 1&lt;br /&gt;
| 7 || 5 || 6 || 5 || 5 || 1 || 5&lt;br /&gt;
|-&lt;br /&gt;
! Null&lt;br /&gt;
| 7 || 2 || 6 || 3|| 4 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Multi-Key Example===&lt;br /&gt;
Rank(NumMaintEvents,CarNum,KeyIndex:MaintType) →&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| 7 || 4 || 6 || 2 || 3 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36367</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36367"/>
		<updated>2015-11-01T06:41:51Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]]&amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rank(x, i)==&lt;br /&gt;
&lt;br /&gt;
Rank(x,i) returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter &amp;quot;I&amp;quot; is unnecessary. A one-dimensional array is returned, indexed by &amp;quot;Years&amp;quot;. This array has a value of 1 where &amp;quot;Year&amp;quot; has the smallest value, a value of 2 where &amp;quot;Year&amp;quot; has the second smallest value, and so on.&lt;br /&gt;
&lt;br /&gt;
Rank(Years) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the example below, the Rank function works with a multidimensional table. Each car type is given a rank for each year, with the cheapest car in that year given &amp;quot;1&amp;quot; and the most expensive car in that year given &amp;quot;3&amp;quot; &lt;br /&gt;
&lt;br /&gt;
Rank(Car_prices, Car_type) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
| 1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
If two (or N) values are equal, they receive the same rank and the next higher value receives a rank 2 (or N) higher. You&lt;br /&gt;
can use an optional parameter, '''Type''', to control which rank is assigned&lt;br /&gt;
to equal values. By default, the lowest rank is used, equivalent to '''Rank(x, i, Type:-1)'''. Alternatively, '''Rank(x, i, Type:0) '''uses the mid-rank and '''Rank(x, i, Type:1) '''uses the upper-rank. '''Rank(x, i, Type:Null) '''assigns a unique rank to every element (the numbers 1 thru N) in which tied elements may have different ranks.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;7&amp;quot; | Rank Type '''&amp;amp;#9660;''', CarNum &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''5'''&lt;br /&gt;
!6&lt;br /&gt;
!7&lt;br /&gt;
|-&lt;br /&gt;
|'''-1'''&lt;br /&gt;
|7&lt;br /&gt;
| 2&lt;br /&gt;
|6&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|1&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''0'''&lt;br /&gt;
|7&lt;br /&gt;
|3.5&lt;br /&gt;
|6&lt;br /&gt;
|3.5&lt;br /&gt;
|3.5&lt;br /&gt;
|1&lt;br /&gt;
|3.5&lt;br /&gt;
|-&lt;br /&gt;
|'''1'''&lt;br /&gt;
|7&lt;br /&gt;
|5&lt;br /&gt;
|6&lt;br /&gt;
|5&lt;br /&gt;
|5&lt;br /&gt;
|1&lt;br /&gt;
|5&lt;br /&gt;
|-&lt;br /&gt;
|'''Null'''&lt;br /&gt;
|7&lt;br /&gt;
|2&lt;br /&gt;
|6&lt;br /&gt;
|3&lt;br /&gt;
|4&lt;br /&gt;
|1&lt;br /&gt;
|6&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, &amp;quot;Zebra&amp;quot; gets a lower rank than &amp;quot;apply&amp;quot;.  In Analytica 4.2 or later, you can supply the optional parameter ''caseInsensitive:true'':&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](D,I, caseInsensitive:true)&lt;br /&gt;
&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](-X, i)&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](X, i, descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is referred to as a multi-key sort (or multi-key rank). The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, ''I''.  You must then introduce a new index, ''keyIndex'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by ''I'' and ''keyIndex''.  For example, the following ranks by age, then for ties by gender:&lt;br /&gt;
 [[Index..Do|&amp;lt;code&amp;gt;Index&amp;lt;/code&amp;gt;]]&amp;lt;code&amp;gt; keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]](Array(keyIndex,[age,gender]), i, keyIndex )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a [[NaN]] value occurs in your data, [[Rank]] can either pass it through as a [[NaN]] or assign it a numeric rank.  The optional ''passNaNs'' parameter controls this behavior.  The special value [[NaN]] indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of [[NaN]] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results.  This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value.  To pass NaNs, include the optional parameter: [[Rank]](x, i, passNaNs:true)&lt;br /&gt;
&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](x, i, passNulls:true). &lt;br /&gt;
When this is not specified, Null values are assigned a rank (with [[Null]] coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
===Optional Type Parameter Examples===&lt;br /&gt;
&lt;br /&gt;
This example shows how the Rank function handles duplicate values.&lt;br /&gt;
For Type = -1, lowest rank for the duplicate value is returned.&lt;br /&gt;
For Type = 0, mid rank value of the duplicates is returned.&lt;br /&gt;
For Type = 1, highest rank for the duplicate value is returned.&lt;br /&gt;
For Type = NULL, Unique rank value is returned. &lt;br /&gt;
&lt;br /&gt;
Index RankType := [-1,0,1, Null] &lt;br /&gt;
&lt;br /&gt;
Rank(NumRepairs,CarNum,Type:RankType →      &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! -1&lt;br /&gt;
| 7 || 2 || 6 || 2 || 2 || 1 || 2 &lt;br /&gt;
|-&lt;br /&gt;
! 0&lt;br /&gt;
| 7 || 3.5 || 6 || 3.5 || 3.5 || 1 || 3.5&lt;br /&gt;
|-&lt;br /&gt;
! 1&lt;br /&gt;
| 7 || 5 || 6 || 5 || 5 || 1 || 5&lt;br /&gt;
|-&lt;br /&gt;
! Null&lt;br /&gt;
| 7 || 2 || 6 || 3|| 4 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Multi-Key Example===&lt;br /&gt;
Rank(NumMaintEvents,CarNum,KeyIndex:MaintType) →&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| 7 || 4 || 6 || 2 || 3 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36366</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36366"/>
		<updated>2015-11-01T06:33:08Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]]&amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rank(x, i)==&lt;br /&gt;
&lt;br /&gt;
Rank(x,i) returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter &amp;quot;I&amp;quot; is unnecessary. A one-dimensional array is returned, indexed by &amp;quot;Years&amp;quot;. This array has a value of 1 where &amp;quot;Year&amp;quot; has the smallest value, a value of 2 where &amp;quot;Year&amp;quot; has the second smallest value, and so on.&lt;br /&gt;
&lt;br /&gt;
Rank(Years) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the example below, the Rank function works with a multidimensional table. Each car type is given a rank for each year, with the cheapest car in that year given &amp;quot;1&amp;quot; and the most expensive car in that year given &amp;quot;3&amp;quot; &lt;br /&gt;
&lt;br /&gt;
Rank(Car_prices, Car_type) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
| 1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
If two (or N) values are equal, they receive the same rank and the next higher value receives a rank 2 (or N) higher. You&lt;br /&gt;
can use an optional parameter, '''Type''', to control which rank is assigned&lt;br /&gt;
to equal values. By default, the lowest rank is used, equivalent to '''Rank(x, i, Type:-1)'''. Alternatively, '''Rank(x, i, Type:0) '''uses the mid-rank and '''Rank(x, i, Type:1) '''uses the upper-rank. '''Rank(x, i, Type:Null) '''assigns a unique rank to every element (the numbers 1 thru N) in which tied elements may have different ranks.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, &amp;quot;Zebra&amp;quot; gets a lower rank than &amp;quot;apply&amp;quot;.  In Analytica 4.2 or later, you can supply the optional parameter ''caseInsensitive:true'':&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](D,I, caseInsensitive:true)&lt;br /&gt;
&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](-X, i)&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](X, i, descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is referred to as a multi-key sort (or multi-key rank). The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, ''I''.  You must then introduce a new index, ''keyIndex'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by ''I'' and ''keyIndex''.  For example, the following ranks by age, then for ties by gender:&lt;br /&gt;
 [[Index..Do|&amp;lt;code&amp;gt;Index&amp;lt;/code&amp;gt;]]&amp;lt;code&amp;gt; keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]](Array(keyIndex,[age,gender]), i, keyIndex )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a [[NaN]] value occurs in your data, [[Rank]] can either pass it through as a [[NaN]] or assign it a numeric rank.  The optional ''passNaNs'' parameter controls this behavior.  The special value [[NaN]] indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of [[NaN]] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results.  This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value.  To pass NaNs, include the optional parameter: [[Rank]](x, i, passNaNs:true)&lt;br /&gt;
&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](x, i, passNulls:true). &lt;br /&gt;
When this is not specified, Null values are assigned a rank (with [[Null]] coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
===Optional Type Parameter Examples===&lt;br /&gt;
&lt;br /&gt;
This example shows how the Rank function handles duplicate values.&lt;br /&gt;
For Type = -1, lowest rank for the duplicate value is returned.&lt;br /&gt;
For Type = 0, mid rank value of the duplicates is returned.&lt;br /&gt;
For Type = 1, highest rank for the duplicate value is returned.&lt;br /&gt;
For Type = NULL, Unique rank value is returned. &lt;br /&gt;
&lt;br /&gt;
Index RankType := [-1,0,1, Null] &lt;br /&gt;
&lt;br /&gt;
Rank(NumRepairs,CarNum,Type:RankType →      &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! -1&lt;br /&gt;
| 7 || 2 || 6 || 2 || 2 || 1 || 2 &lt;br /&gt;
|-&lt;br /&gt;
! 0&lt;br /&gt;
| 7 || 3.5 || 6 || 3.5 || 3.5 || 1 || 3.5&lt;br /&gt;
|-&lt;br /&gt;
! 1&lt;br /&gt;
| 7 || 5 || 6 || 5 || 5 || 1 || 5&lt;br /&gt;
|-&lt;br /&gt;
! Null&lt;br /&gt;
| 7 || 2 || 6 || 3|| 4 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Multi-Key Example===&lt;br /&gt;
Rank(NumMaintEvents,CarNum,KeyIndex:MaintType) →&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| 7 || 4 || 6 || 2 || 3 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36365</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36365"/>
		<updated>2015-11-01T06:30:49Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]]&amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rank(x, i)==&lt;br /&gt;
&lt;br /&gt;
Rank(x,i) returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter &amp;quot;I&amp;quot; is unnecessary. A one-dimensional array is returned, indexed by &amp;quot;Years&amp;quot;. This array has a value of 1 where &amp;quot;Year&amp;quot; has the smallest value, a value of 2 where &amp;quot;Year&amp;quot; has the second smallest value, and so on.&lt;br /&gt;
&lt;br /&gt;
Rank(Years) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the example below, the Rank function works with a multidimensional table. Each car type is given a rank for each year, with the cheapest car in that year given &amp;quot;1&amp;quot; and the most expensive car in that year given &amp;quot;3&amp;quot; &lt;br /&gt;
&lt;br /&gt;
Rank(Car_prices, Car_type) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
| 1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
If two (or N) values are equal, they receive the same rank and the next higher value receives a rank 2 (or N) higher. You&lt;br /&gt;
can use an optional parameter, '''Type''', to control which rank is assigned&lt;br /&gt;
to equal values. By default, the lowest rank is used, equivalent to '''Rank(x, i, Type:-1)'''. Alternatively, '''Rank(x, i, Type:0) '''uses the mid-rank and '''Rank(x, i, Type:1) '''uses the upper-rank. '''Rank(x, i, Type:Null) '''assigns a unique rank to every element (the numbers 1 thru N) in which tied elements may have different ranks.&lt;br /&gt;
&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, &amp;quot;Zebra&amp;quot; gets a lower rank than &amp;quot;apply&amp;quot;.  In Analytica 4.2 or later, you can supply the optional parameter ''caseInsensitive:true'':&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](D,I, caseInsensitive:true)&lt;br /&gt;
&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](-X, i)&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](X, i, descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is referred to as a multi-key sort (or multi-key rank). The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, ''I''.  You must then introduce a new index, ''keyIndex'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by ''I'' and ''keyIndex''.  For example, the following ranks by age, then for ties by gender:&lt;br /&gt;
 [[Index..Do|&amp;lt;code&amp;gt;Index&amp;lt;/code&amp;gt;]]&amp;lt;code&amp;gt; keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]](Array(keyIndex,[age,gender]), i, keyIndex )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a [[NaN]] value occurs in your data, [[Rank]] can either pass it through as a [[NaN]] or assign it a numeric rank.  The optional ''passNaNs'' parameter controls this behavior.  The special value [[NaN]] indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of [[NaN]] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results.  This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value.  To pass NaNs, include the optional parameter: [[Rank]](x, i, passNaNs:true)&lt;br /&gt;
&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter:&lt;br /&gt;
 &lt;br /&gt;
  [[Rank]](x, i, passNulls:true). &lt;br /&gt;
When this is not specified, Null values are assigned a rank (with [[Null]] coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
===Optional Type Parameter Examples===&lt;br /&gt;
&lt;br /&gt;
This example shows how the Rank function handles duplicate values.&lt;br /&gt;
For Type = -1, lowest rank for the duplicate value is returned.&lt;br /&gt;
For Type = 0, mid rank value of the duplicates is returned.&lt;br /&gt;
For Type = 1, highest rank for the duplicate value is returned.&lt;br /&gt;
For Type = NULL, Unique rank value is returned. &lt;br /&gt;
&lt;br /&gt;
Index RankType := [-1,0,1, Null] &lt;br /&gt;
&lt;br /&gt;
Rank(NumRepairs,CarNum,Type:RankType →      &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! -1&lt;br /&gt;
| 7 || 2 || 6 || 2 || 2 || 1 || 2 &lt;br /&gt;
|-&lt;br /&gt;
! 0&lt;br /&gt;
| 7 || 3.5 || 6 || 3.5 || 3.5 || 1 || 3.5&lt;br /&gt;
|-&lt;br /&gt;
! 1&lt;br /&gt;
| 7 || 5 || 6 || 5 || 5 || 1 || 5&lt;br /&gt;
|-&lt;br /&gt;
! Null&lt;br /&gt;
| 7 || 2 || 6 || 3|| 4 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Multi-Key Example===&lt;br /&gt;
Rank(NumMaintEvents,CarNum,KeyIndex:MaintType) →&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| 7 || 4 || 6 || 2 || 3 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Uncumulate&amp;diff=36364</id>
		<title>Uncumulate</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Uncumulate&amp;diff=36364"/>
		<updated>2015-11-01T06:15:00Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Array functions]]&lt;br /&gt;
[[Category:Doc Status D]] &amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
==Uncumulate(x, i, firstElement)==&lt;br /&gt;
&lt;br /&gt;
Finds the difference between each element of x and its predecessor along i.&lt;br /&gt;
&lt;br /&gt;
Uncumulate(x, i) returns an array whose first element (along i) is the first element of x, and each other element is the difference between the corresponding element of x and the previous element of x. &lt;br /&gt;
&lt;br /&gt;
Uncumulate(x, i, firstElement) returns an array with the first element along i equal to firstElement, and each other element equal to the difference between the corresponding element of x and the previous element of x.&lt;br /&gt;
&lt;br /&gt;
Uncumulate(x, i) is the inverse of Cumulate(x, i). Uncumulate(x, i, 0) is similar to a discrete differential operator.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
The following example returns a table that shows an increase in the cost ownership of certain car types over a certain period of time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Uncumulate (Cost_of_ownership, Time)&amp;lt;/code&amp;gt;→&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Time &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:100px;&amp;quot; |'''Car_type &amp;amp;#9660; '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''0'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
|-&lt;br /&gt;
!'''VW''' &lt;br /&gt;
| 2810&lt;br /&gt;
| 141&lt;br /&gt;
|147&lt;br /&gt;
|155&lt;br /&gt;
|163&lt;br /&gt;
|-&lt;br /&gt;
!'''Honda '''&lt;br /&gt;
| 3535&lt;br /&gt;
|312&lt;br /&gt;
|50&lt;br /&gt;
| 269&lt;br /&gt;
| 199&lt;br /&gt;
|-&lt;br /&gt;
!'''BMW''' &lt;br /&gt;
| 3185&lt;br /&gt;
| 109&lt;br /&gt;
| 115&lt;br /&gt;
| 120&lt;br /&gt;
| 127&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next example returns a table that shows the increase in the cost of ownership of cars compared to the previous time period and also sets the first value to 0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Uncumulate (Cost_of_ownership, Time, 0)&amp;lt;/code&amp;gt;→&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Time &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:100px;&amp;quot; |'''Car_type &amp;amp;#9660; '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''0'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
|-&lt;br /&gt;
!'''VW''' &lt;br /&gt;
| 0&lt;br /&gt;
| 141&lt;br /&gt;
| 147&lt;br /&gt;
| 155&lt;br /&gt;
| 163&lt;br /&gt;
|-&lt;br /&gt;
!'''Honda '''&lt;br /&gt;
| 0&lt;br /&gt;
| 312&lt;br /&gt;
| 50&lt;br /&gt;
| 269&lt;br /&gt;
| 199&lt;br /&gt;
|-&lt;br /&gt;
!'''BMW''' &lt;br /&gt;
| 0&lt;br /&gt;
| 109&lt;br /&gt;
| 115&lt;br /&gt;
| 120&lt;br /&gt;
| 127&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Cumulate]]&lt;br /&gt;
* [[Array_Function_Example_Variables|Example variables]]&lt;br /&gt;
* [http://wiki.analytica.com/User_Guide_Examples User Guide Examples] / [http://wiki.analytica.com/Media:_Array_Function_Examples.ana  Array Function Examples.ana] / Reducing Functions Module&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36363</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36363"/>
		<updated>2015-11-01T05:51:26Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: /* Optional Type Parameter Examples: */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]]&amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rank(x, i)==&lt;br /&gt;
&lt;br /&gt;
Rank(x,i) returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter &amp;quot;I&amp;quot; is unnecessary. A one-dimensional array is returned, indexed by &amp;quot;Years&amp;quot;. This array has a value of 1 where &amp;quot;Year&amp;quot; has the smallest value, a value of 2 where &amp;quot;Year&amp;quot; has the second smallest value, and so on.&lt;br /&gt;
&lt;br /&gt;
Rank(Years) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the example below, the Rank function works with a multidimensional table. Each car type is given a rank for each year, with the cheapest car in that year given &amp;quot;1&amp;quot; and the most expensive car in that year given &amp;quot;3&amp;quot; &lt;br /&gt;
&lt;br /&gt;
Rank(Car_prices, Car_type) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
| 1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, &amp;quot;Zebra&amp;quot; gets a lower rank than &amp;quot;apply&amp;quot;.  In Analytica 4.2 or later, you can supply the optional parameter ''caseInsensitive:true'':&lt;br /&gt;
 [[Rank]](D,I,caseInsensitive:true)&lt;br /&gt;
&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using:&lt;br /&gt;
 [[Rank]](-X,I)&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter:&lt;br /&gt;
 [[Rank]](X,I,descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is refered to as a multi-key sort (or multi-key rank).  The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, ''I''.  You must then introduce a new index, ''keyIndex'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by ''I'' and ''keyIndex''.  For example, the following ranks by age, then for ties by gender:&lt;br /&gt;
 [[Index..Do|Index]] keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]]( Array(keyIndex,[age,gender]), I, keyIndex )&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a [[NaN]] value occurs in your data, [[Rank]] can either pass it through as a [[NaN]] or assign it a numeric rank.  The optional ''passNaNs'' parameter controls this behavior.  The special value [[NaN]] indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of [[NaN]] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results.  This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value.  To pass NaNs, include the optional parameter: [[Rank]](X,I,passNaNs:true)&lt;br /&gt;
&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter:&lt;br /&gt;
 [[Rank]](X,I,passNulls:true). &lt;br /&gt;
When this is not specified, Null values are assigned a rank (with [[Null]] coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
===Optional Type Parameter Examples===&lt;br /&gt;
&lt;br /&gt;
Index RankType := [-1,0,1, Null] &lt;br /&gt;
&lt;br /&gt;
Rank(NumRepairs,CarNum,Type:RankType →   &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! -1&lt;br /&gt;
| 7 || 2 || 6 || 2 || 2 || 1 || 2 &lt;br /&gt;
|-&lt;br /&gt;
! 0&lt;br /&gt;
| 7 || 3.5 || 6 || 3.5 || 3.5 || 1 || 3.5&lt;br /&gt;
|-&lt;br /&gt;
! 1&lt;br /&gt;
| 7 || 5 || 6 || 5 || 5 || 1 || 5&lt;br /&gt;
|-&lt;br /&gt;
! Null&lt;br /&gt;
| 7 || 2 || 6 || 3|| 4 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Multi-Key Example===&lt;br /&gt;
Rank(NumMaintEvents,CarNum,KeyIndex:MaintType) → CarNum →&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| 7 || 4 || 6 || 2 || 3 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
See [[Example variables]] for example array variables used here and below.&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36362</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36362"/>
		<updated>2015-11-01T05:30:36Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]]&amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Rank(x, i)==&lt;br /&gt;
&lt;br /&gt;
Rank(x,i) returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter &amp;quot;I&amp;quot; is unnecessary. A one-dimensional array is returned, indexed by &amp;quot;Years&amp;quot;. This array has a value of 1 where &amp;quot;Year&amp;quot; has the smallest value, a value of 2 where &amp;quot;Year&amp;quot; has the second smallest value, and so on.&lt;br /&gt;
&lt;br /&gt;
Rank(Years) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the example below, the Rank function works with a multidimensional table. Each car type is given a rank for each year, with the cheapest car in that year given &amp;quot;1&amp;quot; and the most expensive car in that year given &amp;quot;3&amp;quot; &lt;br /&gt;
&lt;br /&gt;
Rank(Car_prices, Car_type) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
| 1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, &amp;quot;Zebra&amp;quot; gets a lower rank than &amp;quot;apply&amp;quot;.  In Analytica 4.2 or later, you can supply the optional parameter ''caseInsensitive:true'':&lt;br /&gt;
 [[Rank]](D,I,caseInsensitive:true)&lt;br /&gt;
&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using:&lt;br /&gt;
 [[Rank]](-X,I)&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter:&lt;br /&gt;
 [[Rank]](X,I,descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is refered to as a multi-key sort (or multi-key rank).  The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, ''I''.  You must then introduce a new index, ''keyIndex'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by ''I'' and ''keyIndex''.  For example, the following ranks by age, then for ties by gender:&lt;br /&gt;
 [[Index..Do|Index]] keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]]( Array(keyIndex,[age,gender]), I, keyIndex )&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a [[NaN]] value occurs in your data, [[Rank]] can either pass it through as a [[NaN]] or assign it a numeric rank.  The optional ''passNaNs'' parameter controls this behavior.  The special value [[NaN]] indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of [[NaN]] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results.  This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value.  To pass NaNs, include the optional parameter: [[Rank]](X,I,passNaNs:true)&lt;br /&gt;
&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter:&lt;br /&gt;
 [[Rank]](X,I,passNulls:true). &lt;br /&gt;
When this is not specified, Null values are assigned a rank (with [[Null]] coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
===Optional Type Parameter Examples:===&lt;br /&gt;
&lt;br /&gt;
Index RankType := [-1,0,1, Null] &lt;br /&gt;
&lt;br /&gt;
Rank(NumRepairs,CarNum,Type:RankType →   &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! -1&lt;br /&gt;
| 7 || 2 || 6 || 2 || 2 || 1 || 2 &lt;br /&gt;
|-&lt;br /&gt;
! 0&lt;br /&gt;
| 7 || 3.5 || 6 || 3.5 || 3.5 || 1 || 3.5&lt;br /&gt;
|-&lt;br /&gt;
! 1&lt;br /&gt;
| 7 || 5 || 6 || 5 || 5 || 1 || 5&lt;br /&gt;
|-&lt;br /&gt;
! Null&lt;br /&gt;
| 7 || 2 || 6 || 3|| 4 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Multi-Key Example:===&lt;br /&gt;
Rank(NumMaintEvents,CarNum,KeyIndex:MaintType) → CarNum →&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| 7 || 4 || 6 || 2 || 3 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
See [[Example variables]] for example array variables used here and below.&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36361</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36361"/>
		<updated>2015-11-01T05:28:44Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]]&amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ==Rank(x, i)==&lt;br /&gt;
&lt;br /&gt;
'''&amp;lt;code&amp;gt;Rank(x,i)&amp;lt;/code&amp;gt; '''returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter &amp;quot;I&amp;quot; is unnecessary. A one-dimensional array is returned, indexed by &amp;quot;Years&amp;quot;. This array has a value of 1 where &amp;quot;Year&amp;quot; has the smallest value, a value of 2 where &amp;quot;Year&amp;quot; has the second smallest value, and so on.&lt;br /&gt;
&lt;br /&gt;
Rank(Years) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the example below, the Rank function works with a multidimensional table. Each car type is given a rank for each year, with the cheapest car in that year given &amp;quot;1&amp;quot; and the most expensive car in that year given &amp;quot;3&amp;quot; &lt;br /&gt;
&lt;br /&gt;
Rank(Car_prices, Car_type) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
| 1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, &amp;quot;Zebra&amp;quot; gets a lower rank than &amp;quot;apply&amp;quot;.  In Analytica 4.2 or later, you can supply the optional parameter ''caseInsensitive:true'':&lt;br /&gt;
 [[Rank]](D,I,caseInsensitive:true)&lt;br /&gt;
&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using:&lt;br /&gt;
 [[Rank]](-X,I)&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter:&lt;br /&gt;
 [[Rank]](X,I,descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is refered to as a multi-key sort (or multi-key rank).  The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, ''I''.  You must then introduce a new index, ''keyIndex'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by ''I'' and ''keyIndex''.  For example, the following ranks by age, then for ties by gender:&lt;br /&gt;
 [[Index..Do|Index]] keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]]( Array(keyIndex,[age,gender]), I, keyIndex )&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a [[NaN]] value occurs in your data, [[Rank]] can either pass it through as a [[NaN]] or assign it a numeric rank.  The optional ''passNaNs'' parameter controls this behavior.  The special value [[NaN]] indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of [[NaN]] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results.  This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value.  To pass NaNs, include the optional parameter: [[Rank]](X,I,passNaNs:true)&lt;br /&gt;
&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter:&lt;br /&gt;
 [[Rank]](X,I,passNulls:true). &lt;br /&gt;
When this is not specified, Null values are assigned a rank (with [[Null]] coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
===Optional Type Parameter Examples:===&lt;br /&gt;
&lt;br /&gt;
Index RankType := [-1,0,1, Null] &lt;br /&gt;
&lt;br /&gt;
Rank(NumRepairs,CarNum,Type:RankType →   &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! -1&lt;br /&gt;
| 7 || 2 || 6 || 2 || 2 || 1 || 2 &lt;br /&gt;
|-&lt;br /&gt;
! 0&lt;br /&gt;
| 7 || 3.5 || 6 || 3.5 || 3.5 || 1 || 3.5&lt;br /&gt;
|-&lt;br /&gt;
! 1&lt;br /&gt;
| 7 || 5 || 6 || 5 || 5 || 1 || 5&lt;br /&gt;
|-&lt;br /&gt;
! Null&lt;br /&gt;
| 7 || 2 || 6 || 3|| 4 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Multi-Key Example:===&lt;br /&gt;
Rank(NumMaintEvents,CarNum,KeyIndex:MaintType) → CarNum →&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| 7 || 4 || 6 || 2 || 3 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
See [[Example variables]] for example array variables used here and below.&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36360</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36360"/>
		<updated>2015-11-01T05:27:27Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]] &amp;lt;!-- For Lumina use, do not change --&amp;gt;== Rank(x, i) ==&lt;br /&gt;
&lt;br /&gt;
'''&amp;lt;code&amp;gt;Rank(x,i)&amp;lt;/code&amp;gt; '''returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter &amp;quot;I&amp;quot; is unnecessary. A one-dimensional array is returned, indexed by &amp;quot;Years&amp;quot;. This array has a value of 1 where &amp;quot;Year&amp;quot; has the smallest value, a value of 2 where &amp;quot;Year&amp;quot; has the second smallest value, and so on.&lt;br /&gt;
&lt;br /&gt;
Rank(Years) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the example below, the Rank function works with a multidimensional table. Each car type is given a rank for each year, with the cheapest car in that year given &amp;quot;1&amp;quot; and the most expensive car in that year given &amp;quot;3&amp;quot; &lt;br /&gt;
&lt;br /&gt;
Rank(Car_prices, Car_type) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|'''VW'''&lt;br /&gt;
| 1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|'''Honda'''&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|2&lt;br /&gt;
|-&lt;br /&gt;
|'''BMW'''&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, &amp;quot;Zebra&amp;quot; gets a lower rank than &amp;quot;apply&amp;quot;.  In Analytica 4.2 or later, you can supply the optional parameter ''caseInsensitive:true'':&lt;br /&gt;
 [[Rank]](D,I,caseInsensitive:true)&lt;br /&gt;
&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using:&lt;br /&gt;
 [[Rank]](-X,I)&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter:&lt;br /&gt;
 [[Rank]](X,I,descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is refered to as a multi-key sort (or multi-key rank).  The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, ''I''.  You must then introduce a new index, ''keyIndex'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by ''I'' and ''keyIndex''.  For example, the following ranks by age, then for ties by gender:&lt;br /&gt;
 [[Index..Do|Index]] keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]]( Array(keyIndex,[age,gender]), I, keyIndex )&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a [[NaN]] value occurs in your data, [[Rank]] can either pass it through as a [[NaN]] or assign it a numeric rank.  The optional ''passNaNs'' parameter controls this behavior.  The special value [[NaN]] indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of [[NaN]] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results.  This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value.  To pass NaNs, include the optional parameter: [[Rank]](X,I,passNaNs:true)&lt;br /&gt;
&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter:&lt;br /&gt;
 [[Rank]](X,I,passNulls:true). &lt;br /&gt;
When this is not specified, Null values are assigned a rank (with [[Null]] coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
===Optional Type Parameter Examples:===&lt;br /&gt;
&lt;br /&gt;
Index RankType := [-1,0,1, Null] &lt;br /&gt;
&lt;br /&gt;
Rank(NumRepairs,CarNum,Type:RankType →   &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! -1&lt;br /&gt;
| 7 || 2 || 6 || 2 || 2 || 1 || 2 &lt;br /&gt;
|-&lt;br /&gt;
! 0&lt;br /&gt;
| 7 || 3.5 || 6 || 3.5 || 3.5 || 1 || 3.5&lt;br /&gt;
|-&lt;br /&gt;
! 1&lt;br /&gt;
| 7 || 5 || 6 || 5 || 5 || 1 || 5&lt;br /&gt;
|-&lt;br /&gt;
! Null&lt;br /&gt;
| 7 || 2 || 6 || 3|| 4 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Multi-Key Example:===&lt;br /&gt;
Rank(NumMaintEvents,CarNum,KeyIndex:MaintType) → CarNum →&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| 7 || 4 || 6 || 2 || 3 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
See [[Example variables]] for example array variables used here and below.&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36359</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36359"/>
		<updated>2015-11-01T05:19:06Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]] &amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Returns an array of the rank vaules of X across index I.  &lt;br /&gt;
&lt;br /&gt;
== Rank(x, i) ==&lt;br /&gt;
&lt;br /&gt;
'''&amp;lt;code&amp;gt;Rank(x,i)&amp;lt;/code&amp;gt; '''returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter &amp;quot;I&amp;quot; is unnecessary. A one-dimensional array is returned, indexed by &amp;quot;Years&amp;quot;. This array has a value of 1 where &amp;quot;Year&amp;quot; has the smallest value, a value of 2 where &amp;quot;Year&amp;quot; has the second smallest value, and so on.&lt;br /&gt;
&lt;br /&gt;
Rank(Years) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rank(Car_prices, Car_type) → &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 2005&lt;br /&gt;
! 2007&lt;br /&gt;
! 2007&lt;br /&gt;
! 2008&lt;br /&gt;
! 2009&lt;br /&gt;
|-&lt;br /&gt;
! VW&lt;br /&gt;
| 1 || 1 || 1 || 1 || 1 &lt;br /&gt;
|-&lt;br /&gt;
! Honda&lt;br /&gt;
| 2 || 2 || 2 || 2 || 2&lt;br /&gt;
|-&lt;br /&gt;
! BMW&lt;br /&gt;
| 3 || 3 || 3 || 3 || 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
===Case Sensitivity===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, &amp;quot;Zebra&amp;quot; gets a lower rank than &amp;quot;apply&amp;quot;.  In Analytica 4.2 or later, you can supply the optional parameter ''caseInsensitive:true'':&lt;br /&gt;
 [[Rank]](D,I,caseInsensitive:true)&lt;br /&gt;
&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using:&lt;br /&gt;
 [[Rank]](-X,I)&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter:&lt;br /&gt;
 [[Rank]](X,I,descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is refered to as a multi-key sort (or multi-key rank).  The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, ''I''.  You must then introduce a new index, ''keyIndex'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by ''I'' and ''keyIndex''.  For example, the following ranks by age, then for ties by gender:&lt;br /&gt;
 [[Index..Do|Index]] keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]]( Array(keyIndex,[age,gender]), I, keyIndex )&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a [[NaN]] value occurs in your data, [[Rank]] can either pass it through as a [[NaN]] or assign it a numeric rank.  The optional ''passNaNs'' parameter controls this behavior.  The special value [[NaN]] indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of [[NaN]] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results.  This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value.  To pass NaNs, include the optional parameter: [[Rank]](X,I,passNaNs:true)&lt;br /&gt;
&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter:&lt;br /&gt;
 [[Rank]](X,I,passNulls:true). &lt;br /&gt;
When this is not specified, Null values are assigned a rank (with [[Null]] coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
===Optional Type Parameter Examples:===&lt;br /&gt;
&lt;br /&gt;
Index RankType := [-1,0,1, Null] &lt;br /&gt;
&lt;br /&gt;
Rank(NumRepairs,CarNum,Type:RankType →   &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! -1&lt;br /&gt;
| 7 || 2 || 6 || 2 || 2 || 1 || 2 &lt;br /&gt;
|-&lt;br /&gt;
! 0&lt;br /&gt;
| 7 || 3.5 || 6 || 3.5 || 3.5 || 1 || 3.5&lt;br /&gt;
|-&lt;br /&gt;
! 1&lt;br /&gt;
| 7 || 5 || 6 || 5 || 5 || 1 || 5&lt;br /&gt;
|-&lt;br /&gt;
! Null&lt;br /&gt;
| 7 || 2 || 6 || 3|| 4 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Multi-Key Example:===&lt;br /&gt;
Rank(NumMaintEvents,CarNum,KeyIndex:MaintType) → CarNum →&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| 7 || 4 || 6 || 2 || 3 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
See [[Example variables]] for example array variables used here and below.&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36358</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36358"/>
		<updated>2015-11-01T05:12:23Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]] &amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Returns an array of the rank vaules of X across index I.  &lt;br /&gt;
&lt;br /&gt;
== Rank(x, i) ==&lt;br /&gt;
&lt;br /&gt;
'''&amp;lt;code&amp;gt;Rank(x,i)&amp;lt;/code&amp;gt; '''returns an array of the rank values of «x»''' '''across index «i». The lowest value in «x» has a rank value of 1, the next-lowest has a rank of 2, and so on.  «i» is optional if «x» is one-dimensional.   If «i» is omitted when «x» has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify «i» unless you can guarantee that «x» will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
===Advanced Variations ===&lt;br /&gt;
&lt;br /&gt;
 Rank(X : Array[I,keyIndex] ; I : Index ; rankType : optional ; keyIndex : Index ; descending, caseInsensitive : optional boolean[KeyIndex],&lt;br /&gt;
      passNaNs : optional boolean )&lt;br /&gt;
&lt;br /&gt;
=== Case Sensitivity ===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, &amp;quot;Zebra&amp;quot; gets a lower rank than &amp;quot;apply&amp;quot;.  In Analytica 4.2 or later, you can supply the optional parameter ''caseInsensitive:true'':&lt;br /&gt;
 [[Rank]](D,I,caseInsensitive:true)&lt;br /&gt;
&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using:&lt;br /&gt;
 [[Rank]](-X,I)&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter:&lt;br /&gt;
 [[Rank]](X,I,descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is refered to as a multi-key sort (or multi-key rank).  The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, ''I''.  You must then introduce a new index, ''keyIndex'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by ''I'' and ''keyIndex''.  For example, the following ranks by age, then for ties by gender:&lt;br /&gt;
 [[Index..Do|Index]] keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]]( Array(keyIndex,[age,gender]), I, keyIndex )&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a [[NaN]] value occurs in your data, [[Rank]] can either pass it through as a [[NaN]] or assign it a numeric rank.  The optional ''passNaNs'' parameter controls this behavior.  The special value [[NaN]] indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of [[NaN]] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results.  This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value.  To pass NaNs, include the optional parameter: [[Rank]](X,I,passNaNs:true)&lt;br /&gt;
&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter:&lt;br /&gt;
 [[Rank]](X,I,passNulls:true). &lt;br /&gt;
When this is not specified, Null values are assigned a rank (with [[Null]] coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
In the example below, the rank of a list is evaluated. Thus, the second parameter &amp;quot;I&amp;quot; is unnecessary. A one-dimensional array is returned, indexed by &amp;quot;Years&amp;quot;. This array has a value of 1 where &amp;quot;Year&amp;quot; has the smallest value, a value of 2 where &amp;quot;Year&amp;quot; has the second smallest value, and so on.&lt;br /&gt;
&lt;br /&gt;
Rank(Years) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rank(Car_prices, Car_type) → &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 2005&lt;br /&gt;
! 2007&lt;br /&gt;
! 2007&lt;br /&gt;
! 2008&lt;br /&gt;
! 2009&lt;br /&gt;
|-&lt;br /&gt;
! VW&lt;br /&gt;
| 1 || 1 || 1 || 1 || 1 &lt;br /&gt;
|-&lt;br /&gt;
! Honda&lt;br /&gt;
| 2 || 2 || 2 || 2 || 2&lt;br /&gt;
|-&lt;br /&gt;
! BMW&lt;br /&gt;
| 3 || 3 || 3 || 3 || 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Optional Type Parameter Example:===&lt;br /&gt;
&lt;br /&gt;
Index RankType := [-1,0,1, Null] &lt;br /&gt;
&lt;br /&gt;
Rank(NumRepairs,CarNum,Type:RankType →   &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! -1&lt;br /&gt;
| 7 || 2 || 6 || 2 || 2 || 1 || 2 &lt;br /&gt;
|-&lt;br /&gt;
! 0&lt;br /&gt;
| 7 || 3.5 || 6 || 3.5 || 3.5 || 1 || 3.5&lt;br /&gt;
|-&lt;br /&gt;
! 1&lt;br /&gt;
| 7 || 5 || 6 || 5 || 5 || 1 || 5&lt;br /&gt;
|-&lt;br /&gt;
! Null&lt;br /&gt;
| 7 || 2 || 6 || 3|| 4 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Multi-Key Example:===&lt;br /&gt;
Rank(NumMaintEvents,CarNum,KeyIndex:MaintType) → CarNum →&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| 7 || 4 || 6 || 2 || 3 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
See [[Example variables]] for example array variables used here and below.&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
===Type===&lt;br /&gt;
&lt;br /&gt;
If two (or N) values are equal, they receive the same rank and the next higher value receives a rank 2 (or N) higher. You can use an optional parameter, '''Type''', to control which rank is assigned to equal values. By default, the lowest rank is used, equivalent to '''Rank(x,i,Type:-1)'''. Alternatively, '''Rank(x,i,Type:0)''' uses the mid-rank and '''Rank(x,i,Type:1)''' uses the upper-rank. '''Rank(x,i,Type:Null)''' assigns a unique rank to every element (the numbers 1 thru N) in which tied elements may have different ranks.&lt;br /&gt;
&lt;br /&gt;
===keyIndex===&lt;br /&gt;
&lt;br /&gt;
A multi-key rank can be processed by indexing each key with a new index, and specifying this index for the optional '''keyIndex''' parameter. In a multi-key rank,  '''x[@KeyIndex=1]''' determines the rank order, except that ties are then resolved using '''x[@KeyIndex=2]''', any ties there are resolved using '''x[@KeyIndex=3]''', and so on.&lt;br /&gt;
&lt;br /&gt;
===descending===&lt;br /&gt;
&lt;br /&gt;
'''Rank(x,i,descending:true)''' assigns the largest value a rank 1, the second largest a rank 2, and so on.&lt;br /&gt;
&lt;br /&gt;
===caseInsensitive===&lt;br /&gt;
&lt;br /&gt;
When x contains textual values, the optional boolean parameter '''caseInsensitive''':true ignores upper-lower case differences during the comparisons. The parameters '''descending''' and '''caseInsensitive''' may also be indexed by the keyIndex when they vary by key.&lt;br /&gt;
&lt;br /&gt;
===passNaNs, passNulls===&lt;br /&gt;
&lt;br /&gt;
By default, ''Rank'' assigns an arbitrary ranking to '''NaN''' or '''Null''' values. Alternatively, you can pass these through to the result as '''NaN''' or '''Null''' using '''Rank(x,i,passNaNs:true, passNulls:true)'''.&lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
&lt;br /&gt;
===New to 4.0===&lt;br /&gt;
&lt;br /&gt;
The rank type determines how values in X that occur multiple times are ranked. For example, if the value x=5 occurs 6 times, and there are 3 other values in X that are less than 5, then x=5 appears in the sort-order at positions 4,5,6,7,8, and 9. The lower-rank of x=5 is 4, the upper-rank of x=5 is 9, and the mid-rank is 6.5. Note that a mid-rank is not necessary a valid index position (since it may be fractional), so if you intend to use the result of Rank in a slice function, you should use either the lower-rank (the default) or the upper-rank.&lt;br /&gt;
&lt;br /&gt;
===New to 4.2===&lt;br /&gt;
&lt;br /&gt;
When you want every element to be assigned a unique rank, you can specify ''rankType:null''.  Tied elements will be given unique ranks (with their position in the original array being used to break the tie).&lt;br /&gt;
&lt;br /&gt;
The [[RankCorrel]] function also allows you to select which rank type to use, but it uses mid-rank by default in Analytica 4.0.&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Examples variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36357</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36357"/>
		<updated>2015-11-01T04:44:19Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]] &amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Returns an array of the rank vaules of X across index I.  &lt;br /&gt;
&lt;br /&gt;
== Rank(x, i) ==&lt;br /&gt;
&lt;br /&gt;
The lowest value in &amp;lt;tt&amp;gt;x&amp;lt;/tt&amp;gt; has a rank value of 1, the next-lowest has a rank of 2, and so on.  &amp;lt;tt&amp;gt;i&amp;lt;/tt&amp;gt; is optional if &amp;lt;tt&amp;gt;x&amp;lt;/tt&amp;gt; is one-dimensional.   If &amp;lt;tt&amp;gt;i&amp;lt;/tt&amp;gt; is omitted when &amp;lt;tt&amp;gt;x&amp;lt;/tt&amp;gt; has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify &amp;lt;tt&amp;gt;i&amp;lt;/tt&amp;gt; unless you can guarantee that &amp;lt;tt&amp;gt;x&amp;lt;/tt&amp;gt;will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
===Advanced Variations ===&lt;br /&gt;
&lt;br /&gt;
 Rank(X : Array[I,keyIndex] ; I : Index ; rankType : optional ; keyIndex : Index ; descending, caseInsensitive : optional boolean[KeyIndex],&lt;br /&gt;
      passNaNs : optional boolean )&lt;br /&gt;
&lt;br /&gt;
=== Case Sensitivity ===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, &amp;quot;Zebra&amp;quot; gets a lower rank than &amp;quot;apply&amp;quot;.  In Analytica 4.2 or later, you can supply the optional parameter ''caseInsensitive:true'':&lt;br /&gt;
 [[Rank]](D,I,caseInsensitive:true)&lt;br /&gt;
&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using:&lt;br /&gt;
 [[Rank]](-X,I)&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter:&lt;br /&gt;
 [[Rank]](X,I,descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is refered to as a multi-key sort (or multi-key rank).  The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, ''I''.  You must then introduce a new index, ''keyIndex'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by ''I'' and ''keyIndex''.  For example, the following ranks by age, then for ties by gender:&lt;br /&gt;
 [[Index..Do|Index]] keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]]( Array(keyIndex,[age,gender]), I, keyIndex )&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a [[NaN]] value occurs in your data, [[Rank]] can either pass it through as a [[NaN]] or assign it a numeric rank.  The optional ''passNaNs'' parameter controls this behavior.  The special value [[NaN]] indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of [[NaN]] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results.  This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value.  To pass NaNs, include the optional parameter: [[Rank]](X,I,passNaNs:true)&lt;br /&gt;
&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter:&lt;br /&gt;
 [[Rank]](X,I,passNulls:true). &lt;br /&gt;
When this is not specified, Null values are assigned a rank (with [[Null]] coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
&lt;br /&gt;
===Basic Example===&lt;br /&gt;
&lt;br /&gt;
Rank(Years) → &lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rank(Car_prices, Car_type) → Car_type &amp;amp;darr;   , Years  →&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 2005&lt;br /&gt;
! 2007&lt;br /&gt;
! 2007&lt;br /&gt;
! 2008&lt;br /&gt;
! 2009&lt;br /&gt;
|-&lt;br /&gt;
! VW&lt;br /&gt;
| 1 || 1 || 1 || 1 || 1 &lt;br /&gt;
|-&lt;br /&gt;
! Honda&lt;br /&gt;
| 2 || 2 || 2 || 2 || 2&lt;br /&gt;
|-&lt;br /&gt;
! BMW&lt;br /&gt;
| 3 || 3 || 3 || 3 || 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Optional Type Parameter Example:===&lt;br /&gt;
&lt;br /&gt;
Index RankType := [-1,0,1, Null] &lt;br /&gt;
&lt;br /&gt;
Rank(NumRepairs,CarNum,Type:RankType → Rank_type &amp;amp;darr;  , CarNum →  &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! -1&lt;br /&gt;
| 7 || 2 || 6 || 2 || 2 || 1 || 2 &lt;br /&gt;
|-&lt;br /&gt;
! 0&lt;br /&gt;
| 7 || 3.5 || 6 || 3.5 || 3.5 || 1 || 3.5&lt;br /&gt;
|-&lt;br /&gt;
! 1&lt;br /&gt;
| 7 || 5 || 6 || 5 || 5 || 1 || 5&lt;br /&gt;
|-&lt;br /&gt;
! Null&lt;br /&gt;
| 7 || 2 || 6 || 3|| 4 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Multi-Key Example:===&lt;br /&gt;
Rank(NumMaintEvents,CarNum,KeyIndex:MaintType) → CarNum →&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| 7 || 4 || 6 || 2 || 3 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
See [[Example variables]] for example array variables used here and below.&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
===Type===&lt;br /&gt;
&lt;br /&gt;
If two (or N) values are equal, they receive the same rank and the next higher value receives a rank 2 (or N) higher. You can use an optional parameter, '''Type''', to control which rank is assigned to equal values. By default, the lowest rank is used, equivalent to '''Rank(x,i,Type:-1)'''. Alternatively, '''Rank(x,i,Type:0)''' uses the mid-rank and '''Rank(x,i,Type:1)''' uses the upper-rank. '''Rank(x,i,Type:Null)''' assigns a unique rank to every element (the numbers 1 thru N) in which tied elements may have different ranks.&lt;br /&gt;
&lt;br /&gt;
===keyIndex===&lt;br /&gt;
&lt;br /&gt;
A multi-key rank can be processed by indexing each key with a new index, and specifying this index for the optional '''keyIndex''' parameter. In a multi-key rank,  '''x[@KeyIndex=1]''' determines the rank order, except that ties are then resolved using '''x[@KeyIndex=2]''', any ties there are resolved using '''x[@KeyIndex=3]''', and so on.&lt;br /&gt;
&lt;br /&gt;
===descending===&lt;br /&gt;
&lt;br /&gt;
'''Rank(x,i,descending:true)''' assigns the largest value a rank 1, the second largest a rank 2, and so on.&lt;br /&gt;
&lt;br /&gt;
===caseInsensitive===&lt;br /&gt;
&lt;br /&gt;
When x contains textual values, the optional boolean parameter '''caseInsensitive''':true ignores upper-lower case differences during the comparisons. The parameters '''descending''' and '''caseInsensitive''' may also be indexed by the keyIndex when they vary by key.&lt;br /&gt;
&lt;br /&gt;
===passNaNs, passNulls===&lt;br /&gt;
&lt;br /&gt;
By default, ''Rank'' assigns an arbitrary ranking to '''NaN''' or '''Null''' values. Alternatively, you can pass these through to the result as '''NaN''' or '''Null''' using '''Rank(x,i,passNaNs:true, passNulls:true)'''.&lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
&lt;br /&gt;
===New to 4.0===&lt;br /&gt;
&lt;br /&gt;
The rank type determines how values in X that occur multiple times are ranked. For example, if the value x=5 occurs 6 times, and there are 3 other values in X that are less than 5, then x=5 appears in the sort-order at positions 4,5,6,7,8, and 9. The lower-rank of x=5 is 4, the upper-rank of x=5 is 9, and the mid-rank is 6.5. Note that a mid-rank is not necessary a valid index position (since it may be fractional), so if you intend to use the result of Rank in a slice function, you should use either the lower-rank (the default) or the upper-rank.&lt;br /&gt;
&lt;br /&gt;
===New to 4.2===&lt;br /&gt;
&lt;br /&gt;
When you want every element to be assigned a unique rank, you can specify ''rankType:null''.  Tied elements will be given unique ranks (with their position in the original array being used to break the tie).&lt;br /&gt;
&lt;br /&gt;
The [[RankCorrel]] function also allows you to select which rank type to use, but it uses mid-rank by default in Analytica 4.0.&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Example variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Rank&amp;diff=36356</id>
		<title>Rank</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Rank&amp;diff=36356"/>
		<updated>2015-11-01T04:41:36Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Sorting Functions]]&lt;br /&gt;
[[Category:Array Functions]]&lt;br /&gt;
[[Category:Doc Status C]] &amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Returns an array of the rank vaules of X across index I.  &lt;br /&gt;
&lt;br /&gt;
== Rank(x, i) ==&lt;br /&gt;
&lt;br /&gt;
The lowest value in &amp;lt;tt&amp;gt;x&amp;lt;/tt&amp;gt; has a rank value of 1, the next-lowest has a rank of 2, and so on.  &amp;lt;tt&amp;gt;i&amp;lt;/tt&amp;gt; is optional if &amp;lt;tt&amp;gt;x&amp;lt;/tt&amp;gt; is one-dimensional.   If &amp;lt;tt&amp;gt;i&amp;lt;/tt&amp;gt; is omitted when &amp;lt;tt&amp;gt;x&amp;lt;/tt&amp;gt; has more than one dimension, the innermost dimension is ranked.  Since you, as a modeler, have little control over which dimension is the inner dimension, you should always specify &amp;lt;tt&amp;gt;i&amp;lt;/tt&amp;gt; unless you can guarantee that &amp;lt;tt&amp;gt;x&amp;lt;/tt&amp;gt;will always be one-dimensional.&lt;br /&gt;
&lt;br /&gt;
===Advanced Variations ===&lt;br /&gt;
&lt;br /&gt;
 Rank(X : Array[I,keyIndex] ; I : Index ; rankType : optional ; keyIndex : Index ; descending, caseInsensitive : optional boolean[KeyIndex],&lt;br /&gt;
      passNaNs : optional boolean )&lt;br /&gt;
&lt;br /&gt;
=== Case Sensitivity ===&lt;br /&gt;
&lt;br /&gt;
When ranking text values, [[Rank]] treats text values as being case-sensitive with capital letters preceding lower case letters.  So, for example, &amp;quot;Zebra&amp;quot; gets a lower rank than &amp;quot;apply&amp;quot;.  In Analytica 4.2 or later, you can supply the optional parameter ''caseInsensitive:true'':&lt;br /&gt;
 [[Rank]](D,I,caseInsensitive:true)&lt;br /&gt;
&lt;br /&gt;
Case sensitivity only impacts text values.&lt;br /&gt;
&lt;br /&gt;
=== Descending rank ===&lt;br /&gt;
&lt;br /&gt;
You can easily reverse the rank of numeric arrays, where the largest numbers receive the lowest ranks, by simply using:&lt;br /&gt;
 [[Rank]](-X,I)&lt;br /&gt;
&lt;br /&gt;
For arrays containing text values, in Analytica 4.2 and later you can specify the optional ''descending:true'' parameter:&lt;br /&gt;
 [[Rank]](X,I,descending:true)&lt;br /&gt;
which uses the reverse rank order for text as well as numbers.&lt;br /&gt;
&lt;br /&gt;
=== Multi-key ranking ===&lt;br /&gt;
&lt;br /&gt;
When two values are tied for the same rank, a second array can be used to break the tie.  This is refered to as a multi-key sort (or multi-key rank).  The first array is the primary key, the next is the secondary key, and so on.  Analytica 4.2's [[Rank]] function support multi-key ranking.  To use, your keys must all share a common index, ''I''.  You must then introduce a new index, ''keyIndex'', to dimension your keys (any number of keys may be used), and bundle your keys into a 2-D array indexed by ''I'' and ''keyIndex''.  For example, the following ranks by age, then for ties by gender:&lt;br /&gt;
 [[Index..Do|Index]] keyIndex := ['age','gender'];&lt;br /&gt;
 [[Rank]]( Array(keyIndex,[age,gender]), I, keyIndex )&lt;br /&gt;
&lt;br /&gt;
=== Treatment of NaN and Null values ===&lt;br /&gt;
&lt;br /&gt;
When a [[NaN]] value occurs in your data, [[Rank]] can either pass it through as a [[NaN]] or assign it a numeric rank.  The optional ''passNaNs'' parameter controls this behavior.  The special value [[NaN]] indicates an indeterminate real number, which in theory cannot be compared to other numbers, so the ordering of [[NaN]] by [[Rank]] doesn't actually make logical sense.  By passing NaN values through without assigning an actual rank, you may catch errors in your model that lead to the introduction of the [[NaN]] value in the first place, since these errors continue to be propagated to your results.  This is often a desirable property.&lt;br /&gt;
&lt;br /&gt;
By default, [[Rank]] assigns an arbitrary ranking to [[NaN]] values -- placing them between -[[INF]] and any finite numeric value.  To pass NaNs, include the optional parameter: [[Rank]](X,I,passNaNs:true)&lt;br /&gt;
&lt;br /&gt;
[[Null]] values are sometimes used for missing data, and in these cases can also be passed using the passNulls:true parameter:&lt;br /&gt;
 [[Rank]](X,I,passNulls:true). &lt;br /&gt;
When this is not specified, Null values are assigned a rank (with [[Null]] coming after all numeric values).&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
&lt;br /&gt;
===Basic Example===&lt;br /&gt;
&lt;br /&gt;
Rank(Years) → &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Variable Rate_of_inflation :=&amp;lt;/code&amp;gt;&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Years &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |''' '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2005            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2006            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2007            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2008            '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2009            '''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rank(Car_prices, Car_type) → Car_type &amp;amp;darr;   , Years  →&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 2005&lt;br /&gt;
! 2007&lt;br /&gt;
! 2007&lt;br /&gt;
! 2008&lt;br /&gt;
! 2009&lt;br /&gt;
|-&lt;br /&gt;
! VW&lt;br /&gt;
| 1 || 1 || 1 || 1 || 1 &lt;br /&gt;
|-&lt;br /&gt;
! Honda&lt;br /&gt;
| 2 || 2 || 2 || 2 || 2&lt;br /&gt;
|-&lt;br /&gt;
! BMW&lt;br /&gt;
| 3 || 3 || 3 || 3 || 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Optional Type Parameter Example:===&lt;br /&gt;
&lt;br /&gt;
Index RankType := [-1,0,1, Null] &lt;br /&gt;
&lt;br /&gt;
Rank(NumRepairs,CarNum,Type:RankType → Rank_type &amp;amp;darr;  , CarNum →  &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! -1&lt;br /&gt;
| 7 || 2 || 6 || 2 || 2 || 1 || 2 &lt;br /&gt;
|-&lt;br /&gt;
! 0&lt;br /&gt;
| 7 || 3.5 || 6 || 3.5 || 3.5 || 1 || 3.5&lt;br /&gt;
|-&lt;br /&gt;
! 1&lt;br /&gt;
| 7 || 5 || 6 || 5 || 5 || 1 || 5&lt;br /&gt;
|-&lt;br /&gt;
! Null&lt;br /&gt;
| 7 || 2 || 6 || 3|| 4 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Multi-Key Example:===&lt;br /&gt;
Rank(NumMaintEvents,CarNum,KeyIndex:MaintType) → CarNum →&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
! 1&lt;br /&gt;
! 2&lt;br /&gt;
! 3&lt;br /&gt;
! 4&lt;br /&gt;
! 5&lt;br /&gt;
! 6&lt;br /&gt;
! 7&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| 7 || 4 || 6 || 2 || 3 || 1 || 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
See [[Example variables]] for example array variables used here and below.&lt;br /&gt;
&lt;br /&gt;
==Optional Parameters==&lt;br /&gt;
&lt;br /&gt;
===Type===&lt;br /&gt;
&lt;br /&gt;
If two (or N) values are equal, they receive the same rank and the next higher value receives a rank 2 (or N) higher. You can use an optional parameter, '''Type''', to control which rank is assigned to equal values. By default, the lowest rank is used, equivalent to '''Rank(x,i,Type:-1)'''. Alternatively, '''Rank(x,i,Type:0)''' uses the mid-rank and '''Rank(x,i,Type:1)''' uses the upper-rank. '''Rank(x,i,Type:Null)''' assigns a unique rank to every element (the numbers 1 thru N) in which tied elements may have different ranks.&lt;br /&gt;
&lt;br /&gt;
===keyIndex===&lt;br /&gt;
&lt;br /&gt;
A multi-key rank can be processed by indexing each key with a new index, and specifying this index for the optional '''keyIndex''' parameter. In a multi-key rank,  '''x[@KeyIndex=1]''' determines the rank order, except that ties are then resolved using '''x[@KeyIndex=2]''', any ties there are resolved using '''x[@KeyIndex=3]''', and so on.&lt;br /&gt;
&lt;br /&gt;
===descending===&lt;br /&gt;
&lt;br /&gt;
'''Rank(x,i,descending:true)''' assigns the largest value a rank 1, the second largest a rank 2, and so on.&lt;br /&gt;
&lt;br /&gt;
===caseInsensitive===&lt;br /&gt;
&lt;br /&gt;
When x contains textual values, the optional boolean parameter '''caseInsensitive''':true ignores upper-lower case differences during the comparisons. The parameters '''descending''' and '''caseInsensitive''' may also be indexed by the keyIndex when they vary by key.&lt;br /&gt;
&lt;br /&gt;
===passNaNs, passNulls===&lt;br /&gt;
&lt;br /&gt;
By default, ''Rank'' assigns an arbitrary ranking to '''NaN''' or '''Null''' values. Alternatively, you can pass these through to the result as '''NaN''' or '''Null''' using '''Rank(x,i,passNaNs:true, passNulls:true)'''.&lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
&lt;br /&gt;
===New to 4.0===&lt;br /&gt;
&lt;br /&gt;
The rank type determines how values in X that occur multiple times are ranked. For example, if the value x=5 occurs 6 times, and there are 3 other values in X that are less than 5, then x=5 appears in the sort-order at positions 4,5,6,7,8, and 9. The lower-rank of x=5 is 4, the upper-rank of x=5 is 9, and the mid-rank is 6.5. Note that a mid-rank is not necessary a valid index position (since it may be fractional), so if you intend to use the result of Rank in a slice function, you should use either the lower-rank (the default) or the upper-rank.&lt;br /&gt;
&lt;br /&gt;
===New to 4.2===&lt;br /&gt;
&lt;br /&gt;
When you want every element to be assigned a unique rank, you can specify ''rankType:null''.  Tied elements will be given unique ranks (with their position in the original array being used to break the tie).&lt;br /&gt;
&lt;br /&gt;
The [[RankCorrel]] function also allows you to select which rank type to use, but it uses mid-rank by default in Analytica 4.0.&lt;br /&gt;
&lt;br /&gt;
==See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Sort]]&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[RankCorrel]]&lt;br /&gt;
* [[Example variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Uncumulate&amp;diff=36355</id>
		<title>Uncumulate</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Uncumulate&amp;diff=36355"/>
		<updated>2015-11-01T04:19:45Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Array functions]]&lt;br /&gt;
[[Category:Doc Status D]] &amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
==Uncumulate(x, i, firstElement)==&lt;br /&gt;
&lt;br /&gt;
Finds the difference between each element of x and its predecessor along i.&lt;br /&gt;
&lt;br /&gt;
Uncumulate(x, i) returns an array whose first element (along i) is the first element of x, and each other element is the difference between the corresponding element of x and the previous element of x. &lt;br /&gt;
&lt;br /&gt;
Uncumulate(x, i, firstElement) returns an array with the first element along i equal to firstElement, and each other element equal to the difference between the corresponding element of x and the previous element of x.&lt;br /&gt;
&lt;br /&gt;
Uncumulate(x, i) is the inverse of Cumulate(x, i). Uncumulate(x, i, 0) is similar to a discrete differential operator.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
The following example returns a table that shows an increase in the cost ownership of certain car types over a certain period of time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Uncumulate (Cost_of_ownership, Time)&amp;lt;/code&amp;gt;→&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Time &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:100px;&amp;quot; |'''Car_type &amp;amp;#9660; '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''0'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
|-&lt;br /&gt;
!'''VW''' &lt;br /&gt;
| 2810&lt;br /&gt;
| 141&lt;br /&gt;
|147&lt;br /&gt;
|155&lt;br /&gt;
|163&lt;br /&gt;
|-&lt;br /&gt;
!'''Honda '''&lt;br /&gt;
| 3535&lt;br /&gt;
|312&lt;br /&gt;
|50&lt;br /&gt;
| 269&lt;br /&gt;
| 199&lt;br /&gt;
|-&lt;br /&gt;
!'''BMW''' &lt;br /&gt;
| 3185&lt;br /&gt;
| 109&lt;br /&gt;
| 115&lt;br /&gt;
| 120&lt;br /&gt;
| 127&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next example returns a table that shows the increase in the cost of ownership of cars compared to the previous time period and also sets the first value to 0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Uncumulate (Cost_of_ownership, Time, 0)&amp;lt;/code&amp;gt;→&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Time &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:100px;&amp;quot; |'''Car_type &amp;amp;#9660; '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''0'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
|-&lt;br /&gt;
!'''VW''' &lt;br /&gt;
| 0&lt;br /&gt;
| 141&lt;br /&gt;
| 147&lt;br /&gt;
| 155&lt;br /&gt;
| 163&lt;br /&gt;
|-&lt;br /&gt;
!'''Honda '''&lt;br /&gt;
| 0&lt;br /&gt;
| 312&lt;br /&gt;
| 50&lt;br /&gt;
| 269&lt;br /&gt;
| 199&lt;br /&gt;
|-&lt;br /&gt;
!'''BMW''' &lt;br /&gt;
| 0&lt;br /&gt;
| 109&lt;br /&gt;
| 115&lt;br /&gt;
| 120&lt;br /&gt;
| 127&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Cumulate]]&lt;br /&gt;
* [[Array_Function_Example_Variables|Example variables]]&lt;br /&gt;
* [http://wiki.analytica.com/User_Guide_Examples User Guide Examples] / [http://wiki.analytica.com/Media:_Array_Function_Examples.ana  Array Function Examples.ana] / Reducing Functions Module&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Uncumulate&amp;diff=36354</id>
		<title>Uncumulate</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Uncumulate&amp;diff=36354"/>
		<updated>2015-11-01T04:18:13Z</updated>

		<summary type="html">&lt;p&gt;JHernandez2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Transforming functions]]&lt;br /&gt;
[[Category:Array functions]]&lt;br /&gt;
[[Category:Doc Status D]] &amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
==Uncumulate(x, i, firstElement)==&lt;br /&gt;
&lt;br /&gt;
Finds the difference between each element of x and its predecessor along i.&lt;br /&gt;
&lt;br /&gt;
Uncumulate(x, i) returns an array whose first element (along i) is the first element of x, and each other element is the difference between the corresponding element of x and the previous element of x. &lt;br /&gt;
&lt;br /&gt;
Uncumulate(x, i, firstElement) returns an array with the first element along i equal to firstElement, and each other element equal to the difference between the corresponding element of x and the previous element of x.&lt;br /&gt;
&lt;br /&gt;
Uncumulate(x, i) is the inverse of Cumulate(x, i). Uncumulate(x, i, 0) is similar to a discrete differential operator.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
The following example returns a table that shows an increase in the cost ownership of certain car types over a certain period of time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Uncumulate (Cost_of_ownership, Time)&amp;lt;/code&amp;gt;→&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! !! colspan=&amp;quot;5&amp;quot; style=&amp;quot;text-align: left;&amp;quot; | Time &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:100px;&amp;quot; |'''Car_type &amp;amp;#9660; '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''0'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
|-&lt;br /&gt;
!'''VW''' &lt;br /&gt;
| 2810&lt;br /&gt;
| 141&lt;br /&gt;
|147&lt;br /&gt;
|155&lt;br /&gt;
|163&lt;br /&gt;
|-&lt;br /&gt;
!'''Honda '''&lt;br /&gt;
| 3535&lt;br /&gt;
|312&lt;br /&gt;
|50&lt;br /&gt;
| 269&lt;br /&gt;
| 199&lt;br /&gt;
|-&lt;br /&gt;
!'''BMW''' &lt;br /&gt;
| 3185&lt;br /&gt;
| 109&lt;br /&gt;
| 115&lt;br /&gt;
| 120&lt;br /&gt;
| 127&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next example returns a table that shows the increase in the cost of ownership of cars compared to the previous time period and also sets the first value to 0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Uncumulate (Cost_of_ownership, Time, 0)&amp;lt;/code&amp;gt;→&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;  &lt;br /&gt;
! !! style=&amp;quot;text-align: left;&amp;quot; colspan=&amp;quot;5&amp;quot; | Time &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:100px;&amp;quot; |'''Car_type &amp;amp;#9660; '''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''0'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''1'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''2'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''3'''&lt;br /&gt;
! style=&amp;quot;width:75px;&amp;quot; |'''4'''&lt;br /&gt;
|-&lt;br /&gt;
!'''VW''' &lt;br /&gt;
| 0&lt;br /&gt;
| 141&lt;br /&gt;
| 147&lt;br /&gt;
| 155&lt;br /&gt;
| 163&lt;br /&gt;
|-&lt;br /&gt;
!'''Honda '''&lt;br /&gt;
| 0&lt;br /&gt;
| 312&lt;br /&gt;
| 50&lt;br /&gt;
| 269&lt;br /&gt;
| 199&lt;br /&gt;
|-&lt;br /&gt;
!'''BMW''' &lt;br /&gt;
| 0&lt;br /&gt;
| 109&lt;br /&gt;
| 115&lt;br /&gt;
| 120&lt;br /&gt;
| 127&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Cumulate]]&lt;br /&gt;
* [[Array_Function_Example_Variables|Example variables]]&lt;/div&gt;</summary>
		<author><name>JHernandez2</name></author>
	</entry>
</feed>