change                 package:seas                 R Documentation

_F_i_n_d _s_e_a_s_o_n_a_l _a_n_d _a_n_n_u_a_l _c_h_a_n_g_e_s _b_e_t_w_e_e_n _t_w_o _d_a_t_a _s_e_t_s

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

     Find seasonal and annual changes between two data sets; relative
     and absolute changes are found between the central tendency and
     spread of each seasonal state.

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

     # minimum usage
     change(x1, x2, var1)

     # all options
     change(x1, x2, var1, var2=var1, width="mon",
            cent="mean",sprd="sd", disc=FALSE, inter=FALSE,
            p.cut=0.3, start.day=1, calendar)

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

      x1: a 'data.frame' of seasonal data

      x2: a second 'data.frame' of seasonal data

    var1: a variable in 'x1'

    var2: a variable in 'x2'

   width: the width of the bins, see 'mkseas' for more details; this
          will change the sample-sizes between 'x1' and 'x2', which can
          affect the changes detected

    cent: a 'function' to find a central tendency; usually this is
          'mean', however 'median' or other functions can be used too

    sprd: a 'function' to find a spread around a central tendency;
          usually this will be 'sd' (standard-deviation), however 'mad'
          or other functions can be used too

    disc: if the data are discontinuous, the 'seas.sum' objects are
          created for 'var1'/'var2' to determine the changes; this is
          ideal for precipitation, and other sparsely distributed
          variables

   inter: 'interarrival's are calculated, and changes are found between
          _wet_ and _dry_ series

   p.cut: cut-off for wet/dry; see 'interarrival'

start.day: starting day

calendar: calendar; if not specified it will try to read this from the
          attributes, otherwise it is assumed to be a proleptic
          Gregorian calendar; see 'year.length'

_D_e_t_a_i_l_s:

     This function is useful for finding changes between different
     states of seasonal data. Here, a _state_ represents how seasonal
     data behave statistically at either a _time_ or _place_. The
     stability of a state depends on both the variance throughout each
     portion of the season, as well as the number of years of
     observations.

     For instance, seasonal and annual changes in climate can be
     detected in climate data series, by comparing the normals from two
     time periods.

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

     Returns a complex 'list' of relative and absolute (if applicable)
     changes of 'var1'/'var2' between 'x1' and 'x2'.

     Seasonal and annual changes are identified independently of each
     other; where annual changes have a 'ann' prefix.

     Relative changes are not found if 'x$var' has values less than 0,
     such as Temperature measured in degrees C or F.

_A_u_t_h_o_r(_s):

     M.W. Toews

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

     'dathomog', 'lars'

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

     data(mscdata)
     dat1 <- mksub(mscdata,id=1108447,start=1975,end=1984)
     dat2 <- mksub(mscdata,id=1108447,start=1985,end=1995)

     # A few plot functions to make thing easy
     plot.ch <- function(x,main,h,col){
       main <- paste(main,"between 1975-1984 and 1985-1994",sep="\n")
       barplot(x,main=main)
       abline(h=c(0,h),col=c(1,col),lty=c(1,2))
     }
     plot.abs <- function(x,col="red",abs="abs",ann.abs="ann.abs"){
       main <- sprintf("Absolute change in %s",x$long.name[[1]])
       plot.ch(x[[abs]],main,x[[ann.abs]],col)
     }
     plot.rel <- function(x,col="orange",rel="rel",ann.rel="ann.rel"){
       main <- sprintf("Relative change in %s",x$long.name[[1]])
       plot.ch(x[[rel]],main,x[[ann.rel]],col)
     }
     plot.std <- function(x,col="purple"){
       main <- sprintf("Relative change in the\nstandard deviation of %s",
                       x$long.name[[1]])
       plot.ch(x$sprd.rel,main,x$ann.sprd.rel,col)
     }

     # Minimum temperature
     ch <- change(dat1,dat2,"t_min")
     str(ch)
     plot.abs(ch)
     plot.std(ch)
     # Cannot do ch$rel ; since div/0!

     # Precipitation
     ch2 <- change(dat1,dat2,"precip",width="DJF",disc=TRUE)
     plot.abs(ch2,"blue")
     plot.rel(ch2,"purple")
     plot.std(ch2)

