Scaling

This page describes routines that deal with scaling data. The Excel form will in have the following two layouts depending on the option the user selects.

Layout A:

Scaling Standardize

Layout B:

Scaling MinMax


Standardize

Description

Return a matrix that is column-wise centered to mean 0 and scaled to a standard devation 1. More precisely, each original xx in a column corresponds to the following transformation: f(x)=xxσ f(x) = \frac{x - \overline{x}}{\sigma} where x\overline{x} is the column mean and σ\sigma is the column standard deviation.

Returns

  • Matrix with the scaled columns

Min-Max

Description

Return a matrix that is column-wise scaled to a lower bound lblb and an upper bound ubub specified by the user. More precisely, each original xx in a column corresponds to the following transformation: f(x)=lb+(xmin(x))(ublb)(max(x)min(x)) f(x) = lb + \frac{(x - min(x)) (ub - lb)}{(max(x) - min(x))}

Returns

  • Matrix with the scaled columns

Box-Cox

Description

Return a matrix that is column-wise scaled using the Box-Cox transform. The transform itself is defined as:

y(λ)={yλ1λ if λ0log(y) if λ=0 y(\lambda)= \begin{cases} \Large\frac{y^{\lambda} - 1}{\lambda} & \text{ if } \lambda\neq 0 \\log(y) &\text{ if } \lambda = 0 \end{cases}

An optimization routine is used to find the parameter λ \lambda maximizing the log-likelihood function for the Box-Cox transform.

Returns

  • λ \lambda for each column
  • Matrix with the scaled columns

Yeo-Johnson

Description

Return a matrix that is column-wise scaled using the Yeo-Johnson transform. The transform itself is defined as:

y(λ)={(y+1)λ1λ if λ0,y0log(y+1) if λ=0,y0(1y)2λ1λ2 if λ2,y<0log(1y) if λ=2,y<0 y(\lambda)= \begin{cases} \frac{(y+1)^{\lambda} - 1}{\lambda} &\text{ if } \lambda\neq 0, y \geq 0 \\log(y+1) &\text{ if } \lambda = 0, y \geq 0 \\\frac{(1-y)^{2-\lambda} - 1}{\lambda-2} &\text{ if } \lambda\neq 2, y \lt 0 \\-log(1-y) &\text{ if } \lambda = 2, y \lt 0 \end{cases}

An optimization routine is used to find the parameter λ \lambda maximizing the log-likelihood function for the Yeo-Johnson transform.

Returns

  • λ \lambda for each column
  • Matrix with the scaled columns

Log Returns

Description

Return a matrix that calculates column-wise natural log returns. f(x)=lnx1x0 f(x) = ln\frac{x_{1}}{x_{0}}

Returns

  • Matrix