View source: R/semireg-methods.R
| predict.semireg | R Documentation |
Population predictions of a semireg() or semireg_tmb() fit at new data: the fixed effects and
the smooth terms, with the other random effects (and random curves s(x) | g) at zero. For the fitted
values with every random effect, use fitted().
## S3 method for class 'semireg'
predict(
object,
newdata = NULL,
type = c("link", "response", "lpmatrix"),
se.fit = FALSE,
unconditional = NULL,
sm_term = NULL,
...
)
object |
A |
newdata |
A data frame with the variables of the fixed part and of the smooths; default: the data of the fit. |
type |
|
se.fit |
Return standard errors as well (a list with |
unconditional |
Include the uncertainty of the smoothing parameters (the first-order correction of
|
sm_term |
The smooth blocks to include (default all; names as in |
... |
Not used. |
semipred() answers another question: curves on a reference grid, averaged over the factors not in
modelterm, with other covariates at reference values. predict() gives one value per row of
newdata, from that row's own values; averaged over the same grid it gives semipred()'s means.
The design is that of semipred() (mgcv::PredictMat() of the stored smooths, then the map to the
fit's random-effect columns), so predict() at the points of a semipred() grid gives its estimates
and SEs. Offsets written in the formula (offset(o)) are taken from newdata; an offset given as
the offset argument of the fit is not (as predict.gam()).
A vector of predictions, a list with fit and se.fit, or the "lpmatrix".
The attribute "unconditional" says whether the correction was used.
set.seed(1)
d <- data.frame(x = runif(100), g = gl(10, 10))
d$y <- sin(2 * pi * d$x) + rnorm(10, sd = 0.3)[d$g] + rnorm(100, sd = 0.3)
fit <- semireg(y ~ s(x) + (1 | g), data = d)
predict(fit, data.frame(x = c(0.25, 0.5)), se.fit = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.