Learn R Programming

growthTrendR (version 0.2.2)

gamm_radius: detrending model on tree-ring width series

Description

models the biological growth trends in individual tree-ring width series using mgcv::gamm

Usage

gamm_radius(data, resp_scale = "resp_gamma", m.candidates)

Value

list including model, fitting statistics, ptable, stable and prediction table

Arguments

data

data containing all necessary columns to run the model

resp_scale

Character. Specifies how the response variable is treated in the model.

  • "resp_gaussian": Uses the response on its original scale, assuming a Gaussian distribution with an identity link (no transformation applied).

  • "resp_log": Log-transforms the response before modelling. The transformed response is then assumed to follow a Gaussian distribution with an identity link.

  • "resp_gamma": Keeps the response on its original scale, fitted under a Gamma distribution with a log link. Suitable for strictly positive and right-skewed data.

m.candidates

the list of candidate equations.

Details

This function models the biological growth trends in individual tree-ring width series using mcgv::gamm. By integrating a first-order autoregressive (AR1) component, it accounts for temporal autocorrelation. This method can provide “normalized” residuals, which are adjusted to reflect deviations after considering the AR1 correlation structure. 'Normalized' residuals are valuable for further analyses, such as investigating relationships with climatic variables. If users specify multiple candidate models through the m.candidates argument, the function will fit each candidate model using the maximum likelihood (ML) method. The corrected Akaike Information Criterion (AICc) will then be compared to determine the best-fitting model. Once the optimal model is identified, it will be refitted using the restricted maximum likelihood (REML) method and output the results.

If users specify only 1 candidate model through the m.candidates argument, the model is fitted with "REML" method.

Examples

Run this code

# loading processed data
dt.samples_trt <- readRDS(system.file("extdata", "dt.samples_trt.rds", package = "growthTrendR"))
# pre-data for model
dt.samples_long <- prepare_samples_clim(dt.samples_trt)

dt.m <- dt.samples_long[uid_site == 1][ageC >1]

# gamm_radius model
m.radius <-gamm_radius(data = dt.m, resp_scale = "resp_log",
                                       m.candidates = c( "rw_mm ~ s(year)",
                                                         "rw_mm ~ s(year)"))

Run the code above in your browser using DataLab