compute_correlation_matrix
Compute Spearman correlation matrices from historical data, and obtain the nearest valid positive-semidefinite version for creating copula inputs in risk models.
Instructions
ModelRisk: Compute the rank-order (Spearman) correlation matrix of a data range via VoseCorrMatrix, and its nearest valid (positive-semidefinite) form via VoseValidCorrmat. Use this to turn historical data into the correlation matrix you feed to create_copula for correlated inputs. Variables are columns by default (set data_in_rows=True if each row is a variable). Read-only: runs on a transient scratch sheet that is always deleted.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"workbook": "<workbook>",
"sheet": "<sheet>",
"data_range": "<data_range>"
},
"name": "compute_correlation_matrix"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sheet | Yes | Sheet holding the data. | |
| workbook | Yes | Workbook file name. | |
| data_range | Yes | A1-style range of the data, e.g. 'A1:D200'. | |
| data_in_rows | No | True if each variable is a row. Default: columns. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| matrix | Yes | Spearman rank-order correlation matrix (VoseCorrMatrix). | |
| is_valid | Yes | True if the matrix is already a valid (PSD) correlation matrix. | |
| data_range | Yes | ||
| variable_count | Yes | ||
| nearest_valid_matrix | No | Nearest valid matrix (VoseValidCorrmat) — null when already valid. |