# Some environment vector
vec_env <- seq(-2, 2)
# 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 mean by environment
rn_mean_by_env(env = vec_env,
shape = expr,
theta = theta,
V_theta = G,
fixed = c(3, 4))
# Note that fixed is set for the third and forth parameters than are not in G
# This is (slightly) different from the function evaluated
# using the average values of the parameters in theta
theta["cmax"] * exp(
- exp(theta["rho"] * (vec_env - theta["xopt"]) - 6) -
theta["sigmagaus"] * (vec_env - theta["xopt"])^2
)
Run the code above in your browser using DataLab