Announcement

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

  • combined variance

    Hi All,

    I need to calculate combined variance of several samples. I only have mean, standard deviation, and sample size of the samples. Is there anyway to do that in Stata with this information?

    Thanks!

  • #2
    Monica:
    can you please provide the list with an example of what you're arfter? Thanks.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Sure! Here is a small part of my data:

      each row shows mean, sample size(n), and standard error of one sample for two different variables (ab_A3IM and Ab_A4IM)

      I need to find the overall mean and standard deviation for the population that includes these samples. (N=152)

      I found a formula (the 5 steps at the end of the page) for it but I don't know how to apply it on my data:



      Code:
      clear
      input int id     int   ab_meanA3IM     int   ab_nA3IM      int  ab_seA3IM   int     ab_meanA4IM        int ab_nA4IM      int  ab_seA4IM
      id        ab_meanA3IM        ab_nA3IM        ab_seA3IM        ab_meanA4IM        ab_nA4IM        ab_seA4IM
      1        4.38        8        0.18        4.12        8        0.13
      2        4        6        0        4        6        0
      3        4        8        0.19        3.62        8        0.18
      5        4.38        9        0.18        3.88        9        0.13
      7        4        12        0.19        3.88        12        0.13
      8        4.12        8        0.13        3.75        8        0.16
      9        4.5        10        0.19        3.75        10        0.16
      10        4        9        0.19        3.5        9        0.19
      11        4.12        8        0.13        3.88        8        0.13
      13        4        7        0        4.12        7        0.13
      14        4.12        8        0.13        4        8        0
      15        3.88        9        0.13        4        9        0
      16        4.12        10        0.13        3.88        10        0.13
      17        4.12        8        0.13        4        8        0
      19        3.88        8        0.13        3.88        8        0.13
      20        3.88        8        0.13        3.75        8        0.16
      22        4        8        0        4        8        0
      23        3.88        8        0.3        3.25        8        0.16
      end
      I really appreciate your help

      Comment


      • #4
        I'm not sure if I got your point quite right, but, to start, I gather you could play with - egen - with rowmean and rowsd. For example:

        Code:
        . egen newvar1 = rowmean(var1 var2 var3)
        . egen newvar2 = rowsd(var1 var2 var3)

        Then, with - generate - you could convert the sd into variance, just by squaring the sd.


        Hopefully that helps.
        Best regards,

        Marcos

        Comment


        • #5
          Dear Marcos, I have to find out the combined variance of three variables. However, i am unable to understand above data set and explanation. Using following data set:
          sysuse auto.dta

          How to find out combined variance between price, mpg, and displacement using Stata?

          Comment

          Working...
          X