The theory behind fitting an ARIMAX model I'm very familiar with the theoretical underpinnings of ARIMA/SARIMA models but I've been struggling to understand the theory behind fitting an ARIMAX model. I'm not looking for a practical application on R or Python since I know how to do that I'm rather looking for how exactly is the procedure done. I've been digging around the web for a while and found papers about Transfer Functions & Impulse Response but not at any depth or elaboration. 
 A: Please see my response to How to use Dynamic Regression models in R to forecast future sales . The whole idea about transfer function model identification is that we filter the stationary  X to make it white noise (x) and apply that filter to the stationary  Y to make y and then use the cross-correlation of x & y or it's proportional equivalent the Impulse Response Weights (regression coefficients) to identify a minimally sufficient set of lags (0,1,2,??).
The following should be studied closely ( follow the algebra ) to do this http://www.math.cts.nthu.edu.tw/download.php?filename=569_fe0ff1a2.pdf&dir=publish&title=Ruey+S.+Tsay-Lec1 ... particularly the bottom of page 4.

The final model errors need to be free of not only auto-correlation BUT cross-correlation AND need to be free of pulses,level/step shifts, seasonal pulses & Local time trends. Furthermore the parameters of the final model and the error variance need to be homogeneous over time.  using something similar to https://autobox.com/pdfs/A.pdf
EDITED AFTER OP'S QUESTION:
b ( the delay) is the the # of periods before the first significant cross-correlation. s speaks to the denominator structure (output lag) and can be identified by examining the cross-correlation for possible "decay" . (this is similar to examining the acf for decay in univariate analysis) and r is the # of numerator coefficients (input lag structure) that are needed. AUTOBOX solves this problem via a heuristic search process similar to auto.arima in style that yields the answers to r,s, and b https://autobox.com/cms/index.php/blog/entry/watson-its-not-elementary
See http://viewer.zmags.com/publication/9d4dc62a#/9d4dc62a/66 for a very aggressive test of the AUTOBOX heuristic when the reviewer injected structure to test the viability of AUTOBOX.
This is the area of " Pankratz's subjectivity" which is dealt with via search procedures not so easily programmed which is why one uses "smart software" for help rather than spending a lifetime at the keyboard.
Various alternatives such as the corner method often fail to uncover the the correct combination of s and b . As a novice you might start simply by setting s=0 and r large enough to encompass the significant cross-correlations. 
Finally the coefficents for the polynomial can be estimated by starting with the Impulse Response Weights.
If you are satisfied with my answer ...upcheck it and accept it to bring attention to the clarity it brings .
