Learn R Programming

lazy (version 1.2-14)

predict.lazy: Predict method for lazy learning

Description

Obtains predictions from a lazy learning object

Usage

## S3 method for class 'lazy':
predict(object, newdata=NULL,
          t.out=FALSE, k.out=FALSE,
            S.out=FALSE, T.out=FALSE, I.out=FALSE, \dots)

Arguments

object
Object of class inheriting from lazy.
newdata
Data frame (or matrix, vector, etc...) defining of the query points for which a prediction is to be produced.
t.out
Logical switch indicating if the function should return the parameters of the local models used to perform each estimation.
k.out
Logical switch indicating if the function should return the number of neighbors used to perform each estimation.
S.out
Logical switch indicating if the function should return the estimated variance of the prediction suggested by all the models identified for each query point.
T.out
Logical switch indicating if the function should return the parameters of all the models identified for each query point.
I.out
Logical switch indicating if the function should return the index i of all the samples (X[i,],Y[i]) used to perform each estimation.
...
Arguments passed to or from other methods.

Value

  • The output of the method is a list containing the following components:
  • hVector of q elements, where q is the number of rows in newdata, i.e. the number of query points. The element in position i is the estimate of the value of the unknown function in the query point newdata[i,]. The component h is always returned.
  • tMatrix of z*q elements, where z=z2 i.e., number of parameters of a quadratic model if at least one model of degree 2 was identified (see quaIdPar in lazy.control), otherwise z=z1 i.e., number of parameters of a linear model if at least one model of degree 1 was identified (see linIdPar in lazy.control), or z=1 if only models of degree 0 where considered. In the general case, the elements of the vector t[,j]=c(a0, a1,..., an, a11, a12,..., a22, a23,..., a33, a34,..., ann) are the parameters of the local model used for estimating the function in the jth query point: the cross-terms terms a11,a12,...,ann wil be missing if no quadratic model is identified and the terms a1,...,an, will be missing if no linear model is identified. If, according to cmbPar (see lazy.control), estimations are to be performed by a combination of models, the elements of t[,j] are a weighted average of the parameters of the selected models where the weight of each model is the inverse of the a leave-one-out estimate of the variances of the model itself. REMARK: a translation of the axes is considered which centers all the local models in the respective query point.
  • kVector of q elements. Selected number of neighbors for each query point. If, according to cmbPar (see lazy.control), a local combination of models is considered, k[j] is the largest value among the number of neighbors used by the selected models for estimating the value in the jth query point.
  • SList of up to 3 components: Each component is a matrix containing an estimate, obtained through a leave-one-out cross-valication, of the variance of local models. [object Object],[object Object],[object Object] The component S is returned only if S.out=TRUE in the function call.
  • TList of up to 3 components: [object Object],[object Object],[object Object] REMARK: a translation of the axes is considered which centers all the local models in the respective query point. The component T is returned only if T.out=TRUE in the function call.
  • IMatrix of idM*q elements, where idM is the largest of idM0, idM1, and idM2. Contains the index of the neighbors of each query point in newdata. In particular, I[i,j] is the ith nearest neighbor of the qth query point.

See Also

lazy, lazy.control

Examples

Run this code
data(cars)
cars.lazy <- lazy(dist ~ speed, cars)
predict(cars.lazy, data.frame(speed = seq(5, 30, 1)))

Run the code above in your browser using DataLab