View source: R/knnImputation.R

rho_knn | R Documentation |

`rho_knn`

uses the KNN approach to estimate the probabilities of the disease status in case of three categories.

```
rho_knn(
x_mat,
dise_vec,
veri_stat,
k,
type = c("eucli", "manha", "canber", "lagran", "mahala"),
trace = FALSE
)
```

`x_mat` |
a numeric design matrix. |

`dise_vec` |
a n * 3 binary matrix with three columns, corresponding to the three classes of the disease status. In row i, 1 in column j indicates that the i-th subject belongs to class j, with j = 1, 2, 3. A row of |

`veri_stat` |
a binary vector containing the verification status (1 verified, 0 not verified). |

`k` |
an integer value/vector, which indicates the number of nearest neighbors. It should be less than the number of the verification subjects. |

`type` |
a distance measure. |

`trace` |
switch for tracing estimation process. Default |

`type`

should be selected as one of `"eucli"`

, `"manha"`

, `"canber"`

, `"lagran"`

, `"mahala"`

corresponding to Euclidean, Manhattan, Canberra, Lagrange and Mahalanobis distance. In practice, the selection of a suitable distance is typically dictated by features of the data and possible subjective evaluations. For example, if the covariates are heterogeneous with respect to their variances (which is particularly true when the variables are measured on heterogeneous scales), the choice of the Mahalanobis distance may be a good choice.

For the number of nearest neighbors, a small value of `k`

, within the range 1-3, may be a good choice. In general, the choice of `k`

may depend on the dimension of the feature space, and propose to use cross–validation to find `k`

in case of high–dimensional covariate. See `cv_knn`

.

`rho_knn`

returns a list containing the following components:

`values` |
estimates of the probabilities. |

`X` |
a design model matrix. |

`K` |
the number of nearest neighbors. |

`type` |
the chosen distance. |

To Duc, K., Chiogna, M. and Adimari, G. (2020)
Nonparametric estimation of ROC surfaces in presence of verification bias.
*REVSTAT-Statistical Journal*. **18**, 5, 697–720.

```
data(EOC)
x_mat <- cbind(EOC$CA125, EOC$CA153, EOC$Age)
dise_na <- pre_data(EOC$D, EOC$CA125)
dise_vec_na <- dise_na$dise_vec
## Euclidean distance, k = 1
out_ecul_1nn <- rho_knn(x_mat, dise_vec_na, EOC$V, k = 1, type = "eucli")
## Manhattan distance, k = 1
out_manh_1nn <- rho_knn(x_mat, dise_vec_na, EOC$V, k = 1, type = "manha")
## Canberra distance, k = 3
out_canb_1nn <- rho_knn(x_mat, dise_vec_na, EOC$V, k = 3, type = "canber")
## Lagrange distance, k = 3
out_lagr_1nn <- rho_knn(x_mat, dise_vec_na, EOC$V, k = 3, type = "lagran")
## Mahalanobis distance, k = c(1,3)
out_maha_13nn <- rho_knn(x_mat, dise_vec_na, EOC$V, k = c(1, 3),
type = "mahala")
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.