dlm: Dendro-flavoured linear model

Description Usage Arguments Details Value Author(s) Examples

View source: R/dlm.R

Description

This is a wrapper around lm for working with the same data structures and modifiers as dcc does.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
dlm(
  chrono,
  climate,
  selection,
  timespan = NULL,
  var_names = NULL,
  param_names = NULL,
  intercept = TRUE,
  scale = FALSE
)

Arguments

chrono

data.frame containing a tree-ring chronologies, e.g. as obtained by chron of package dplR.

climate

either a data.frame or matrix with climatic data in monthly resolution, with year, month and climate parameters in columns (all columns except year and month will be recognized as parameters for response or correlation functions), or a single data.frame or matrix in 13-column format (see below), or a (potentially named) list of one or several of the latter.

selection

either a numeric vector, a modifier, or a chain of modifiers specifying the parameter selection for the model (see Details).

timespan

integer vector of length 2 specifying the time interval (in years) to be considered for analysis. Defaults to the maximum possible interval.

var_names

character vector with variable names. Defaults to corresponding column names of parameter climate if given as data.frame, or its names if given as list.

param_names

character vector with parameter names. Defaults to auto-generated (potentially compound) names.

intercept

logical: should intercept be included in model?

scale

logical: should data be scaled prior to computing model? If TRUE, intercept will be set to FALSE.

Details

Input chronology data can be a data.frame such as produced by function chron of package dplR. It has to be a data.frame with at least one column containing the tree-ring indices, and the corresponding years as rownames.

For climatic input data, there are three possibilities: Firstly, input climatic data can be a data.frame or matrix consisting of at least 3 rows for years, months and at least one climate parameter in the given order. Secondly, input climatic data can be a single data.frame or matrix in the style of the original DENDROCLIM2002 input data, i.e. one parameter with 12 months in one row, where the first column represents the year. Or thirdly, input climatic data can be a (potentially named) list of one or several of the latter described data.frame or matrices. If named list is provided, potentially provided variable names through argument var_names are ignored. As an internal format dispatcher checks the format automatically, it is absolutely necessary that in all three cases, only complete years (months 1-12) are provided. It is not possible to mix different formats in one go.

In 'dlm', there is no default parameter selection, in contrast to 'dcc'. Parameters can be selected with the 'selection' parameter in two different ways:

For the exclusion of months, the convenience function exclude_from (or short exfr) is provided.

With 'dlm' one would usually try to keep the number of predictors low.

For pretty output of the resulting linear model, parameters can be renamed, to e.g. reflect the season they represent.

Value

'dlm' returns an 'object' of class '"tc_dlm"', which is a superclass of 'lm'. Additional elements to what is included in standard 'lm' objects:

call_dlm

the call made to function 'dlm'

design

the design matrix on which this call to 'dlm' operates

truncated

the input data truncated to the common timespan or the specified timespan

original

the original input data, with the climate data being recast into a single data.frame

Author(s)

Christian Zang

Examples

1
2
3
4
5
6
7
8
dlm1 <- dlm(rt_spruce, rt_prec, .sum(6:8), param_names = "summer_prec")
summary(dlm1)

dlm2 <- dlm(rt_spruce, list(rt_prec, rt_temp),
  .sum(6:8, "prec") + .mean(6:8, "temp"), var_names = c("prec", "temp"),
  param_names = c("summer_prec", "summer_temp"))
summary(dlm2)
anova(dlm1, dlm2)

cszang/treeclim documentation built on Feb. 18, 2022, 4:54 a.m.