dissWeights | R Documentation |
Compute weights as a function of the dissimilarities.
dissWeights(delta, type = c("unif", "knn", "power", "unifpower"),
k = NULL, power = 0)
delta |
Either a symmetric dissimilarity matrix or an object of class |
type |
One of |
k |
The number of smallest dissimilarities per row for which the weights need to be set to 1. The default |
power |
power to which the dissimilarities need to be raised as weights. Default is 0, so that all weights are 1. |
The weights are computed as a function of the dissimilarities depending on type
.
- "unif"
Compute weights such that the weighted empirical distribution (histogram) of the dissimilarities is uniform. Particularly if the number of objects is large, the dissimilarities that occuur most often will start to dominate the solution. This option de-emphasizes often occuring dissimilarities such that the weighted empirical distribution (the weighted histogram) becomes approximately uniform.
- "knn"
Per row of the dissimilarity matrix the k
smallest dissimilarities obtain a weight of 1 and the others a 0.
- "power"
The weights are set to the delta^power
. If power
is small (e.g., power = -5
) then the smaller dissimilarities will be better fitted. If power
is large (e.g., power = 5
) then the larger dissimilarities will be better fitted.
- "unifpower"
First weights are determined by the "unif"
option and then multiplied by the weights obtained by the "power"
option. If the dissimilarity matrix is large, then this option is needed to see an effect of the "power"
option on the MDS solution.
weightmat |
the weight matrix |
Patrick Groenen
## mds solution for kinship data with uniform weights
res <- mds(kinshipdelta, weightmat = dissWeights(kinshipdelta, type = "unif"))
par(mfrow = c(2,2))
plot(res, main = "uniform weights")
plot(res, plot.type = "Shepard")
plot(res, plot.type = "histogram")
## mds solution for kinship data with knn weights
res <- mds(kinshipdelta, weightmat = dissWeights(kinshipdelta, type = "knn", k = 5))
par(mfrow = c(1,2))
plot(res, main = "knn weights with k=5")
plot(res, plot.type = "Shepard")
## mds solution for kinship data with power weights emphasizing large dissimilarities
res <- mds(kinshipdelta, weightmat = dissWeights(kinshipdelta, type = "power", power = 5))
par(mfrow = c(2,2))
plot(res, main = "Power = 5 weights")
plot(res, plot.type = "Shepard")
plot(res, plot.type = "histogram")
## mds solution for kinship data with power weights emphasizing small dissimilarities
res <- mds(kinshipdelta, weightmat = dissWeights(kinshipdelta, type = "power", power = -5))
par(mfrow = c(2,2))
plot(res, main = "Power = -5 weights")
plot(res, plot.type = "Shepard")
plot(res, plot.type = "histogram")
## mds solution for kinship data with power weights emphasizing large dissimilarities
## while correcting for nonuniform dissimilarities
res <- mds(kinshipdelta, weightmat = dissWeights(kinshipdelta, type = "unifpower", power = 5))
par(mfrow = c(2,2))
plot(res, main = "Uniform power = 5 weights")
plot(res, plot.type = "Shepard")
plot(res, plot.type = "histogram")
## mds solution for kinship data with power weights emphasizing small dissimilarities
## while correcting for nonuniform dissimilarities
res <- mds(kinshipdelta, weightmat = dissWeights(kinshipdelta, type = "unifpower", power = -5))
par(mfrow = c(2,2))
plot(res, main = "Uniform power = -5 weights")
plot(res, plot.type = "Shepard")
plot(res, plot.type = "histogram")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.