mov.cor.dm: Running correlation between dendrometer data and climate

View source: R/mov.cor.dm.R

mov.cor.dmR Documentation

Running correlation between dendrometer data and climate

Description

Calculates running correlations between a selected daily dendrometer summary and one or more climate variables. The user can select the daily dendrometer statistic, correlation method, optional bootstrap confidence intervals, and lagged / antecedent climate transformations.

Usage

mov.cor.dm(
  df,
  Clim,
  TreeNum,
  win_size,
  cor_method = c("pearson", "kendall", "spearman"),
  boot = FALSE,
  R = 1000,
  boot.ci = 0.05,
  set_seed = 1,
  dm_stat = c("mean", "min", "max", "median", "amplitude", "change"),
  clim_vars = NULL,
  lag_days = 0,
  accum_days = 1,
  clim_fun = "raw",
  min_complete = NULL,
  p_adjust_method = "BH"
)

Arguments

df

A data frame with the first column containing date-time in the format yyyy-mm-dd HH:MM:SS (or convertible to POSIXct) and dendrometer series in the following columns.

Clim

A data frame with the first column containing daily date (yyyy-mm-dd, Date, or convertible) and one or more climate variables in the following columns.

TreeNum

Integer indicating the dendrometer series to analyze.

win_size

Integer giving the running window size in days. Minimum is 18.

cor_method

Correlation method: one of "pearson", "kendall", or "spearman".

boot

Logical. If TRUE, bootstrap confidence intervals are computed for each running correlation.

R

Integer number of bootstrap iterations.

boot.ci

Numeric confidence level selector: one of 0.01, 0.05 (default), or 0.1.

set_seed

Integer seed for reproducibility of bootstrap results.

dm_stat

Daily dendrometer statistic used for correlation. One of "mean", "min", "max", "median", "amplitude", or "change".

clim_vars

Optional character vector of climate variables to analyze. If NULL, all numeric climate variables are used.

lag_days

Climate lag in days. Can be:

  • one value for all selected climate variables

  • one value per selected climate variable

  • a named numeric vector keyed by climate variable name

accum_days

Antecedent window length in days for climate transformation. Can be scalar, per-variable, or a named numeric vector.

clim_fun

Climate transformation over the antecedent window. One of "raw", "mean", "sum", "max", "min", or "median". Can be scalar, per-variable, or a named character vector.

min_complete

Minimum number of complete paired observations required in a running window to calculate correlation. If NULL, defaults to max(3, ceiling(0.8 * win_size)).

p_adjust_method

Method for p-value adjustment in the non-bootstrap output. Passed to p.adjust(). Use "none" to skip adjustment.

Details

The dendrometer series is first aggregated to daily resolution. The daily dendrometer statistic used for correlation is controlled by dm_stat:

  • "mean": daily mean dendrometer value

  • "min": daily minimum

  • "max": daily maximum

  • "median": daily median

  • "amplitude": daily amplitude (max - min)

  • "change": day-to-day change in the daily mean

Users can choose the climate variables to analyze via clim_vars. Climate transformation settings can be given as:

  • a single value applied to all selected climate variables

  • an unnamed vector with one value per selected climate variable

  • a named vector mapping each selected climate variable to its own setting

This applies to clim_fun, lag_days, and accum_days.

Value

A list with class "mov_cor_dm" (and "mov_cor_dm_boot" if bootstrapped) containing:

  • results: named list of tibbles, one per climate variable

  • metadata: analysis metadata

  • call: the matched function call

Examples


library(dendRoAnalyst)
data(gf_nepa17)
data(ktm_rain17)

# one common climate transformation for all selected variables
out_corr <- mov.cor.dm(
  df = gf_nepa17,
  Clim = ktm_rain17,
  TreeNum = 1,
  win_size = 21,
  clim_fun = "raw"
)
print(out_corr)
summary(out_corr)

# variable-specific climate transformations
out_varfun <- mov.cor.dm(
  df = gf_nepa17,
  Clim = ktm_rain17,
  TreeNum = 1,
  win_size = 21,
  clim_vars = c("rainfall"),
  clim_fun = c(rainfall = "sum"),
  lag_days = c(rainfall = 1),
  accum_days = c(rainfall = 7)
)

# bootstrap confidence intervals
out_boot <- mov.cor.dm(
  df = gf_nepa17,
  Clim = ktm_rain17,
  TreeNum = 1,
  win_size = 21,
  boot = TRUE,
  R = 250
)
summary(out_boot)



dendRoAnalyst documentation built on May 20, 2026, 5:07 p.m.