help topsis

Title

topsis -- Calculation comprehensive scores based on the entropy method or the entropy-TOPSIS method

Syntax

topsis [, positive(varlist) negative(varlist) topsis]

Options

positive(varlist) Specifies the list of positive indicators.

negative(varlist) Specifies the list of negative indicators.

topsis Uses the TOPSIS method to calculate the comprehensive score.

Notes

o 1. Combined Input Support: The topsis command supports the combined input of positive and negative indicators. If no indicators are specified, the program will return an error message.

o 2. Correct Variable Naming: Users should ensure the correctness of variable names when inputting positive and negative indicators, and avoid duplication to prevent program errors or inaccurate calculations.

o 3. Numeric Variables: All input variables should be numeric. Non-numeric variables may lead to program errors or abnormal calculations.

o 4. TOPSIS Option: When using the topsis option, the program will further calculate the comprehensive score based on the entropy-TOPSIS method.

Description

topsis is used to calculate comprehensive scores based on the entropy method or the TOPSIS method.

This command allows users to specify both positive and negative indicators, and automatically performs data normalization, calculates information entropy, redundancy, and weights, and finally calculates a comprehensive score.

Additionally, the program can use the TOPSIS method to calculate the score (optional, depending on user preference).

If the topsis option is not used, the program will output the information entropy, redundancy, and weights of each indicator, and by default, display the comprehensive scores for the first 10 samples.

Users can also view stored return values, the complete list of comprehensive scores, and descriptive statistical analysis results by clicking the links in the Stata results window.

If the topsis option is used, the program will display the comprehensive scores based on the entropy-TOPSIS method and provide descriptive statistical analysis.

Friendly Reminder

o (1) Normalization:

The program will automatically normalize the input data. If the maximum and minimum values of a variable are the same, the normalized result will be set to 0.5 to avoid division by zero. Additionally, normalized values of 0 are replaced with 0.0001 to prevent errors such as ln(0) during calculations.

o (2) Temporary Variables:

The command will generate many temporary variables upon execution, so when running the command a second time, you need to manually delete the temporary variables.

You can manually select and delete the temporary variables in the variable window, or use preserve before executing the command and restore afterward to restore the original data.

o (3) Consistency of Units:

The units of the indicators should be consistent or properly normalized to ensure the comparability and scientific validity of the results. Indicators with different units may result in unreasonable comprehensive scores.

o (4) TOPSIS Data Quality:

When using the TOPSIS method, the quality and appropriateness of both positive and negative indicators should be ensured to guarantee valid results, especially avoiding extreme values that could adversely affect the calculations.

o (5) Data Cleaning Recommendations:

It is recommended to handle missing values and outliers in the input data before executing topsis to ensure the accuracy of the calculations and results.

o (6) Data Backup:

It is advisable to back up the current dataset (e.g., using preserve) before executing the topsis command to prevent data loss in case of improper command execution.

Examples

Note: When running the new command again, you must manually delete the new temporary variables or use the preserve and restore commands in advance. Otherwise, the program topsis will report an error

Example 1：Basic Usage: citytemp4 Dataset Case

Setup

sysuse citytemp4.dta, clear

Or enter (cnuse is an external command that needs to be downloaded, and can be installed using ssc install cnuse, replace)

cnuse citytemp4.dta, clear

* Drop missing values

drop if missing(heatdd)

* Perform entropy method operations assuming heatdd and tempjuly are positive indicators, cooldd and tempjan are negative indicators

topsis, positive(heatdd tempjuly) negative(cooldd tempjan)

Example 2: Further usage：TOPSIS Dataset Case

* Setup

cnuse topsis1.dta, clear

* Use topsis command for entropy analysis

preserve

topsis, positive(x3 x4 x5 x6) negative(x1 x2)

* View comprehensive score results

list Score in 1/10

sum Score, detail

* Stata stored return values view

return list

mat list r(E)

mat list r(D)

mat list r(W)

restore

* Perform entropy-TOPSIS method analysis

* Note: You must manually delete the new temporary variables or use the preserve and restore commands in advance.

topsis, positive(x3 x4 x5 x6) negative(x1 x2) topsis

Stored Results

topsis will store the following items in r():

Matrices

r(E): Stores information entropy.

r(D): Stores redundancy coefficients.

r(W): Stores weights.

These three results are hyperlinked in the command execution section. You can also enter return list to see the stored Stata return values and use mat list to view the stored results.

For example, enter mat list r(E) to view information entropy, mat list r(D) to view redundancy coefficients, and mat list r(W) to view weights.

Author

Wang Qiang, Xi'an Jiaotong University, China.

Questions and Suggestions

If you have any questions or suggestions, please send an email to: 740130359@qq.com.

Also see

cnuse (if installed), enwei (if installed), entropy (if installed)