Description Usage Arguments Value Examples
Simulate response data given input lagged env data and an expression
1 | simResponse(x, mu, rfunc = stats::rnorm, ...)
|
x |
data.frame containing at least 1 matrix column of lagged data |
mu |
R expression describing how mean response relates to variables in x |
rfunc |
function generating response from mean and parameters in ... |
... |
additional arguments to rfunc |
data.frame with all the variables in x plus a response variable
1 2 3 4 5 6 7 8 9 10 11 12 | test <- lagData(env_data, response_data, unit = "month", 6, 24, "envVar")
# generate a response linear in the lag, normal errors sd = 5
test1 <- simResponse(test, 0.05*x1 + rowSums(0.1*lag_6_24*envVar_6_24), sd = 5)
fit1 <- mgcv::gam(response ~ x1 + s(lag_6_24, by = envVar_6_24), data = test1)
summary(fit1)
# poisson response with sine function of lag and an offset
test2 <- simResponse(test, exp(-2 + log(offset) - 0.05*x1 +
rowSums(envVar_6_24*sin(lag_6_24/pi))), rpois)
fit2 <- mgcv::gam(response ~ offset(log(offset)) + x1 + s(lag_6_24, by = envVar_6_24),
data = test2, family = poisson)
summary(fit2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.