topsis | R Documentation |
Implements the Technique for Order of Preference by Similarity to Ideal Solution
(TOPSIS) method to rank alternatives based on multiple criteria. The decision matrix
A
must contain positive indicators (larger values are better) or be preprocessed
using functions like rescale
, normalize
,
rescale_middle
, or rescale_interval
from the
mathmodels package. The function normalizes the matrix, applies weights, and
computes relative closeness to the ideal solution.
topsis(A, w)
A |
Numeric matrix, the decision matrix where rows are alternatives and columns are criteria. All criteria must be positive indicators (larger is better) or preprocessed to satisfy this condition. |
w |
Numeric vector, weights for each criterion. Must be non-negative and sum to a positive value. |
The TOPSIS method ranks alternatives by:
Normalizing the decision matrix using L2 norm (similar to normalize
).
Applying weights to form a weighted normalized matrix.
Identifying positive and negative ideal solutions (column max/min).
Computing Euclidean distances to ideal solutions.
Calculating relative closeness as S0 / (S0 + Sstar)
, where S0
is the distance to the negative ideal and Sstar
is the distance to the positive ideal.
Since A
must contain positive indicators, use rescale
for Min-Max
normalization, rescale_middle
for centered indicators, or
rescale_interval
for interval indicators before calling topsis()
.
NA values in A
may affect results and trigger a warning.
A named numeric vector of the same length as the number of rows in A
,
containing relative closeness scores in 0, 1. Higher values indicate better alternatives.
Names are taken from rownames(A)
or default to "Sample1", "Sample2", etc.
Hwang, C. L., & Yoon, K. (1981). Multiple Attribute Decision Making: Methods and Applications.
The mathmodels_penguins
dataset is derived from the palmerpenguins package.
A = data.frame(
X1 = c(2, 5, 3), # "+"
X2 = c(8, 1, 6) # "+"
)
w = c(0.6, 0.4)
topsis(A, w)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.