change: Find seasonal and annual changes between two data sets

changeR Documentation

Find seasonal and annual changes between two data sets

Description

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.

Usage

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

Arguments

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

interarrivals 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

Details

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.

Value

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.

Author(s)

Mike Toews

See Also

dathomog, lars

Examples

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)


seas documentation built on May 2, 2022, 5:08 p.m.