simulate.gam | R Documentation |
This method can be used to simulate vectors of responses from a gamObject.
## S3 method for class 'gam'
simulate(
object,
nsim = 1,
seed = NULL,
method = "auto",
newdata,
u = NULL,
w = NULL,
offset = NULL,
trans = NULL,
...
)
object |
the output of a |
nsim |
the number of simulated vectors of responses. A positive integer. |
seed |
currently not used. |
method |
the method used for the simulation. If set to "rd" then |
newdata |
Optional new data frame or list to be passed to predict.gam. |
u |
a matrix where each row is a vector of uniform random variables in (0, 1).
This will be used to simulate responses only if |
w |
vector of prior weights to be used in the simulations. If |
offset |
numeric vector of offsets. For GAMs with multiple linear predictor (see eg gaulss) it
must be a list of vectors. NB: if |
trans |
function used to transform or summarize each vector of simulated responses.
It must take a vector as argument, but it can output a vector or a scalar.
Potentially useful for saving storage (e.g. by transforming each simulated vector
to a scalar). If left to |
... |
extra arguments passed to |
A matrix where each column is a vector of simulated responses. The number of rows is equal to the number of responses in the fitted object.
library(mgcViz)
set.seed(2) ## simulate some data...
dat <- gamSim(1,n=400,dist="normal",scale=2)
b <- gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat)
# Simulate three vectors of responses
matplot(simulate(b, nsim = 3), pch = 19, col = c(1, 3, 4))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.