Announcement

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

  • Averages for Panel Data

    I have gathered cross country time-series data and culculated averages for all variables in Excel. For all the variables there are arithmetic averages and for GNIpcGrowth, DNPpcGrowth - geometric averages. For my regression I wanted to compute averages in Stata but I couldn't... Stata notifies about mismatch (r109) mistake. I tried different ways and failed. I thought that probably something wrong with the presentation of my data...
    Would you please look at the data and tell me whether everything is ok with it? It is only beginning of the work I will Need the data for cross-section regressions, POLSand FE. In my excell spreadscheet there are averages in the the lowest row for each country (which I computed in Excel), should I remove them or place in the coloumn?

    I have tried to use the commands
    gen mean
    gen cummean
    collapse
    egen


    And the second question. Is it possible to compute geometric averages for growth in Stata? I have negative values there, so I will probably need an intermediate calculation as I performed in Excel (for GNIpcChange and GNPpcChange)
    Attached Files

  • #2
    Lana (please note the strong prefeence for full real names on this forum. Thanks).
    Starting out from the basics, r(109) warns you about that a type mismatch between string and numeric format has occurred:
    Code:
    [P]     error . . . . . . . . . . . . . . . . . . . . . . . .  Return code 109
            type mismatch;
            In an expression, you attempted to combine a string and numeric
            subexpression in a logically impossible way.  For instance, you
            attempted to subtract a string from a number or you attempted
            to take the substring of a number.
    
    (end of search)
    With -describe- Stata will promtly inform you about the format of your variables so that you can change it accordingly.

    As this is not your first post, you should be already aware of that most listers do not use or are reluctant to open spreadsheet, due to the risk of inadvertently download nasty active contents.
    Hence, attachments are welcomed in Stata format only.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Welcome to Statalist, Lana!

      We can better help you if we know what commands you have tried and what Stata told you to indicate that there was a problem. Please review the Statalist FAQ linked to from the top of the page, especially sections 9-12 on how to best pose your question. It's particularly helpful to copy commands and output from your Stata log window and paste them into your Statalist post using CODE delimiters, as described in section 12 of the FAQ. Please also note the preference for the use of real names on this forum, and take the time to click "Contact Us" below and request your registration name be changed to include your personal and family names.

      With that said, when I import your Excel data into Stata, I see that because of the cells with ".." in them, all the variables are being imported as strings, not as numbers. Stata does not recognize ".." as having any special meaning, so it brings it in as a string. I think that is the source of your "mismatch" problem, although without seeing your commands and Stata's responses I cannot be certain.

      In Excel, I replaced all .. with nothing, so those cells became empty, and then saved the spreadsheet. When I imported the edited data into Stata, all the variables came were imported as numbers, other than country and year.

      Comment


      • #4
        Many many thanks, It helped.

        Without dots I am able to work with it. (and I have requested about changing my nickname)

        Comment


        • #5
          I still have a question about geometric averages. For the dataset, attached to this post, (to perform cross-sectional analysis) I need arithmetic averages for 6 variables, while for the 7th one I need geometric average. This particular variable is GNIpcGrowth and its observations are both positive and negative values.

          1) Having got arithmetic averages vor 6 variables with the command collapse GNS_currentLCU GNI_currentLCU GNIpc_2005USD ADR_Old ADR_Young GINI, by (Country) I have lost the variable GNIpcGrowth from the dataset, does it mean that I cannot use collapse command? What is better to use then?

          2) How can I compute geometric average in Stata or, if I cannot, how can I include already compjuted geometric averages from Excel to the data to use it in a regression?
          Attached Files

          Comment


          • #6
            Hello Lana,

            You may want to type:

            Code:
            . help ameans
            Best,

            Marcos
            Best regards,

            Marcos

            Comment


            • #7
              Thanks. If I compjute them with the Stata tools

              Statistics > Summaries, tables, and tests > Summary and descriptive statistics > Arith./geometric/harmonic means

              I get three types of mean for each variable. I am sorry for a silly question but how can I use these means for a regression?

              Shall I create new variables using these mean values?


              Last edited by Lana Rais; 27 Aug 2015, 05:07.

              Comment


              • #8
                I have done everything.
                I have used intermediate variable for generating geometric average (as my values vor growth are not always positive)


                gen intermediatevariable = variable+100
                egen averageintermediatevariable = gmean(intermediatevariable), by (Country)
                gen averagevariable = averageintermediatevariable-100

                Then arithmetic variables for all other variables

                egen average… = mean(my variable), by (Country)
                and merged them into one variable for each country with collapse command
                collapse …. …. …. …. …. … , by (Country)
                Thank you.


                Comment

                Working...
                X