Creating a 4th order Butterworth filter R I have sampled my data at 2000 Hz and want to generate a fourth order low-pass zero-lag filter with a cut-off frequency of 150 Hz.
I have put the code below that I have created but I have the following questions. Given that I have used the filtfilt function do I need to change the number to “2” so that it is a second-order and should I also double the cut-off frequency i.e change “W” to 0.3 from 0.15.
‘’’rawdata = data$Moment unfiltered
bf = butter(4,0.15,type = c(&quot;low&quot;), plane = c(&quot;z&quot;))
filtereddata = filtfilt(bf, data$Moment unfiltered)’’’
Thank you in advance!
do I need to change the number to “2” so that it is a second-order

Yes

and should I also double the cut-off frequency i.e change “W” to 0.3 from 0.15.

No
Strictly speaking, doubling up the filter will make the gain at the cutoff frequency -6dB instead of -3dB. So you have created a Linkwitz-Riley and not a Butterworth filter.
If you want a gain of exactly -3dB at 150 Hz you would need to increase the frequency slightly. You can work out the math by calculating the -1.5dB point of a Butterworth filter, but trial and error is probably quicker. 185Hz should get you fairly close.
In any case, the shape will still NOT be that of a Butterworth. Cascading two Butterworth filters does not result in another Butterworth filter. The zeros are in the right location but the poles are simply duplicated and are not Butterworth-distributed any more.