Fits a GP model to each pair of populations and constructs a matrix of pairwise dynamic correlation (rho) values. The matrix can be passed to fitGP under argument rhomatrix.

getrhomatrix(
  data = NULL,
  y,
  x = NULL,
  pop,
  time = NULL,
  E = NULL,
  tau = NULL,
  scaling = c("global", "local", "none"),
  initpars = NULL,
  modeprior = 1,
  fixedpars = NULL,
  augdata = NULL
)

Arguments

data

A data frame, or matrix with named columns.

y

The response variable (required). If data is supplied, a column name (character) or index (numeric). If data is not supplied, a numeric vector.

x

Predictor variables. If data is supplied, column names (character vector) or indices (numeric vector). If data is not supplied, a numeric matrix (or vector, if there is only one predictor variable). If x is not supplied, values for E and tau must be provided to construct it internally.

pop

Identifies separate populations (optional, if not supplied, defaults to 1 population). Population values can be either numeric, character, or factor. If data is supplied, a column name (character) or index (numeric). If data is not supplied, a vector (numeric, character, or factor).

time

A time index (optional, if not supplied, defaults to a numeric index). Important: The time index is not used for model fitting (timesteps are assumed to be evenly spaced) but supplying time will be add these values to the output table, which may be useful for later plotting purposes. If data is supplied, a column name (character) or index (numeric). If data is not supplied, a numeric vector.

E

Embedding dimension. If supplied, will be used to constuct lags of x (or lags of y if x is not supplied).

tau

Time delay. If supplied, will be used to constuct lags of x (or lags of y if x is not supplied).

scaling

How the variables should be scaled (see Details). Scaling can be "global" (default), "local" (only applicable if more than 1 pop), or "none". Scaling is applied to y and each x. For a mix of scalings, do it manually beforehand and set scaling to "none". All outputs are backtransformed to original scale.

initpars

Starting values for hyperparameters (see Details) in the order c(phi,ve,sigma2,rho), in constrained (non-transformed) space. Should be a numeric vector with length ncol(x)+3. Defaults used if not supplied: c(rep(0.1,ncol(x)), 0.001, 1-0.001, 0.5)

modeprior

This value is used by the phi prior and sets the expected number of modes over the unit interval. Defaults to 1.

fixedpars

Fixes values of the hyperparameters phi, ve, and sigma2 (if desired). Should be a numeric vector with length ncol(x)+2 in the order c(phi,ve,sigma2) in constrained (non-transformed) space. Hyperparameters to estimate should be input as NA. The value of rho is fixed separately using argument rhofixed.

augdata

A data frame with augmentation data (see Details).

Value

A square matrix of pairwise dynamic correlations between all populations. Rows and columns are named with population names.

Details

The pop argument is required and there must be more than 1 population. Function scales data prior to subsetting to each pair of populations.

References

Rogers, T. L. and Munch, S. B. 2020. Hidden similarities in the dynamics of weakly synchronous marine metapopulation. Proceedings of the National Academy of Sciences 117(1):479-485

See also