This function calculates, for a linear (in its parameters) model, the plastic variance of the average (over genotypes) reaction norm shape \(V_{\text{Plas}}\) and its \(\varphi\)-decomposition (depending on the parameters rather than slope/curvature). This is especially useful when the reaction norm model was a polynomial.
rn_phi_decomp(theta, X, S = NULL, wt_env = NULL, correction = FALSE, v_plas = NA)This function yields the \(\pi\)-decomposition of \(V_{\text{Plas}}\) as a one-row data.frame. If \(V_{\text{Plas}}\) was provided as an argument (e.g. as computed from a separate character-state model), it also outputs \(M^2\), the ratio between \(V_{\text{Plas}}\) as computed from the linear model parameters and the provided value for \(V_{\text{Plas}}\) (data.frame, all numeric).
Average parameters of the shape function. It must be a named vector, with the names corresponding to the parameters in the shape expression. (numeric)
The design matrix X of the reaction norm model. For a polynomial, X contains all the exponents of the environment. (numerical matrix)
The error variance-covariance matrix of the estimated fixed effects theta. Not mandatory, but it is strongly advised to correct for the error variance in the parameter estimates. The function throws a warning if it is NULL (numerical matrix).
Weights to apply to the env vector values, providing an information regarding their relative probability in the biological context. The weights must non-negative, and at least one must non-zero. The vector wt_env must be the same length as env. By default, no weighting is applied. (numeric)
Should Bessel's correction (dividing the sum-of-squares by N-1 rather than N) be used (TRUE) or not (FALSE, default). The default is FALSE, because it is likely that other components such as the total phenotypic variance is computed over the number of individuals (generally large number) rather than the number of environments (generally small number). The best is to manually use Bessel's correction over the proper number of data points. (boolean)
If already computed, an estimate for \(V_{\text{Plas}}\). If NA, then \(V_{\text{Plas}}\) will be computed by the function. (numeric)
Pierre de Villemereuil
The variance \(V_{\text{Plas}}\) is the variance arising from the shape of the reaction norm after avering over the genetic variance, i.e. the purely environmental part of the variance of plasticity in the reaction norm. Its \(\phi\)-decomposition is based on the parameters of the linear model \(\mathbf{X}\theta\), rather than on slope and curvature, as for the \(\pi\)-decomposition.
It is very important that the parameters are in the same order in theta (which, again, must be named) and in G_theta.
rn_pi_decomp, rn_vplas
# Parameters
vec_env <- rnorm(20)
theta <- c(a = 1.5, b = 0.5, c = -0.5)
X <- cbind(1, vec_env, (vec_env - mean(vec_env))^2)
S <- (10^-4) * diag(3)
# Computing the phi-decomposition
rn_phi_decomp(theta = theta, X = X, S = S)
Run the code above in your browser using DataLab