cosine {rioplot} | R Documentation |
Compute the Cosine similarity between two points.
Description
Given two points, the function computes the cosine similarity between them.
Usage
cosine(x,y)
Arguments
x |
Point 1 |
y |
Point 2 |
Value
The cosine similarity, ranging between -1 and +1.
Author(s)
Ronald L. Breiger, David Melamed and Eric Schoon
References
Schoon, Eric, David Melamed, and Ronald L. Breiger. 2023. Regression Inside Out. NY: Cambridge University Press.
Examples
data(Kenworthy99)
m1 <- lm(scale(dv) ~ scale(gdp) + scale(pov) + scale(tran) -1,data=Kenworthy99)
rp1 <- rio.plot(m1,include.int="no",r1=1:15)
cosine(rp1$row.dimensions[15,],rp1$row.dimensions[8,])
# cosine similarity between USA and Ireland
cosine(rp1$row.dimensions[15,],rp1$row.dimensions[14,])
# cosine similarity between USA and United Kingdom
[Package rioplot version 1.1.1 Index]