# Some environment vector
vec_env <- rnorm(20)
# Shape function
expr <- expression(
cmax * exp(
- exp(rho * (x - xopt) - 6) -
sigmagaus * (x - xopt)^2
))
# Theta
theta <- c(cmax = 1, xopt = 0.9, rho = 8, sigmagaus = 0.4)
# G, only for cmax and xopt
G <- matrix(c(0.1, 0.01,
0.01, 0.05),
ncol = 2)
# Computing the pi-decomposition of V_Plas
rn_pi_decomp(theta = theta,
V_theta = G,
env = vec_env,
shape = expr,
fixed = c(3, 4))
# Note that fixed is set for the third and forth parameters than are not in G
# Applying some weighting to the environmental values according to a normal distribution
# if the env variable is actually fixed
vec_env2 <- seq(-2, 2, length.out = 20)
rn_pi_decomp(theta = theta,
V_theta = G,
env = vec_env2,
shape = expr,
fixed = c(3, 4),
wt_env = dnorm(vec_env2))
Run the code above in your browser using DataLab