Predict Nearest-Person Binary Probabilities
Source:R/neighbor_probability.R
predict.neighbor.probability.fit.RdPredict Nearest-Person Binary Probabilities
Arguments
- object
A fitted
fit.neighbor.probabilityobject.- newdata
Query coordinate matrix. With no query data, predict at the stored training rows while excluding each query's whole participant.
- distances
Query-by-training distance matrix for a precomputed fit. Columns must retain the original training record order.
- query.group
Optional participant IDs for query rows. Matching training participants are excluded. Omit only for genuinely new participants.
- k
One or more requested sizes; defaults to the fitted size.
- type
Return a probability matrix or a list including matrices of neighbor counts, case counts, radii and boundary-tie diagnostics.
- ...
Reserved; additional arguments are rejected.
Value
A query-by-size matrix, or a diagnostic list with that matrix as
probability. Unsupported estimates remain NA.
boundary.ties counts distances within 1e-12 of the cutoff;
ordering itself uses exact distance ties. Diagnoses count distinct people.
With positive eps, boundary counts cover retrieved participants
only (boundary.complete = FALSE). search.candidates gives
the final number of candidate records, including visit refinement.
Examples
X <- matrix(0:5, ncol = 1)
f <- fit.neighbor.probability(X, c(1, 0, 1, 0, 0, 1), k = 2)
predict(f) # leave-participant-out, not resubstitution
#> 2
#> 1 0.5
#> 2 1.0
#> 3 0.0
#> 4 0.5
#> 5 0.5
#> 6 0.0
predict(f, matrix(2.5, ncol = 1), type = "diagnostics")
#> $probability
#> 2
#> [1,] 0.5
#>
#> $neighbors
#> [,1]
#> [1,] 2
#>
#> $cases
#> [,1]
#> [1,] 1
#>
#> $radius
#> [,1]
#> [1,] 0.5
#>
#> $boundary.ties
#> [,1]
#> [1,] 2
#>
#> $split.tie
#> [,1]
#> [1,] FALSE
#>
#> $available.people
#> [1] 6
#>
#> $available.cases
#> [1] 3
#>
#> $search.candidates
#> [1] 6
#>
#> $status
#> 2
#> [1,] "ok"
#>
#> $k
#> [1] 2
#>
#> $method
#> [1] "knn"
#>
#> $metric
#> [1] "euclidean"
#>
#> $distance.backend
#> [1] "geosmooth"
#>
#> $search
#> [1] "ann"
#>
#> $eps
#> [1] 0
#>
#> $boundary.complete
#> [1] TRUE
#>