
Stata Code for Weighted Peers Variables and Multidimensional Scaling
Project details
This project provides Stata codes for ‘weighted peers’ score ( customer satisfaction in this project). The weighted peers’ score can be any variable that a researcher might be interested in. We identify peer firms as firms with brands that are classified in at least one common ACSI-defined sector (or any other classification) of the focal firm.
The code performs the following steps:
- Multidimensional Scaling: The code utilizes the Classical Multidimensional Scaling method, as proposed by Borg and Groenen (2003) and Kruskal and Wish (1978). It creates a positioning map with two dimensions for each sector. This map represents the relative similarities between firms based on a range of characteristics.
- Firm Characteristics: To capture the similarities in firm characteristics such as market values and geographical diversification, the code incorporates two or more key firm characteristics.
- Euclidean Distance Calculation: Using the positioning maps generated in the previous step, the code calculates the Euclidean distances between all firms within each sector. The Euclidean distance reflects the dissimilarity or similarity between a pair of firms. A smaller Euclidean distance indicates greater similarity, while a greater distance signifies less similarity.
- Relationship Weight Computation: the code computes the weights for the relationships between the focal firm and its peers based on the Euclidean distances. The weight is determined as the difference between the total Euclidean distance of the focal firm and the Euclidean distance from its peer. This weight is then scaled by the total Euclidean distance.
- Weighted Variable Calculation: Once the weights for the relationships between focal firms and their peers are obtained, the code proceeds to calculate a weighted variable as follows: W_{i\acute{i}\;{st}}, represents the weight between the focal firm i and its peer firm \acute{i} in ACSI-defined sector s at time t , and CS_{\acute{i}\;{st}} is the customer satisfaction score of the peer firm \acute{i} in ACSI-defined sector s at time t .
Whether you are a researcher, data enthusiast, or a teacher, this coding exercise provides key learning opportunities for coding Euclidean Distance, using multidimensional scaling, normalizing variables, and creating weighted variables.
Stata Code
We have developed easy-to-use yet robust codes for the steps mentioned above. These codes only require a basic understanding of Stata. Additionally, our comments on each line of code will assist you in running the code and understanding the process more clearly. Typically, we provide all Stata files, raw data files, and Stata codes with comments. The purpose is to help researchers learn and independently apply these codes. We are also available to answer any questions that may arise during the application of these codes at a later stage.
Is the code accurate?
Our codes have undergone rigorous testing to ensure their accuracy and reliability. We have implemented comprehensive validation processes to verify the correctness of our codes. To test accuracy of this code, we used the data given in ‘Web Appendix D: Operationalization of the Weights’ of the paper by Lim, Tuli and Grewal (2020). Our code fully replicates the weighted score given in Table D1, last column.
Pricing
The code is available for 99 USD with some example data. If you need help with data processing or application of the code to your data, you may contact us for help. Payment can be made using any of the following methods.
PayPal email: stata.professor@gmail.com
Wise bank transfer (preferred due to low transaction costs).
For further details, please contact us at:
aullah.shah@imsciences.edu.pk
Stata.Professor@gmail.com
What is included in the package?
- Example dataset
- Stata Code for multi dimensional scaling
- Stata code for Euclidean Distance
- Mata code for finding the weights
- Mata code for weighting a given variable
- The code is accompanied by comments that guide you through the process. All you need to do is plug in your specific variable names.
How the process works?
About the developer

Having authored several Stata packages, Dr. Attaullah Shah has established a reputation for delivering high-quality, reliable solutions to the financial research community. With a passion for facilitating knowledge transfer, Dr. Shah has designed the code and accompanying resources to be user-friendly, even for those with basic understanding of Stata.
Dr. Shah is committed to providing exceptional support and ensuring that researchers can seamlessly apply these codes to their own projects. By leveraging Dr. Shah’s expertise and extensive experience, you can trust that this code is built on a solid foundation of academic rigor and practical applicability. View his academic contributions and software development here.
References
ACSI (2016), History of the American Customer Satisfaction Index, American Customer Satisfaction Index, (accessed 8 June 2016), [available at http://www.theacsi.org/about-acsi/history].
Borg, Ingwer and Patrick Groenen (2003), Modern multidimensional scaling: Theory and applications, Journal of Educational Measurement, 40(3), 277-80.
Kruskal, Joseph B. and Myron Wish (1978), Multidimensional Scaling. Thousand Oaks, California.
Lim, L. G., Tuli, K. R., & Grewal, R. (2020). Customer satisfaction and its impact on the future costs of selling, Journal of Marketing, 84(4), 23-44.