getnbrs {adlift}R Documentation

getnbrs

Description

This function uses the user's neighbourhood configuration input to find the neighbours of the lifted datapoint to be used in the prediction step of the transform.

Usage

getnbrs(X, remove, pointsin, neighbours, closest)

Arguments

X

The vector of gridpoints.

remove

the index (into X) of the point to be removed.

pointsin

The indices of gridpoints still to be removed.

neighbours

the number of neighbours to find for use in prediction.

closest

Boolean argument: If FALSE, the neighbours selected are the ones on both sides of the removed point.

Details

The function uses the value of neighbours and closest to choose the neighbours to return. If closest is FALSE, pointsin is used to find neighbours indices on both sides of the index of the removed point (remove). If closest is TRUE, then the function uses the gridpoint vector (X) to calculate distances from the removed point to neighbours neighbours on each side of the removed point (if they exist) and then uses this information to choose the closest neighbours ones, recording where they lie in relation to the removed point, and accordingly their index can be obtained. If the removed point is on the boundary, then by choice, we take only one neighbour.

Value

nbrs

the indices of the neighbours corresponding to the specified configuration.

index

the indices into pointsin of the neighbours

Author(s)

Matt Nunes (nunesrpackages@gmail.com), Marina Knight

See Also

fwtnp

Examples

x1<-runif(20)
#
x1
#
y1<-make.signal2("bumps",x=x1)
#
y1
#
order(x1)
#
# shows where the points lie in relation to each other.
#
neigh<-getnbrs(x1,3,order(x1),4,TRUE)
#
neigh$nbrs
#
# these are the indices of the 4 closest neighbours to point 3.
#

[Package adlift version 1.4-5 Index]