change {seas} | R 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 |
x2 |
a second |
var1 |
a variable in |
var2 |
a variable in |
width |
the width of the bins, see |
cent |
a |
sprd |
a |
disc |
if the data are discontinuous, the |
inter |
|
p.cut |
cut-off for wet/dry; see |
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 |
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
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)