Monitor and flag (if necessary) incoming multivariate process observations.
mspMonitor(observations, labelVector, trainingSummary, ...)
an n x p xts matrix. For real-time monitoring via a script within a batch file, n = 1, so this must be a 1 x p matrix. If lags were included at the training step, then these observations will also have lagged features.
an n x 1 integer vector of class memberships
the TrainingSpecs list returned by the mspTrain() function. This list contains---for each class---the SPE and T2 thresholds, as well the projection matrix.
Lazy dots for additional internal arguments
An n x (p + 5) xts matrix, where the last five columns are:
the SPE statistic value for each observation in "observations"
a vector of SPE indicators recording 0 if the test statistic is less than or equal to the critical value passed through from the threshold object
the T2 statistic value for each observation in "observations"
a vector of T2 fault indicators, defined like SPE_Flag
a column indicating if there have been five flags in a row for either the SPE or T2 monitoring statistics or both. Alarm states are as follows: 0 = no alarm, 1 = Hotelling's T2 alarm, 2 = Squared Prediction Error alarm, and 3 = both alarms.
This function is designed to be run at specific time intervals (e.g.every 10 seconds, 30 seconds, 1 minute, 5 minutes, 10 minutes) through a scheduled operating script which calls this function and mspWarning(). We expect this script to be set up in Windows "Task Scheduler" or Macintosh OX "launchd" application suites. This function takes in the specific observations to monitor and their class memberships (if any) and returns an xts matrix of these observation columns concatenated with their monitoring statistic values, flag statuses, and an empty alarm column. Users should then append these rows onto a previously existing matrix of daily observations. The mspWarning() function will then take in the daily observation xts matrix with updated rows returned by this function and check the monitoring statistic flag indicators to see if an alarm status has been reached. For further details, see the mspWarning() function.
This function calls the faultDetect() function, and requires the training information returned by the mspTrain function. This function will return the xts matrix necessary for the mspWarning() function.
Calls: faultDetect
. Pipe flow: mspTrain
into mspMonitor
into mspWarning
.
if (FALSE) # cut down on R CMD check time
nrml <- mspProcessData(faults = "NOC")
n <- nrow(nrml)
#> Error in eval(expr, envir, enclos): object 'nrml' not found
# Calculate the training summary, but save five observations for monitoring.
trainResults_ls <- mspTrain(data = nrml[1:(n - 5), -1],
labelVector = nrml[1:(n - 5), 1],
trainObs = 4320)
#> Error in eval(expr, envir, enclos): object 'nrml' not found
# While training, we included 1 lag (the default), so we will also lag the
# observations we will test.
testObs <- nrml[(n - 6):n, -1]
#> Error in eval(expr, envir, enclos): object 'nrml' not found
testObs <- xts:::lag.xts(testObs, 0:1)
#> Error in eval(expr, envir, enclos): object 'testObs' not found
testObs <- testObs[-1,]
#> Error in eval(expr, envir, enclos): object 'testObs' not found
testObs <- cbind(nrml[(n - 5):n, 1], testObs)
#> Error in eval(expr, envir, enclos): object 'nrml' not found
mspMonitor(observations = testObs[, -1],
labelVector = testObs[, 1],
trainingSummary = trainResults_ls$TrainingSpecs)
#> Error in eval(expr, envir, enclos): object 'testObs' not found