linearFit             package:ifultools             R Documentation

_L_i_n_e_a_r _r_e_g_r_e_s_s_i_o_n _o_f _a _s_e_g_m_e_n_t_e_d _t_i_m_e _s_e_r_i_e_s

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

     Segments the time series in approximately linear regions as
     defined by the 'linearSegmentation' function and subsequently
     regressed the specified segment using a selected regression
     scheme.

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

     linearFit(x, y, fit=lmsreg, method="widest",
         n.fit=5, angle.tolerance=5, aspect=TRUE)

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

       x: the independent variable of the time series.

       y: the dependent variable of the time series.

angle.tolerance: the maximum angle in degrees that the running average
          of the slopes in the current set of points can change
          relative to the slope of the data calculated in the most
          current (rightmost) window before a change-point is recorded.
          Default: 5.

  aspect: a logical value. If 'TRUE', the aspect ratio of the data
          (defined by 'range(y) / range(x)') is used to adjust the
          'angle.tolerance'. Specifically, the new angle tolerance
          becomes 'angle.tolerance / aspect.ratio'. Using the aspect
          ratio to dilate 'angle.tolerance' allows the user to specify
          the degree of variablity they wish to impose on the data
          vis-a-vis a standard plot of the data, i.e. what you would
          see if you issued 'plot(xdata, ydata)'. The idea is that when
          looking at such plots, one might decide (for example) that a
          5 degree variablity on the plot would be acceptable. But if
          that range of 'y' is vastly different from that of 'x', then
          the true change in angle from one section to the other will
          be much different than 5 degrees. Thus, 'aspect' can be used
          to compensate for aspect ratios far away from unity. Default:
          'TRUE'.

     fit: a function representing the linear regression scheme to use
          in fitting the resulting statistics (on a log-log scale).
          Supported functions are: 'lm', 'lmsreg', and 'ltsreg'. See
          the on-line help documentation for each of these for more
          information. Default: 'lmsreg'.

  method: a character string used to define the criterion for selecting
          one of the segments returned by the 'linearSegmentation'
          function. Choices are

          '"_f_i_r_s_t"' The first (leftmost) segment.

          '"_l_a_s_t"' The last (rightmost) segment.

          '"_w_i_d_e_s_t"' The segment containing the most number of points.

          '"_a_l_l"' A union of all segments.

          Default: '"widest"'.

   n.fit: an integer denoting the window size, not to exceed the number
          of samples in the time series. Default: 5.

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

     the regression model.

_S_e_e _A_l_s_o:

     'logScale'.

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

     ## obtain some data with approximately 
     ## piecewise-linear trends 
     x <- seq(0,2*pi,length=100)
     y <- sin(x)

     ## perform linear segmentation with aspect ratio 
     ## dilation using a 5 degree tolerance and 5 
     ## point windows. regress the widest of these 
     ## segments with the lm() function. 
     linearFit(x, y, n.fit=5, angle.tolerance=5, aspect=TRUE,
         method="widest", fit=lm)

