Description Usage Arguments Value Note Author(s) See Also Examples
View source: R/predict.bayesx.R
Takes a fitted "bayesx"
object returned from bayesx
and produces predictions
by refitting the initial model with weights set to zero for new observations.
1 2 3 4 
object 
an object of class 
newdata 
a data frame or list containing the values of the model covariates at which
predictions are required. If missing 
model 
for which model should predictions be calculated, either an integer or
a character, e.g. 
type 
when 
na.action 
function determining what should be done with missing values in 
digits 
predictions should usually be based on the new values provided in argument

... 
not used. 
Depending on the specifications of argument type
.
This prediction method is based on refitting the initial model with weights, i.e., if new
observations lie outside the domain of the respective covariate, the knot locations when using
e.g. Psplines are calculated using the old and the new data. Hence, if there are large gaps
between the old data domain and new observations, this could affect the overall fit of the
estimated spline, i.e., compared to the initial model fit there will be smaller or larger
differences depending on the newdata
provided.
Nikolaus Umlauf, Thomas Kneib, Stefan Lang, Achim Zeileis.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23  ## Not run:
## generate some data
set.seed(121)
n < 500
## regressors
dat < data.frame(x = runif(n, 3, 3), z = runif(n, 0, 1),
w = runif(n, 0, 3))
## generate response
dat$y < with(dat, 1.5 + sin(x) + z 3 * w + rnorm(n, sd = 0.6))
## estimate model
b < bayesx(y ~ sx(x) + z + w, data = dat)
## create some data for which predictions are required
nd < data.frame(x = seq(2, 5, length = 100), z = 1, w = 0)
## prediction model from refitting with weights
nd$fit < predict(b, newdata = nd)
plot(fit ~ x, type = "l", data = nd)
## End(Not run)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.