Home   >   User Resources   >   Online Help   >   apakNearestNeighbour.Regression
 

 

Function index Version 3.0.0

apakNearestNeighbour.Regression(k, DataMatrix)

Excel=apakNearestNeighbour.Regression(k, DataMatrix)

Result

k-nearest neighbors (kNN) regression: for each data point, an OLS regression with a constant is fitted to the data point and its k nearest neighbors, and the fitted value at the data point is returned. Returns a 1 x c vector.

Syntax

k: number of nearest neighbors to consider, between the number of regressors r - 1 and c - 1

DataMatrix: r x c data matrix; row 1 contains the dependent variable, rows 2 to r the regressors. Objects are in columns.

Remarks

Neighbors are determined by the Euclidean distance in regressor space (rows 2 to r); ties are broken by the lower column index. Since the data point itself is part of each local regression, the fitted values are in-sample.

Pressing Esc aborts the calculation; the function then returns "Calculation aborted by user."