sav_gol               package:RTisean               R Documentation

_S_a_v_i_t_z_k_y-_G_o_l_a_y _f_i_l_t_e_r

_D_e_s_c_r_i_p_t_i_o_n:

     A Savitzky-Golay filter to either clean the data from high
     frequency noise or to get a better estimate of its derivative of a
     chosen order.

_U_s_a_g_e:

     sav_gol(series, l, x = 0, c, m, n = "2,2", p = 2, D = 0)

_A_r_g_u_m_e_n_t_s:

  series: a vector or a matrix.

       l: number of data to use.

       x: number of lines to be ignored.

       c: column to be read.

       m: number of components to be read (dimension).

       n: a string containing the two lengths of the averaging windows
          back and forward in time, separated by comma (see example)

       p: order of the fitted polynomial.

       D: order of the derivative to be estimated.

_V_a_l_u_e:

     A matrix containining the filtered data, disposed in 'l' lines,
     each of which has 'm' columns.   The first length of the averaging
     window back in time and the last length of the  averaging window
     forward in time lines are special. They contain the raw data  in
     the case that 'D' was set to 0 and zeroes in the case that 'D' was
     larger than zero.

_R_e_f_e_r_e_n_c_e_s:

     W. H. Press, B. P. Flannery, S. A. Teukolsky, and W. T.
     Vetterling, ``Numerical Recipes'', 2nd edn., Cambridge University
     Press, Cambridge (1992).

_E_x_a_m_p_l_e_s:

     ## Not run: 

     numdata <- 500
     dat <- cos(1:numdata/25)+rnorm(numdata,0,0.1)
     windowlength <- 15
     plot(dat[windowlength:(numdata-windowlength)],xlab="Time",t="l",ylab="Cos Data",ylim=c(-1.5,1.2))
     filteredata <- sav_gol(dat,n="15,15")
     lines(filteredata[windowlength:(numdata-windowlength)],col=2,lwd=2)
     legend(300,-1.2, c("Noisy Data","Filtered Data"),fill=c(1,2), bty="n")

     ## End(Not run)

