Cross Sectional Functions

What are they with sample use cases

Marco Salerno
Written by Marco SalernoLast update 11 months ago

Cross-sectional functions allow you to perform tests against a body of related stocks, on the fly and point-in-time. These are the cross-sectional functions available:

  • Count (FCount)

  • Median (FMedian)

  • Ordinal Rank (FOrder)

  • Percentile Rank (FRank)

  • Sum (FSum)

  • Z-Score (ZScore)

  • Aggregate

You would use these against a group (or groups) of stocks to get a number that plugs into a rule. For example:

FOrder("MktCap", #Sector, #Desc) = 1

FOrder gets the order within the sorted array of the group. In the example above it sorts the stocks by market cap within each sector and returns the largest cap of each sector.

Additional Parameters

All the cross sectional functions require one parameter: the "formula" used to calculate the value for each stock. There are several other parameters, each having a default behavior if it is not specified. Here's a sampling of the available parameters:

  • Scope: example "Universe" or "Sector"

  • Sort: ascending or descending

  • Include NAs: true or false

Some parameters are specific to a single function. Please refer to the reference (see end of the article) for detailed information for each function.

Aggregate

The Aggregate function is much more flexible. Think of the function as an average on steroids. It has parameters like "Outlier Percent", "Median Fallback," and "Exclude ADRs."

Porfolio123 uses Aggregate to calculate Industry and Sector factors, for example the PE for the Industry. We have built upon a large amount of research to do so.

One quirk of financial data is that cross-sectional outliers are unavoidable, material, and frequent. They are caused by actual events that happen to actual companies. That still doesn't mean that we want them in our averages.

Aggregate solves this by putting all of the data to be averaged into a row, large to small, and then lopping off about 16.5% of the population at the tails.

This may seem like a large amount, but it's actually quite reasonable. In testing, we found that for some data it was possible to cut off a total of 70% at the tails without a significant change in the averages.

By default, the aggregate function tosses 16.5% at each tail and calculates a simple mean.

But if you don't like the default, the function is capable of automatically performing a cap-weighted average, doing Winsorization, excluding ADRs, and excluding zero values. 

Reference

To read more about each Cross Sectional Function open the Reference section of the tool you are using (ex. the Screener) expand the CROSS SECTIONAL section as shown below. Then click on "Full Description."



Did this answer your question?