Description Usage Arguments Value Author(s) Examples
For each smooth in a GAM, generate new data over the range of the variables in volved in a smooth.
1 2 3 4 5 6 7 8 9 10 |
x |
an object for which new data is required. Currently objects of classes |
... |
arguments passed to methods |
n |
numeric; the number of data values to generate per term in each smooth. |
data |
data frame; for |
A data frame of new values spread over the range of the observed values.
Gavin L. Simpson
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | library("mgcv")
## 1d example
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")
df <- datagen(m1)
head(df)
## 2d example
dat <- gamSim(2, n = 400, dist = "normal", scale = 2)
m2 <- gam(y ~ s(x, z), data = dat$data, method = "REML")
df <- datagen(m2)
head(df)
## alternative showing using the mgcv.smooth method for a single smooth
df2 <- datagen(m2[["smooth"]][[1L]], data = dat$data)
head(df2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.