s | R Documentation |
This function can be used inside the formula specification
of the linear predictor in create_sampler
or
generate_data
. The smooth term is set up by
the smooth term specification function s
of package mgcv. The smooth term is usually composed
of random (penalised) effects as well as a few fixed
(unpenalised) effects, not including an intercept.
s(..., unit.precision = FALSE, name = "", debug = FALSE)
... |
parameters passed to |
unit.precision |
to be implemented. |
name |
the name of the model component. By default the name will be 's'
with the number of the model term attached. This name is used in the output
of the MCMC simulation function |
debug |
if |
An object with precomputed quantities and functions for sampling from prior or conditional posterior distributions for this model component, intended for internal use by other package functions.
S.N. Wood (2017). Generalized additive models: an introduction with R. Chapman and Hall/CRC.
## Not run:
library(mgcv)
set.seed(0)
dat <- gamSim(5, n=200, scale=2)
b <- gam(y ~ x0 + s(x1) + s(x2) + s(x3), data=dat)
sampler <- create_sampler(
y ~ x0 + s(x1) + s(x2) + s(x3), data=dat
)
sim <- MCMCsim(sampler, store.all=TRUE)
(summ <- summary(sim))
plot(
coef(b),
c(summ$reg1[, "Mean"],
summ$s2_r[, "Mean"], summ$s2_f[, "Mean"],
summ$s3_r[, "Mean"], summ$s3_f[, "Mean"],
summ$s4_r[, "Mean"], summ$s4_f[, "Mean"]
)
); abline(0, 1)
predb <- predict(b, newdata=dat[1:5, ])
pred <- predict(sim, newdata=dat[1:5, ], type="response")
(summpred <- summary(pred))
plot(predb, summpred[, "Mean"]); abline(0, 1)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.