sparse_weights {CCMMR} | R Documentation |

## Computation of sparse weight matrix

### Description

Construct a sparse weight matrix in a dictionary-of-keys format.
Each nonzero weight is computed as `exp(-phi * ||x_i - x_j||^2)`

, where
the squared Euclidean distance may be scaled by the average squared Euclidean
distance, depending on the argument `scale`

. Sparsity is achieved by
only setting weights to nonzero values that correspond to two objects that
are among each other's `k`

nearest neighbors.

### Usage

```
sparse_weights(
X,
k,
phi,
connected = TRUE,
scale = TRUE,
connection_type = "SC"
)
```

### Arguments

`X` |
An |

`k` |
The number of nearest neighbors to be used for non-zero weights. |

`phi` |
Tuning parameter of the Gaussian weights. Input should be a nonnegative value. |

`connected` |
If |

`scale` |
If |

`connection_type` |
Determines the method to ensure a connected weight
matrix if |

### Value

A `sparseweights`

object containing the nonzero weights in
dictionary-of-keys format.

### Examples

```
# Load data
data(two_half_moons)
data = as.matrix(two_half_moons)
X = data[, -3]
y = data[, 3]
# Get sparse distances in dictionary of keys format with k = 5 and phi = 8
W = sparse_weights(X, 5, 8.0)
```

*CCMMR*version 0.2 Index]