entropy_weight: Entropy Weight Method for Indicator Weighting and Sample...

View source: R/entropy_weight.R

entropy_weightR Documentation

Entropy Weight Method for Indicator Weighting and Sample Scoring

Description

Computes the weights of indicators and scores of samples based on the entropy method. This method objectively determines the importance of each indicator according to the amount of information it contains.

Usage

entropy_weight(X, index = NULL)

Arguments

X

A numeric data frame or matrix where rows represent samples (observations) and columns represent indicators (variables).

index

A character vector indicating the direction of each indicator. Use "+" for positive indicators (higher is better) and "-" for negative indicators (lower is better). If not provided, all indicators are assumed to be positive.

Value

A list containing:

w

Numeric vector of weights for each indicator.

s

Numeric vector of scores for each sample (row), scaled by 100.

Examples

# Example: Using entropy weight method on a simple dataset
X = data.frame(
  x1 = c(3, 5, 2, 7),
  x2 = c(10, 20, 15, 25)
)
index = c("+", "-")
entropy_weight(X, index)

zhjx19/mathmodels documentation built on June 2, 2025, 12:18 a.m.