compare {musica}R Documentation

Compare decomposed variables

Description

The function evaluates distance between statistical characteristics of specified data sets. Distance is measured as difference for variables included in getOption('additive_variables'), i.e. temperature (TAS) by default, and as a ratio for other variables.

Usage

compare(x, compare_to, fun = mean, wet_int_only = TRUE, wet_int_thr = 0.1,
  exclude_below = 0.9)

Arguments

x

List of decomposed variables to be compared

compare_to

Decomposed variable used as a reference

fun

Function used for comparison

wet_int_only

(logical) Should only the wet intervals be considered?

wet_int_thr

Numeric value specifying the minimum depth to be considered wet

exclude_below

Some of the intervals might not be of required length, e.g. D10 interval may have less than 10 days available. The exclude_below argument controls the minimum fraction of the interval that has to be available in order to be considered in the summary statistics.

Value

data.table summarizing the differences with columns:

variable

factor indicating the variable

period

specification of the averaging length with 'D' - day(s), 'M' - month(s), 'Y' - year(s) and 'G1' - the overall mean

TS

averaging length in hours

sub_period

indication of the aggregating scale specified by agg_by argument

comp

factor indicating the data sets from x with labels given by names(x)

DIF

distance between data sets from x and compare_to. Distance is measured as difference for variables included in getOption('additive_variables'), i.e. temperature (TAS) by default, and as a ratio for other variables, see dif

Examples

library(ggplot2)
data(basin_PT)
## Not run: 
dobs = decomp(basin_PT[['obs_ctrl']])
dctrl = decomp(basin_PT[['sim_ctrl']])
dscen = decomp(basin_PT[['sim_scen']])
d = compare(x = list(CTRL = dctrl, SCEN = dscen), compare_to = dobs, fun = max)
ggplot(d) +
 geom_line(aes(x = TS, y = DIF, col = factor(sub_period))) +
 facet_grid(variable ~ comp, scale = 'free') +
 scale_x_log10()
 
## End(Not run)

[Package musica version 0.1.3 Index]