Simulate butterworth filter with initial condition of state vector in R
If you want to filter signals with an IIR filter, it's best to use the &quot;standard&quot; filter function of the language. That would be filter() for Matlab, lfilter() for Python and for R I believe this is signal::filter().
All of these functions allow you to specify the initial state. The exact details of how this is done, depends on the specific implementation of the filter.
If you don't specify any initial state the functions typically assume it's zero.
If I understand you correctly, you want to initialize the filter with the condition of $s[n] = s[0], n &lt; 0$, i.e. a non-zero constant.
Apparently signal::filter() allows you to specify the arguments. initX and initY. I would assume the length of this arguments must match the filter order. You can set initX= s[0], for a first order filter. For an Nth order filter you would have to repeat s[0] N times. You would also have to calculate the steady state output for a constant input, but since it's a high pass filter, that should just be zero, so initY = 0 shuld work.
CAVEAT: I don't speak R and don't have an R development system to work with. This answer is derived from &quot;best practices&quot; and reading some documentation.