Learn R Programming

KSPM (version 0.2.1)

predict.kspm: Predicting Kernel Semi parametric Model Fits

Description

predict method for class "kspm".

Usage

# S3 method for kspm
predict(object, newdata.linear = NULL,
  newdata.kernel = NULL, interval = "none", level = 0.95, ...)

Arguments

object

an object of class "kspm", usually, a result of a call to kspm.

newdata.linear

should be a data frame or design matrix of variables used in the linear part

newdata.kernel

a list containing data frame or design matrix of variables used in each kernel part depending on the specification format of each kernel. When a kernel has been specified using kernel.function = "gram.matrix" in Kernel function, the user should also provide the Gram matrix associated to the new data points in newdata.kernel. The function info.kspm may help to correctly specify it.

interval

type of interval calculation. If "none" (default), no interval is computed, if "confidence", the confidence interval is computed, if "prediction", the prediction interval is computed.

level

confidence level. Default is level = 0.95 meaning 95% confidence/prediction interval.

...

further arguments passed to or from other methods.

Value

predict.kspm returns a vector of predictions or a matrix containing the following components if interval is set:

fit

predictions.

lwr

lower bound of confidence/prediction intervals.

upr

upper bound of confidence/prediction intervals.

Details

predict.kspm produces predicted values. If a new dataset is not specified, it will return the fitted values from the original data (complete data used in the model specification). If predict.kspm is applied to a new dataset, all variables used in the original model should be provided in newdata.linear and newdata.kernel arguments but only complete data may be provided. Setting interval specifies computation of confidence or prediction intervals at the specified level.

See Also

kspm, summary.kspm.

Examples

Run this code
# NOT RUN {
x <- 1:15
z1 <- runif(15, 1, 6)
z2 <- rnorm(15, 1, 2)
y <- 3*x + (z1 + z2)^2 + rnorm(15, 0, 2)
fit <- kspm(y, linear = ~ x, kernel = ~ Kernel(~ z1 + z2,
kernel.function = "polynomial", d= 2, rho = 1, gamma = 0))
predict(fit, interval = "confidence")

# }

Run the code above in your browser using DataLab