Hello everybody,
I use Stata 13.1 and I am working with a dataset that contains 25 numerical variables (var1-var25) and around 400 observations. I want to create a 25x25 matrix A. Each cell of A reports the euclidean distance between the corresponding pair of variables. For example, a11=sqrt[sumi(var1i -var1i)^2] and the subscript i refers to the observation i (from 1 to 400), a21=sqrt[sumi(var2i -var1i)^2] etc. Obviously, A will be a square and symmetric matrix, in which the elements of the diagonal will be zero. This is some sort of dissimilarity matrix, I have tried the command matrix dissim to achieve that but it creates a 400x400 matrix in which each cell reports the distance of each observation instead of the total distance for each variable. Is there any simple way to create this matrix?
Thanks,
David Puig
Related Posts with Creating a matrix with Euclidean distances between variables.
7-point ordinal dependent variable: Is it okay to transform and model with fracreg logit?Greetings, I'm running Stata 15.1 on a Mac OS and working with cross-sectional survey data. My depe…
Mean size of householdi am just a beginner in stata , i want to know a simple command for calculating the mean size of hou…
XTIVREG, FE: needs to be FE in stage 1 and 2?Hi all, I'm running a fixed effects regression using an IV variable, but I'm wondering, do I need t…
Trimming certain part of variable labelsI am trying to remove the "R10 D Covid-19 Sp" part from all the variables. I used the Code: cleanch…
Generalized difference in differences with panel dataHi, I am relatively new to Stata so any help would be greatly appreciated! Q: How do I do a general…
Subscribe to:
Post Comments (Atom)
0 Response to Creating a matrix with Euclidean distances between variables.
Post a Comment