R equivalent of the MATLAB filter function

I am fitting MATLAB code to R and trying to create a waveform using the ARMA formula. Is there a simple R-equivalent function for MATLAB filterto accept AR / MA coefficients to build a waveform?

npts = 100;
a = [1 0.6]; % AR coeffs
b = [1 0.25 3]; % MA coeffs
e = randn(npts,1); % generate gaussian white noise
waveform = filter(b,a,e); % generate waveform
+5
source share
2 answers

Hmm, you cannot achieve this with the filterfunction in the signal package ?

require(signal)
a = c(1,0.6)
b = c(1,0.25,3)
e = rnorm(100)
waveform = filter(b,a,e)
+2
source

Yes, you can do it usring arima.sim, for example.

arima.sim(npts, model=list(ar=a, ma=b), rand.gen=rnorm)

Please note that the model is checked for stationarity, and the above model is not stationary. If you want something integrated, you can specify the order of integration in the model.

+4
source

All Articles