W_matrix: Build the Matrix of Environmental Covariables for Reaction...

View source: R/Wmatrix.R

W_matrixR Documentation

Build the Matrix of Environmental Covariables for Reaction Norm

Description

Estimates a weather covariable realized matrix with dimensions of q x k, for q environments and k covariables.

Usage

W_matrix(
  env.data,
  is.processed = FALSE,
  id.names = NULL,
  env.id = NULL,
  var.id = NULL,
  probs = NULL,
  by.interval = NULL,
  time.window = NULL,
  names.window = NULL,
  center = TRUE,
  scale = TRUE,
  sd.tol = 10,
  statistic = NULL,
  tol = 0.001,
  QC = FALSE
)

Arguments

env.data

data.frame of environmental variables gotten from get_weather().

is.processed

boolean. Indicates whether the dataframe was previously processed with summaryWTH() and contains means, medians, etc.

id.names

character. Indicates the name of the columns to be used as id for the environmental variables to be analysed.

env.id

character. Indicates the name of the columns to be used as id for environments.

var.id

vector (character). Indicates which variables will be used in the analysis.

probs

vector(numeric). Indicates the probability quantiles, as probs = 0,1, if cardinals is NULL. If is quantiles=NULL, quantiles = c(0.01,.25,.50,.99).

by.interval

boolean. Indicates if temporal intervals must be computed insied of each environment. Default = FALSE.

time.window

vector (numeric). If by.interval = TRUE, this argument indicates the temporal breaks for delimited intervals.

names.window

vector(character). If by.interval = TRUE, this argument indicates the names of the desirable intervals.

center

boolean. Indicates whether the matrix should be centered.

scale

boolean. If scale=TRUE, the variables assume a mean-centered scaled distribution, with x~N(0,1).

sd.tol

numeric. Default value equal to 10.

statistic

vector (character). Indicates what statistic must be runned, statistic = c('all','sum','mean','quantile'). Default: 'mean'.

tol

TODO.

QC

boolean. Indicates with Quality Control is applied. QC is based on the standard deviation tolerance (sd.tol), removing variables (x) with sd(x) > sd.tol

Details

TODO

Value

Returns an environmental covariable realized matrix with dimensions of q x k, for q environments and k covariables.

Author(s)

Germano Costa Neto

Examples

## Not run: 
data("maizeWTH")
env.data = maizeWTH[maizeWTH$daysFromStart < 100,]
### Mean-centered and scaled matrix
W <- W_matrix(env.data = env.data)

### Same as SummaryWTH, we can add time.windows
W <- W_matrix(env.data = env.data, by.interval = TRUE,
              time.window = c(0, 14, 35, 60, 90, 120))

### Selecting statistic to be used
W <- W_matrix(env.data = env.data, by.interval = TRUE, statistic = 'mean',
              time.window = c(0, 14, 35, 60, 90, 120))

W <- W_matrix(env.data = env.data, by.interval = TRUE, statistic = 'quantile',
              time.window = c(0, 14, 35, 60, 90, 120))

### With Quality Control (QC) based on the maximum sd tolerated
W <- W_matrix(env.data = env.data, by.interval = FALSE, QC = TRUE)

### With Quality Control (QC) based on the maximum sd tolerated
W <- W_matrix(env.data = env.data, by.interval = FALSE, QC = TRUE, sd.tol = 3)

### Creating W for specific variables
id.var = c('T2M_MAX','T2M_MIN','T2M')
W <- W_matrix(env.data = env.data, var.id = id.var)

### Combining summaryWTH by using is.processed = TRUE
data <- summaryWTH(env.data, env.id = 'env', statistic = 'quantile')
W <- W_matrix(env.data = data, is.processed = TRUE)


## End(Not run)

allogamous/EnvRtype documentation built on Nov. 1, 2024, 3:48 a.m.