Learn R Programming

LaMa (version 3.1.0)

predict.LaMa_matrices: Build the prediction design matrix based on new data and model_matrices object created by modmat

Description

Build the prediction design matrix based on new data and model_matrices object created by modmat

Usage

# S3 method for LaMa_matrices
predict(object, newdata, what = NULL, exclude = NULL, ...)

Value

prediction design matrix for newdata with the same basis as used for object

Arguments

object

model matrices object as returned from modmat

newdata

data frame containing the variables in the formula and new data for which to evaluate the basis

what

optional character string specifying which formula to use for prediction if object contains multiple formulas.

exclude

optional vector of terms to set to zero in the predicted design matrix. Useful for predicting main effects only when e.g. s(..., bs = "re") terms are present. See mgcv::predict.gam for more details.

...

for method consistency only

See Also

modmat for creating objects of class LaMa_matrices which can be used for prediction by this function.

Examples

Run this code
# single formula
modmat = modmat(~ s(x), data.frame(x = 1:10))
Z_p = predict(modmat, data.frame(x = 1:10 - 0.5))
# with multiple formulas
modmat = modmat(list(mu ~ s(x), sigma ~ s(x, bs = "ps")), data = data.frame(x = 1:10))
Z_p = predict(modmat, data.frame(x = 1:10 - 0.5), what = "mu")
# nested formula list
form = list(stream1 = list(mu ~ s(x), sigma ~ s(x, bs = "ps")))
modmat = modmat(form, data = data.frame(x = 1:10))
Z_p = predict(modmat, data.frame(x = 1:10 - 0.5), what = c("stream1", "mu"))

Run the code above in your browser using DataLab