# ipd.mat: Interpoint Distance Matrix In nnspat: Nearest Neighbor Methods for Spatial Patterns

## Description

This function computes and returns the distance matrix computed by using the specified distance measure to compute the distances between the rows of the set of points `x` and `y` using the `dist` function in the `stats` package of the standard R distribution. If `y` is provided (default=`NULL`) it yields a matrix of distances between the rows of `x` and rows of `y`, otherwise, it provides a square matrix with i,j-th entry being the distance between row i and row j of `x`. This function is different from the `dist` function in the `stats` package. `dist` returns the distance matrix in a lower triangular form, and `ipd.mat` returns in a full matrix. ... are for further arguments, such as `method` and `p`, passed to the `dist` function.

## Usage

 `1` ```ipd.mat(x, y = NULL, ...) ```

## Arguments

 `x` A set of points in matrix or data frame form where points correspond to the rows. `y` A set of points in matrix or data frame form where points correspond to the rows (default=`NULL`). `...` Additional parameters to be passed on the `dist` function.

## Value

A distance matrix whose i,j-th entry is the distance between row i of `x` and row j of `y` if `y` is provided, otherwise i,j-th entry is the distance between rows i and j of `x`.

Elvan Ceyhan

## See Also

`dist`, `ipd.mat.euc`, `dist.std.data`

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23``` ```#3D data points n<-3 X<-matrix(runif(3*n),ncol=3) mtd<-"euclidean" #try also "maximum", "manhattan", "canberra", "binary" ipd.mat(X,method=mtd) ipd.mat(X,method="minkowski",p=6) n<-5 Y<-matrix(runif(3*n),ncol=3) ipd.mat(X,Y,method=mtd) ipd.mat(X[1,],Y,method=mtd) ipd.mat(c(.1,.2,.3),Y,method=mtd) ipd.mat(X[1,],Y[3,],method=mtd) #1D data points X<-as.matrix(runif(3)) # need to be entered as a matrix with one column #(i.e., a column vector), hence X<-runif(3) would not work ipd.mat(X) Y<-as.matrix(runif(5)) ipd.mat(X,Y) ipd.mat(X[1,],Y) ipd.mat(X[1,],Y[3,]) ```

nnspat documentation built on May 10, 2021, 9:06 a.m.