# ARIMA model for a single variable with hidden context

I have a signal which measures the power of a machine. I have been asked to fit an ARIMA model for this signal in order to find anomalies.

However as far as I know, the power of the machine is controlled by several factors, like: human control (i.e. an operator can increase, decrease, turn off, ... the power as he needs of as he is requested), automatic control (i.e. when for instance the internal temperature of the machine is too high it limits itself power, or if the power is not used for a given time the machine automatically turns off, ...), external control (i.e. some day it rains and the machine performs badly, ...), and of course some randomness.

My question is: from a methodological point of view, does it even make sense to fit an ARIMA model of this signal (and of this signal ONLY) without considering the context i.e. what the operator does, what the machine does, external factors? Maybe the power of the machine is "10" in the last six months, now it becomes "100" just because someone has decided so, how can I know if this is an anomaly or an intended behavior? How can the ARIMA model fit without these information? Or is the ARIMA model "strong enough" to handle all these "hidden" contexts?

• It seems like a methodology has been dictated to you from on high. In my (professional) context, this happens sometimes too. Do you have the ability/latitude to suggest something different? Sometimes this requires educating your audience. That said, with ARIMA you can include additional regressors so you could include those other factors if you have the data on them. Without the additional regressors ARIMA will do poorly-- it will either not fit the level shifts, or it will incorrectly fit it not understanding the mechanism. – Chris Umphlett Nov 26 '19 at 17:36
• Yes I can try to suggest something different, but I'll have to explain why. My hunch says that an ARIMA model with one variable in a real case analysis makes no sense, but I'd like to confront with you to understand if I'm right and how to formally prove that in order to propose something else. – edoedoedo Nov 27 '19 at 7:56

My suggestion is that you consider approach than ARIMA if necessary, which is typically used for forecasting. Anomaly detection appears to be the goal here. There are several options available in R and SAS (where I have experience). You didn't mention a particular language or software so I won't comment on all the ones I'm aware of for now, though I will show one example below.

Time series anomaly detection will use a time series forecasting framework to detect outliers-- you might even find one in your software that uses ARIMA as its base, in which case you could get away with not explaining a different method. You need a method that does both time-series anomaly detection and can include regressors.

I like using tsoutliers in R. Using the built-in R dataset LakeHuron, there's a one line call to produce a plot showing the presence, magnitude and type of outliers (level shifts, temporary pulses, outliers): plot(tsoutliers::tso(LakeHuron)). The tso function accomodates regressors as well. Perhaps most importantly for you, "The original framework is based on ARIMA time series models" (direct quote from the documentation).

SAS example, per request. I no longer have SAS so I can only talk about it more generally. I have done this previously with PROC UCM (Unobserved Component Models), so this is not an ARIMA based approach. It is probably possible to get something out of PROC ARIMA.

PROC UCM includes many statements-- it can be quite complex. There's no automatic optimisation, unlike R, so you will need to specify the appropriate components for the model (such as trend, level, season). The Model and RANDOMREG statements allow you to include regressors.

One of the optional statements is OUTLIER. This allows you to set the threshold for outlier detection and will output the outliers that are identified. You can use ODS tables to output this to a data set.

• Thanks a lot, can you share an example code in SAS as well? – edoedoedo Nov 27 '19 at 14:53
• Do you have SAS/ETS? – Chris Umphlett Nov 27 '19 at 14:55
• Yes I have that package – edoedoedo Nov 27 '19 at 15:00
• editing my answer. – Chris Umphlett Nov 27 '19 at 15:16