Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Calculating the Mean Distance of 2 Variables

    I would greatly appreciate it if somebody could help me with the following question. I am currently writing a paper in which I use survey data and I am having problems with generating the following variable. As part of the methodology, I am taking the difference between the means of perceived party positions in addition to the mean distance between parties' perceived positions. Before I go any further, the variables I am using are individuals' perceived party ideological positioning in which they give the party in question a score between 1-10. While the difference between the means of perceived party positions can be obtaining by taking the difference of the perceived party means, I honestly am not sure how to calculate the mean distance between parties' perceived positions. Can anyone help me with this issue? I can provide additional code if need be. Thanks in advance.

  • #2
    No need to provide additional code. But you really do need to show example data, as the solution depends on the way your data is organized. The helpful way to do this is with the -dataex- command. If you are running version 18, 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    Comment


    • #3
      Thank you for your response Clyde and my apologies for not providing further information. Are you referring to something like the example below? Do let me know if this is what you're looking for.


      . dataex psoe_ideology pp_ideology if year == 2020

      ----------------------- copy starting from the next line -----------------------
      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input byte(psoe_ideology pp_ideology)
      6  8
      5  7
      5  8
      3  7
      5  7
      7  8
      1  7
      3  7
      3 10
      3  8
      3  7
      5  9
      3  8
      4  9
      3  9
      2  9
      1  6
      4  8
      3  8
      3  8
      4 10
      3  9
      6  8
      5  5
      4  7
      3  6
      5  7
      4  8
      5  8
      4  8
      4  7
      6  8
      1 10
      .  .
      6  8
      3  8
      3  6
      8  9
      6  9
      . 10
      4  9
      3  6
      .  .
      6 10
      4  6
      1 10
      3  5
      3  7
      1 10
      5  8
      4  5
      1  7
      4  6
      2  6
      7  7
      8 10
      3  8
      6  7
      5 10
      1 10
      4  6
      3  7
      6  8
      .  5
      .  .
      7  8
      5  8
      4  8
      6  3
      5  7
      1  7
      4  9
      . 10
      4  6
      .  .
      4  5
      4  8
      2 10
      5  7
      5 10
      3  7
      9 10
      3  7
      1 10
      9 10
      8 10
      4  7
      .  6
      5 10
      4  7
      4  7
      5  6
      4  7
      6  9
      5  7
      5  7
      4  7
      .  .
      3  7
      5  9
      end
      ------------------ copy up to and including the previous line ------------------

      Listed 100 out of 45644 observations
      Use the count() option to list more

      .
      end of do-file

      Comment


      • #4
        Yes, I was looking for -dataex- output like that. But I think what you have provided is either incomplete, or insufficiently explained, or both. I don't see how to connect your example data to your problem. First, I don't know what the variables psoe_ideology and pp_ideology. I suppose one of them is perceived and the other is the party's official position? But even if so, which is which? Also, I don't see anything that tells us which party is being perceived in each observation.

        Comment


        • #5
          Hello again Clyde, I think I managed to figure it out. It was mostly a matter of taking the difference between the aforementioned variables and then take the mean of said variable. Either way, thank you for your willingness to help. Next time I will be more thorough with my questions.

          Comment

          Working...
          X