ktd_predict {ktweedie}R Documentation

Predict outcome using fitted kernel Tweedie model

Description

ktd_predict() predicts the outcome with fitted ktweedie or sktweedie model at the user supplied new data.

Usage

ktd_predict(model, newdata, which.lam1 = 1, type = "link")

Arguments

model

Fitted model from ktd_estimate

newdata

New x matrix for the prediction. If not provided, it will be the x matrix used to fit model.

which.lam1

The index of the lam1 in model used in the prediction. Default is 1.

type

The type of prediction to be made - "link" for the linear predictor and "response" for the predicted outcome. Default is "link".

Details

ktd_predict() uses the fitted model from ktd_estimate to estimate the mean outcome for new data points.

Value

A list named prediction containing the vector of predicted outcomes.

See Also

ktd_estimate, ktd_cv, ktd_cv2d

Examples

# Fit a ktweedie model
fit <- ktd_estimate(x = dat$x, y = dat$y,
                    kern = rbfdot(sigma = 1e-6),
                    lam1 = 10^(-5:1))
# Generate newx at which predictions are to be made.
# The newdata should have the same dimension as the original trainig data.
newx <- matrix(rnorm(10 * ncol(dat$x)), nrow = 10)
pred <- ktd_predict(model = fit, newdata = newx,
                    which.lam1 = 3, type = "link")

[Package ktweedie version 1.0.3 Index]