lengthintervals {adlift}R Documentation

lengthintervals

Description

This function constructs the vector of interval lengths from a vector of interval endpoints.

Usage

lengthintervals(X, I, type = "midpoints", neighbours, closest)

Arguments

X

The vector of gridpoints.

I

a vector of interval endpoints. This is of length length(X)+1.

type

a character string, either "midpoints" or "average", denoting the way of computing the interval lengths, if closest=TRUE. If "average", then the average neighbour distance is associated as the interval lengths to the gridpoints; otherwise the lengths are associated from the interval vector, I in the obvious way : right endpoint - left endpoint.

neighbours

the number of neighbours to be used in the prediction step of the transform. This is only used if closest=TRUE, since it specifies how many distances to average over when type="average".

closest

indicates whether the neighbourhood structure to be used in the transform is symmetrical or not. When combined with type="average", enables the option of average closest neighbour distance as the associated interval lengths to the gridpoints.

Details

The function computes the interval lengths by finding the differences between the consecutive entries of the supplied interval vector I. In the case of the choice of average closest neighbour distance interval association, the method uses the function getnbrs to find the initial neighbours of each gridpoint to compute the average distances.

Value

lengths

a vector of length(X) with the intervals lengths associated to the gridpoints.

initialnbrs

a matrix with columns order(X), possibly together with the neighbour indices into X of each gridpoint, if type="average".

initialindex

If closest=TRUE and type="average", a matrix of dimension length(X) x neighbours, showing the indices into order(X) of the neighbours of each gridpoint. Otherwise is NULL.

Author(s)

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

See Also

getnbrs, intervals

Examples

input<-runif(10)
#gridpoint vector
#
I<-intervals(input,"reflect")
#create the interval endpoint vector using the input
#
lengthintervals(input,I,"average",3,TRUE)
#
#computes 'intervals' based on 3 closest neighbour distance averages
#

[Package adlift version 1.4-5 Index]