applyCorrelationMatrix
¶
Performs the mathematical operation \(\sqrt{\symbf{D}\symbf{C}\symbf{D}^T}\) for each time step, where \(\symbf{C}\) is a square matrix containing correlation coefficients, like
and \(\symbf{D}\) is a row vector containing the data at the current time step
and \(N\) is the number of variables.
This produces a scalar for each time step:
The results are written to a new table, and the name of the table is returned.
Signature and arguments¶
applyCorrelationMatrix(
correlationMatrixTableName,
dataMatrixTableName
)
correlationMatrixTableName
- The name of the table containing the correlation matrix \(\symbf{C}\). The header is ignored.
dataMatrixTableName
- The name of the table containing the data matrix where each row represents an instance of \(\symbf{D}\) at a
specific time step. The
variableMatrix()
function is well suited here.
Examples¶
See the example workbook.
Using tables from the model¶
You may use tables that already exist on the model (e.g. in the inputs workbook):
applyCorrelationMatrix(table("TableCorr1"), table("TableData1"))
The table()
function ensures that the tables are copied to the output workbook, where
the calculation is performed.
Using a variable matrix¶
Since applyCorrelationMatrix
simply requires two table names, and variableMatrix()
returns
such a name, you can use it directly to apply a correlation matrix to variables from the current projection node:
applyCorrelationMatrix(table("TableCorr1"), variableMatrix("VarA", "VarB", "VarC"))
Using tables from CSV¶
The csvToTable()
function also returns a table name, and can therefore also be
used directly inside applyCorrelationMatrix
:
applyCorrelationMatrix(csvToTable("correlation.csv"), csvToTable("data.csv"))