The inspect function turns the long tracking table into a year a metric summary
on which to track the inoputs and outputs of all steps inside a call to the mp
function.
inspect(tab, metrics = NULL, summary = medmad)An FLms+e object or a data.table containing tracking data. If an FLmse object is supplied, the tracking slot is extracted.
A character vector specifying the metrics to include in the output. If a single character value is given and it does not match excatly any of the contained metrics, it is used to subset using the datatable::%ilike% function. The special value "decisions" can be used to select all metrics from "hcr" onward. If NULL, the default, all metrics are returned.
A function (such as mean or median) to summarize the data column within the tracking data.table across rthe iter dimension. Defaults to medmad which returns a string with "Median (Median Absolute Deviation)".
A data.table where rows correspond to years and columns to selected metrics, with the tracking data aggregated using the specified summary function.
The function processes the table on the tracking slot by:
Arranging metrics based on the order in which they are produced inside mp().
Subsets metrics based on user input or predefined criteria like "decisions".
Aggregates the data column using the summary function provided.
Reshapes the processed data.table into a year-by-metrics format for easy reading.
The predefined metric order is that of the various steps inside mp(): "om", "obs", "est", "ind", "phcr", "hcr", "isys", "tm", "iem", "fb", "fwd". Extra tracks produced inside any module are placed before the one named after
the module that produced it.
# Load example MP run
data(mserun)
# Inspect all metrics
inspect(run)
#> Key: <year>
#> year B.om C.om F.om SB.om B.obs
#> <char> <char> <char> <char> <char> <char>
#> 1: 2021 8629 (2647) 1157 (225) 0.233 (0.0792) 7265 (2547) 8629 (2647)
#> 2: 2022 8602 (2618) 1146 (269) 0.222 (0.0764) 7599 (2617) 8602 (2618)
#> 3: 2023 8701 (2701) 1003 (387) 0.189 (0.0538) 7656 (2790) 8701 (2701)
#> 4: 2024 9404 (2636) 983 (381) 0.182 (0.056) 8264 (2557) 9404 (2636)
#> 5: 2025 9634 (2527) 1033 (332) 0.179 (0.0495) 8643 (2517) 9634 (2527)
#> 6: 2026 10183 (2263) 1095 (378) 0.179 (0.0559) 8906 (2371) 10183 (2263)
#> 7: 2027 10774 (1757) 1129 (344) 0.18 (0.0546) 9487 (1724) 10774 (1757)
#> 8: 2028 10850 (1641) 1192 (332) 0.181 (0.0592) 9883 (1534) 10850 (1641)
#> 9: 2029 11202 (1638) 1248 (312) 0.194 (0.061) 10117 (1502) 11202 (1638)
#> 10: 2030 11359 (1480) 1309 (257) 0.205 (0.0654) 10273 (1551) 11359 (1480)
#> 11: 2031 11626 (1669) 1340 (282) 0.213 (0.0625) 10448 (1557) 11626 (1669)
#> 12: 2032 11706 (1693) 1342 (276) 0.224 (0.0663) 10572 (1568) 11706 (1693)
#> 13: 2033 11685 (1660) 1413 (294) 0.233 (0.0581) 10487 (1676) 11685 (1660)
#> 14: 2034 11458 (1638) 1449 (266) 0.239 (0.0647) 10378 (1700) 11458 (1638)
#> C.obs SB.obs B.est C.est F.est SB.est
#> <char> <char> <char> <char> <char> <char>
#> 1: 1157 (225) 7265 (2547) 8629 (2647) 1157 (225) 0.233 (0.0792) 7265 (2547)
#> 2: 1146 (269) 7599 (2617) 8602 (2618) 1146 (269) 0.222 (0.0764) 7599 (2617)
#> 3: 1003 (387) 7656 (2790) 8701 (2701) 1003 (387) 0.189 (0.0538) 7656 (2790)
#> 4: 983 (381) 8264 (2557) 9404 (2636) 983 (381) 0.182 (0.056) 8264 (2557)
#> 5: 1033 (332) 8643 (2517) 9634 (2527) 1033 (332) 0.179 (0.0495) 8643 (2517)
#> 6: 1095 (378) 8906 (2371) 10183 (2263) 1095 (378) 0.179 (0.0559) 8906 (2371)
#> 7: 1129 (344) 9487 (1724) 10774 (1757) 1129 (344) 0.18 (0.0546) 9487 (1724)
#> 8: 1192 (332) 9883 (1534) 10850 (1641) 1192 (332) 0.181 (0.0592) 9883 (1534)
#> 9: 1248 (312) 10117 (1502) 11202 (1638) 1248 (312) 0.194 (0.061) 10117 (1502)
#> 10: 1309 (257) 10273 (1551) 11359 (1480) 1309 (257) 0.205 (0.0654) 10273 (1551)
#> 11: 1340 (282) 10448 (1557) 11626 (1669) 1340 (282) 0.213 (0.0625) 10448 (1557)
#> 12: 1342 (276) 10572 (1568) 11706 (1693) 1342 (276) 0.224 (0.0663) 10572 (1568)
#> 13: 1413 (294) 10487 (1676) 11685 (1660) 1413 (294) 0.233 (0.0581) 10487 (1676)
#> 14: 1449 (266) 10378 (1700) 11458 (1638) 1449 (266) 0.239 (0.0647) 10378 (1700)
#> conv.est ssb.ind metric.hcr decision.hcr rule.hcr hcr
#> <char> <char> <char> <char> <char> <char>
#> 1: 1 (0) 7524 (2901) 7524 (2901) 1003 (387) 2 (0) 1003 (387)
#> 2: 1 (0) 7375 (2859) 7375 (2859) 983 (381) 2 (0) 983 (381)
#> 3: 1 (0) 7751 (2493) 7751 (2493) 1033 (332) 2 (0) 1033 (332)
#> 4: 1 (0) 8209 (2834) 8209 (2834) 1095 (378) 2 (0) 1095 (378)
#> 5: 1 (0) 8467 (2578) 8467 (2578) 1129 (344) 2 (0) 1129 (344)
#> 6: 1 (0) 8939 (2490) 8939 (2490) 1192 (332) 2 (0) 1192 (332)
#> 7: 1 (0) 9358 (2340) 9358 (2340) 1248 (312) 2 (0) 1248 (312)
#> 8: 1 (0) 9821 (1925) 9821 (1925) 1309 (257) 2 (0) 1309 (257)
#> 9: 1 (0) 10047 (2112) 10047 (2112) 1340 (282) 2 (0) 1340 (282)
#> 10: 1 (0) 10063 (2068) 10063 (2068) 1342 (276) 2 (0) 1342 (276)
#> 11: 1 (0) 10597 (2205) 10597 (2205) 1413 (294) 2 (0) 1413 (294)
#> 12: 1 (0) 10871 (1997) 10871 (1997) 1449 (266) 2 (0) 1449 (266)
#> 13: 1 (0) 10566 (2441) 10566 (2441) 1409 (325) 2 (0) 1409 (325)
#> 14: 1 (0) 10360 (1801) 10360 (1801) 1381 (240) 2 (0) 1381 (240)
#> borrowing.isys banking.isys isys fwd
#> <char> <char> <char> <char>
#> 1: 0 (0) 0 (0) 1003 (387) 1003 (387)
#> 2: 0 (0) 0 (0) 983 (381) 983 (381)
#> 3: 0 (0) 0 (0) 1033 (332) 1033 (332)
#> 4: 0 (0) 0 (0) 1095 (378) 1095 (378)
#> 5: 0 (0) 0 (0) 1129 (344) 1129 (344)
#> 6: 0 (0) 0 (0) 1192 (332) 1192 (332)
#> 7: 0 (0) 0 (0) 1248 (312) 1248 (312)
#> 8: 0 (0) 0 (0) 1309 (257) 1309 (257)
#> 9: 0 (0) 0 (0) 1340 (282) 1340 (282)
#> 10: 0 (0) 0 (0) 1342 (276) 1342 (276)
#> 11: 0 (0) 0 (0) 1413 (294) 1413 (294)
#> 12: 0 (0) 0 (0) 1449 (266) 1449 (266)
#> 13: 0 (0) 0 (0) 1409 (325) 1409 (325)
#> 14: 0 (0) 0 (0) 1381 (240) 1381 (240)
# Inspect with different summary function
inspect(tracking(run), summary=mean)
#> Key: <year>
#> year B.om C.om F.om SB.om B.obs C.obs SB.obs
#> <char> <num> <num> <num> <num> <num> <num> <num>
#> 1: 2021 8923.504 1198.571 0.2510223 7895.436 8923.504 1198.571 7895.436
#> 2: 2022 9095.729 1176.443 0.2422128 8052.965 9095.729 1176.443 8052.965
#> 3: 2023 9294.027 1046.336 0.1940889 8242.883 9294.027 1046.336 8242.883
#> 4: 2024 9658.836 1080.121 0.1900099 8576.051 9658.836 1080.121 8576.051
#> 5: 2025 10024.338 1098.941 0.1868299 8939.896 10024.338 1098.941 8939.896
#> 6: 2026 10410.579 1152.582 0.1909446 9298.402 10410.579 1152.582 9298.402
#> 7: 2027 10771.517 1191.400 0.1956375 9654.732 10771.517 1191.400 9654.732
#> 8: 2028 11100.170 1244.776 0.2043953 9961.836 11100.170 1244.776 9961.836
#> 9: 2029 11370.303 1290.776 0.2107285 10247.186 11370.303 1290.776 10247.186
#> 10: 2030 11573.418 1338.531 0.2193204 10466.329 11573.418 1338.531 10466.329
#> 11: 2031 11691.668 1371.477 0.2266620 10597.072 11691.668 1371.477 10597.072
#> 12: 2032 11718.398 1379.859 0.2309177 10640.405 11718.398 1379.859 10640.405
#> 13: 2033 11717.365 1436.846 0.2447184 10636.413 11717.365 1436.846 10636.413
#> 14: 2034 11628.997 1432.878 0.2501304 10556.247 11628.997 1432.878 10556.247
#> B.est C.est F.est SB.est conv.est ssb.ind metric.hcr
#> <num> <num> <num> <num> <num> <num> <num>
#> 1: 8923.504 1198.571 0.2510223 7895.436 1 7847.517 7847.517
#> 2: 9095.729 1176.443 0.2422128 8052.965 1 8100.905 8100.905
#> 3: 9294.027 1046.336 0.1940889 8242.883 1 8242.054 8242.054
#> 4: 9658.836 1080.121 0.1900099 8576.051 1 8644.369 8644.369
#> 5: 10024.338 1098.941 0.1868299 8939.896 1 8935.502 8935.502
#> 6: 10410.579 1152.582 0.1909446 9298.402 1 9335.823 9335.823
#> 7: 10771.517 1191.400 0.1956375 9654.732 1 9680.816 9680.816
#> 8: 11100.170 1244.776 0.2043953 9961.836 1 10038.982 10038.982
#> 9: 11370.303 1290.776 0.2107285 10247.186 1 10286.081 10286.081
#> 10: 11573.418 1338.531 0.2193204 10466.329 1 10348.942 10348.942
#> 11: 11691.668 1371.477 0.2266620 10597.072 1 10776.344 10776.344
#> 12: 11718.398 1379.859 0.2309177 10640.405 1 10746.583 10746.583
#> 13: 11717.365 1436.846 0.2447184 10636.413 1 10604.507 10604.507
#> 14: 11628.997 1432.878 0.2501304 10556.247 1 10465.082 10465.082
#> decision.hcr rule.hcr hcr borrowing.isys banking.isys isys
#> <num> <num> <num> <num> <num> <num>
#> 1: 1046.336 2 1046.336 0 0 1046.336
#> 2: 1080.121 2 1080.121 0 0 1080.121
#> 3: 1098.941 2 1098.941 0 0 1098.941
#> 4: 1152.582 2 1152.582 0 0 1152.582
#> 5: 1191.400 2 1191.400 0 0 1191.400
#> 6: 1244.776 2 1244.776 0 0 1244.776
#> 7: 1290.776 2 1290.776 0 0 1290.776
#> 8: 1338.531 2 1338.531 0 0 1338.531
#> 9: 1371.477 2 1371.477 0 0 1371.477
#> 10: 1379.859 2 1379.859 0 0 1379.859
#> 11: 1436.846 2 1436.846 0 0 1436.846
#> 12: 1432.878 2 1432.878 0 0 1432.878
#> 13: 1413.934 2 1413.934 0 0 1413.934
#> 14: 1395.344 2 1395.344 0 0 1395.344
#> fwd
#> <num>
#> 1: 1046.336
#> 2: 1080.121
#> 3: 1098.941
#> 4: 1152.582
#> 5: 1191.400
#> 6: 1244.776
#> 7: 1290.776
#> 8: 1338.531
#> 9: 1371.477
#> 10: 1379.859
#> 11: 1436.846
#> 12: 1432.878
#> 13: 1413.934
#> 14: 1395.344
# Inspect metrics with "SB" or "sb" in their names
inspect(tracking(run), metrics="SB")
#> SB.om SB.obs SB.est ssb.ind
#> <char> <char> <char> <char>
#> 1: 7265 (2547) 7265 (2547) 7265 (2547) 7524 (2901)
#> 2: 7599 (2617) 7599 (2617) 7599 (2617) 7375 (2859)
#> 3: 7656 (2790) 7656 (2790) 7656 (2790) 7751 (2493)
#> 4: 8264 (2557) 8264 (2557) 8264 (2557) 8209 (2834)
#> 5: 8643 (2517) 8643 (2517) 8643 (2517) 8467 (2578)
#> 6: 8906 (2371) 8906 (2371) 8906 (2371) 8939 (2490)
#> 7: 9487 (1724) 9487 (1724) 9487 (1724) 9358 (2340)
#> 8: 9883 (1534) 9883 (1534) 9883 (1534) 9821 (1925)
#> 9: 10117 (1502) 10117 (1502) 10117 (1502) 10047 (2112)
#> 10: 10273 (1551) 10273 (1551) 10273 (1551) 10063 (2068)
#> 11: 10448 (1557) 10448 (1557) 10448 (1557) 10597 (2205)
#> 12: 10572 (1568) 10572 (1568) 10572 (1568) 10871 (1997)
#> 13: 10487 (1676) 10487 (1676) 10487 (1676) 10566 (2441)
#> 14: 10378 (1700) 10378 (1700) 10378 (1700) 10360 (1801)
# Inspect specific metrics
inspect(tracking(run), metrics=c("C.om", "C.obs", "C.est"))
#> C.om C.obs C.est
#> <char> <char> <char>
#> 1: 1157 (225) 1157 (225) 1157 (225)
#> 2: 1146 (269) 1146 (269) 1146 (269)
#> 3: 1003 (387) 1003 (387) 1003 (387)
#> 4: 983 (381) 983 (381) 983 (381)
#> 5: 1033 (332) 1033 (332) 1033 (332)
#> 6: 1095 (378) 1095 (378) 1095 (378)
#> 7: 1129 (344) 1129 (344) 1129 (344)
#> 8: 1192 (332) 1192 (332) 1192 (332)
#> 9: 1248 (312) 1248 (312) 1248 (312)
#> 10: 1309 (257) 1309 (257) 1309 (257)
#> 11: 1340 (282) 1340 (282) 1340 (282)
#> 12: 1342 (276) 1342 (276) 1342 (276)
#> 13: 1413 (294) 1413 (294) 1413 (294)
#> 14: 1449 (266) 1449 (266) 1449 (266)
# Inspect only decision-related metrics from 'hcr'
inspect(tracking(run), metrics="decisions")
#> hcr borrowing.isys banking.isys isys fwd
#> <char> <char> <char> <char> <char>
#> 1: 1003 (387) 0 (0) 0 (0) 1003 (387) 1003 (387)
#> 2: 983 (381) 0 (0) 0 (0) 983 (381) 983 (381)
#> 3: 1033 (332) 0 (0) 0 (0) 1033 (332) 1033 (332)
#> 4: 1095 (378) 0 (0) 0 (0) 1095 (378) 1095 (378)
#> 5: 1129 (344) 0 (0) 0 (0) 1129 (344) 1129 (344)
#> 6: 1192 (332) 0 (0) 0 (0) 1192 (332) 1192 (332)
#> 7: 1248 (312) 0 (0) 0 (0) 1248 (312) 1248 (312)
#> 8: 1309 (257) 0 (0) 0 (0) 1309 (257) 1309 (257)
#> 9: 1340 (282) 0 (0) 0 (0) 1340 (282) 1340 (282)
#> 10: 1342 (276) 0 (0) 0 (0) 1342 (276) 1342 (276)
#> 11: 1413 (294) 0 (0) 0 (0) 1413 (294) 1413 (294)
#> 12: 1449 (266) 0 (0) 0 (0) 1449 (266) 1449 (266)
#> 13: 1409 (325) 0 (0) 0 (0) 1409 (325) 1409 (325)
#> 14: 1381 (240) 0 (0) 0 (0) 1381 (240) 1381 (240)