Learn R Programming

smacof (version 2.1-7)

sim2diss: Converts similarites to dissimilarities

Description

Utility function for converting similarities into dissimilarities. Different methods are provided.

Usage

sim2diss(s, method = "corr", to.dist = FALSE)

Value

Returns dissimiarities either as matrix or as dist object.

Arguments

s

Similarity matrix (not necessarily symmetric, nor square)

method

Various methods for converting similarities into dissimilarities: "corr", "reverse", "reciprocal", "ranks", "exp", "Gaussian", "cooccurrence", "gravity", "confusion", "transition", "membership", "probability", or an integer value from which the similarity is subtracted

to.dist

If TRUE, object of class dist is produced

Details

The conversion formulas for the various methods can be found in the package vignette.

References

Mair, P., Groenen, P. J. F., De Leeuw, J. (2022). More on multidimensional scaling in R: smacof version 2. Journal of Statistical Software, 102(10), 1-47. tools:::Rd_expr_doi("10.18637/jss.v102.i10")

Examples

Run this code

## Convert crimes data (correlations)
data(crimes)
crimeD <- sim2diss(crimes, method = "corr", to.dist = TRUE)

## Convert Wish data (similarities) by subtracting from 7
data(wish)
wishD <- sim2diss(wish, method = 7, to.dist = TRUE)

## Convert Ekman data (similarities) into dissimilarities
data(ekman)
ekmanD <- sim2diss(ekman, method = "confusion", to.dist = TRUE)

## Convert album ratings (rectangular similarities) by reversing the ratings
data(RockHard)
rockD1 <- sim2diss(RockHard[,5:18], method = "reverse")

Run the code above in your browser using DataLab