Dear Janesh,

Re:

> Dear Franklin Bretschneider,
> 
> Thank you so much for your reply and explanation about the filter using the 
> stats and signal package. 
> 
> I decided to opt the filter method in signal package. I have a simple 
> question about the cut off frequency here. 
> 
> I have 30 minute collected tidal data and I want to use the 48 hour low pass 
> filter to my data to remove the fluctuations and then get only the residuals. 
> What should be the cutoff frequency in my case ? I have tried to figure out 
> cut off frequency with the following rationale : . 
> 
> The parameters for butter filter are n, Wn and type. In the help, W    is 
> defined as critical frequencies of the filter. W must be a scalar for 
> low-pass and high-pass filters, and W must be a two-element vector c(low, 
> high) specifying the lower and upper bands. For digital filters, W must be 
> between 0 and 1 where 1 is the Nyquist frequency.
> 
> A value of 1 corresponds to half the sampling frequency. In my case the 
> sampling frequency is 2 hr^-1. Hence a value of 0.01 corresponds to a 
> frequency cutoff of .01*1 = .01 hr^-1 or 100 hrs time. Using unitary method, 
> if 100 hours cut off frequency is 0.01 then 48 hours cut off frequency is 
> 0.01/100*48 = 0.0048 hr^-1 . Is that correct ?
> 
> Thank you so much
> 
> Janesh
> 


With digital filters (called "z-plane" in the signal package), the cut-off 
frequency must indeed be given as a fraction of the Nyquist freqency.

With your tidal data, taken at 2 samples per hour, the nyquist is 1 per hour. 
So, a cutoff interval of 48 h means a cutoff frequncy of 1/48 f(nyq) , or 
0.020833. This must be fed into the butterworth function.

Note btw that at the cut-off frequency, the amplitude is still rather high 
(about 0.707), so the tidal signal (period about 12.5 h) will not be attenuated 
much.
I hope this helps. It's always best to check with a simple example, such as an 
f= 1/48 sine, which after your filter should be reduced to an amplitude of 
0.707). Then check with a simulated tidal signal (say, a sine of about 12:25 h 
period). 
With such simple tests, I often find my own programming errors.
Best wishes,


Franklin
--


Franklin Bretschneider
--
Dept Biology
Kruyt Building W711
Padualaan 8
3584 CH Utrecht
The Netherlands






        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to