A weighted similarity measure between two numeric vectors.

stats.SimilarityOfVectors(weights, final, initial)

Arguments

weights

Vector of weights for each observation.

final

Vector of numbers.

initial

Vector of numbers.

Value

A percentage of similarity between the two numeric vectors.

Examples

library(goal)

weights=c(0.5, 0.25, 0.25)
final=c(42,5,36)
initial=c(40,5,36)

plot(final, initial, cex=weights*2, col="red",
  xlim=range(initial, final), ylim=range(initial, final))
abline(0,1)


per = goal::stats.SimilarityOfVectors(weights, final, initial)
print(per)
#> [1] 0.9756098