trending (version 0.0.2)

trending_model_fit-prediction: Predict methods

Description

These functions can be used to generated estimated values and associated confidence/prediction intervals for trending_model_fit objects.

Usage

# S3 method for trending_model_fit
predict(object, new_data, alpha = 0.05, add_pi = TRUE, uncertain = TRUE, ...)

# S3 method for trending_model_fit_list predict(object, new_data, alpha = 0.05, add_pi = TRUE, uncertain = TRUE, ...)

Arguments

object

A trending_model_fit or trending_model_fit_list object.

new_data

A data.frame containing data for which predictions are to be derived.

alpha

The alpha threshold to be used for prediction intervals, defaulting to 0.05, i.e. 95% prediction intervals are derived.

add_pi

Add a prediction interval to the output. Default TRUE.

uncertain

Only used for glm models. Default TRUE. If FALSE uncertainty in the fitted paramaters is ignored when generating the prediction intervals.

...

Not currently used.

x = rnorm(100, mean = 0) y = rpois(n = 100, lambda = exp(1.5 + 0.5*x)) dat <- data.frame(x = x, y = y)

poisson_model <- glm_model(y ~ x , family = "poisson") negbin_model <- glm_nb_model(y ~ x)

fitted_poisson <- fit(poisson_model, dat) fitted_list <- fit(list(poisson_model, negbin_model), dat)

predict(fitted_poisson) predict(fitted_list)