Skip to contents

Computes predictions from a fitted Compound Poisson-Normal (CPN) regression model. Supports predictions on the link, rate, or response scale, with optional confidence intervals.

Usage

# S3 method for class 'cpn'
predict(
  object,
  newdata = NULL,
  type = c("link", "rate", "response"),
  interval = c("none", "confidence"),
  level = 0.95,
  ...
)

Arguments

object

An object of class cpn, typically the result of a call to a function fitting a Compound Poisson-Normal regression model.

newdata

An optional data frame in which to look for variables with which to predict. If omitted, the original model data is used.

type

Type of prediction: "link" returns the linear predictor \(\eta = X\beta\); "rate" returns \(\exp(\eta)\); "response" returns the mean response \(E[Y] = \mu \cdot \exp(\eta)\).

interval

Type of interval calculation. Either "none" (default) or "confidence" for confidence intervals around the predicted values.

level

Confidence level for the interval. Defaults to 0.95.

...

Further arguments passed to or from other methods (not currently used).

Value

If interval = "none", returns a numeric vector of predicted values on the specified scale. If interval = "confidence", returns a data frame with columns:

fit

Predicted value

lwr

Lower bound of the confidence interval

upr

Upper bound of the confidence interval

Details

For predictions on the response scale with confidence intervals, the standard errors of both the linear predictor and the estimated mu parameter are combined using the delta method.

Factor levels in newdata are aligned to match those used in the original model fit.

Examples

if (FALSE) { # \dontrun{
fit <- cpn(y ~ x1 + x2, data = mydata)
predict(fit, newdata = mynewdata, type = "response", interval = "confidence")
} # }