Skip to contents

Mirrors the C# LinearRegression.Predict/PredictionIntervals methods.

Usage

# S3 method for class 'corehydro_lm'
predict(object, newdata, interval = FALSE, level = 0.9, ...)

Arguments

object

a corehydro_lm from linear_regression().

newdata

a numeric matrix of predictors with the same number of columns as the x the model was fitted with (an intercept column, if any, is added internally), or a numeric vector for a single-predictor model.

interval

if TRUE, also return the level prediction interval (a Student-t interval around the mean response, mirroring PredictionIntervals). Default FALSE.

level

prediction interval level, between 0 and 1. Default 0.90, matching PredictionIntervals's own alpha = 0.1 default.

...

unused; present for generic consistency.

Value

with interval = FALSE, a numeric vector of predicted values, one per row of newdata. With interval = TRUE, a matrix with columns lower, upper, mean.

Examples

x <- cbind(c(1, 2, 3, 4, 5), c(2, 1, 4, 3, 5))
y <- c(3.1, 4.2, 8.1, 9.2, 13.0)
fit <- linear_regression(x, y)
predict(fit, cbind(1, 2))
#> [1] 3.02