Announcement

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

  • How to Compute Mean Values across Groups with Long Format Data

    Hi, folks,
    The manager asked me to compute mean values across groups using a longitudinal dataset. For illustrative purposes, I used a real dataset available online, as shown below:
    use https://www.stata-press.com/data/r18/nlswork.dta, clear
    The solution provided by the manager was table collgrad, stat(mean hours).

    I believe this approach is neither correct nor appropriate because the hours variable is time-varying.
    What would be the correct Stata code for this task?

    Thank you!

  • #2
    It depends on why you want to do it. Your manager asked for the mean, and you give him the mean. So from that point of view this approach is exactly right. A possible problem could be that typically not everybody remains equally long in a panel dataset, so of you do it like that you will give higher weight to people who remained longer in the dataset. This only matters if you care about how representative it is for some population outside the data. If you just want to describe the data, then that is not a problem. So whether this is a problem, and what the best solution may be depends on what you want those means to mean.
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      The manager asked me to do t-test for the collgrad variable with the variable "hours". Then, it seems that there is no difference whether the data is wide format or long format?
      I really cannot understand it.

      Comment


      • #4
        I am afraid I do not understand your question. I don't know what you have done. I don't know the results you are referring to. I don't know why you (your manager) think you want a t-test. I think your use of nlsw88 example is more confusing than it helps. An analysis is all about the details, and the exact goal of the analysis.

        Can you ask the question again with a lot more details, using the real data, and the real goal? Don't try to simplify it.
        ​​​​​
        ---------------------------------
        Maarten L. Buis
        University of Konstanz
        Department of history and sociology
        box 40
        78457 Konstanz
        Germany
        http://www.maartenbuis.nl
        ---------------------------------

        Comment


        • #5
          Because the rule here is not allowed to upload real data, I have to use "nlsw88" example for illustrative purposes. He just wants to do an exploratory data analysis with t-test.
          That is why I said I can't understand his thoughts in long format data.

          Comment


          • #6
            Now I am even more confused: exploratory data analysis is something you cannot do with a test. Do you have an inhouse statistician you can talk to?
            ---------------------------------
            Maarten L. Buis
            University of Konstanz
            Department of history and sociology
            box 40
            78457 Konstanz
            Germany
            http://www.maartenbuis.nl
            ---------------------------------

            Comment


            • #7
              Manager is the god in the team although he knows very little about statistics and just has a master's degree in biology. He calls t-test as exploratory statistics rather than inferential statistics.

              Comment


              • #8
                If your manager has a god-syndrome then the best advise I can give you is to just give him what he asked for, not what he needs. So that makes the whole question of whether what he says is good statistics irrelevant.
                ---------------------------------
                Maarten L. Buis
                University of Konstanz
                Department of history and sociology
                box 40
                78457 Konstanz
                Germany
                http://www.maartenbuis.nl
                ---------------------------------

                Comment


                • #9
                  Thank you.

                  Comment


                  • #10
                    Can anybody here help me? Thank you!

                    Comment


                    • #11
                      While I endorse everything that Maarten Buis has said, just to get you out of the hole you have been thrown into by your manager:
                      Code:
                      ttest hours, by(collgrad)
                      Unsolicited career advice: don't work for a manager who is "god" any longer than you must. Start your job search today and leave as soon as possible.

                      Comment


                      • #12
                        Thank you, Professor!

                        Comment

                        Working...
                        X