Description Usage Arguments Value Author(s) Examples
Simulations from the posterior distribution of a fitted GAM model involve making random draws from a multivariate normal with mean vector equal to the estimated model coefficients and covariance matrix equal to the covariance matrix of the coefficients.
1 2 3 4 5 6 7 8 9 10 11 | ## S3 method for class 'gam'
simulate(object, nsim = 1, seed = NULL, newdata = NULL,
freq = FALSE, unconditional = FALSE, ...)
## S3 method for class 'gamm'
simulate(object, nsim = 1, seed = NULL, newdata = NULL,
freq = FALSE, unconditional = FALSE, ...)
## S3 method for class 'scam'
simulate(object, nsim = 1, seed = NULL, newdata = NULL,
freq = FALSE, parametrized = TRUE, ...)
|
object |
a fitted GAM, typically the result of a call to |
nsim |
numeric; the number of posterior simulations to return. |
seed |
numeric; a random seed for the simulations. |
newdata |
data frame; new observations at which the posterior draws from the model should be evaluated. If not supplied, the data used to fit the model will be used for |
freq |
logical; |
unconditional |
logical; if |
... |
arguments passed to methods |
parametrized |
logical; use parametrized coefficients and covariance matrix, which respect the linear inequality constraints of the model. |
(Currently) A matrix with nsim
columns.
Gavin L. Simpson
1 2 3 4 5 6 7 8 9 10 11 12 | library("mgcv")
set.seed(2)
dat <- gamSim(1, n = 400, dist = "normal", scale = 2)
m1 <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = dat, method = "REML")
sims <- simulate(m1, nsim = 5, seed = 42)
head(sims)
m2 <- gamm(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = dat, method = "REML")
sims <- simulate(m2, nsim = 5, seed = 42)
head(sims)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.