Announcement

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

  • #16
    Originally posted by Carlo Lazzaro View Post
    Stef:
    simply replace your values in A (or import your 584-number variable and name it -A- in Stata.dta) and run the rest of the code.
    What I actually did, the result is the same. Is something wrong?

    Click image for larger version

Name:	numbers.PNG
Views:	1
Size:	18.3 KB
ID:	1379992
    Click image for larger version

Name:	Unbenannt2.PNG
Views:	1
Size:	36.5 KB
ID:	1379993
    Click image for larger version

Name:	Unbenannt3.PNG
Views:	1
Size:	66.6 KB
ID:	1379994

    Comment


    • #17
      Stef:
      you repeated the old code and, being -seed- set01 you get te very same results.
      Now you have your origina data for -A-, instead.
      Hence the previous code should be tweaked a bit, just like in the following toy-example.

      Code:
      import excel "C:\Users\user\Desktop\StefSample.xlsx", sheet("Foglio1") clear
      
      set seed 1
      
       g double mean=.
      (584 missing values generated)
      
      
      quietly forvalues i = 1/100 {
      preserve
      sample 30 if A !=., count
      summ A
      scalar Am = r(mean)
      restore
      replace mean = Am in `i'
       }
      
      sum A mean
      Kind regards,
      Carlo
      (Stata 18.0 SE)

      Comment


      • #18
        Originally posted by Carlo Lazzaro View Post
        Stef:
        you repeated the old code and, being -seed- set01 you get te very same results.
        Now you have your origina data for -A-, instead.
        Hence the previous code should be tweaked a bit, just like in the following toy-example.

        Code:
        import excel "C:\Users\user\Desktop\StefSample.xlsx", sheet("Foglio1") clear
        
        set seed 1
        
        g double mean=.
        (584 missing values generated)
        
        
        quietly forvalues i = 1/100 {
        preserve
        sample 30 if A !=., count
        summ A
        scalar Am = r(mean)
        restore
        replace mean = Am in `i'
        }
        
        sum A mean
        YES!!! Carlo you are a great master. I wish you all the best!

        Best regards,
        Stefan.

        Comment


        • #19
          Originally posted by Carlo Lazzaro View Post
          Stef:
          you repeated the old code and, being -seed- set01 you get te very same results.
          Now you have your origina data for -A-, instead.
          Hence the previous code should be tweaked a bit, just like in the following toy-example.

          Code:
          import excel "C:\Users\user\Desktop\StefSample.xlsx", sheet("Foglio1") clear
          
          set seed 1
          
          g double mean=.
          (584 missing values generated)
          
          
          quietly forvalues i = 1/100 {
          preserve
          sample 30 if A !=., count
          summ A
          scalar Am = r(mean)
          restore
          replace mean = Am in `i'
          }
          
          sum A mean
          Carlo, I have one more question.
          Is there random sample by picking up 30 numbers?
          What I see, that computer gives me all the time the same result. but, in reality it should fluctuate a little bit, because by random choice numbers should vary.
          Do you know what I mean?
          And if I try for instance the next code, all the time the programm gives me the same result.

          set seed 1
          g double mean=.
          quietly forvalues i = 1/1 {
          preserve sample 1 if A !=., count
          summ A
          scalar Am = r(mean)
          restore replace mean = Am in `i'
          }
          su A mean
          Last edited by Stef Appel; 24 Mar 2017, 08:36.

          Comment


          • #20
            Stef:
            if you remove -set seed 1- from your code, you'll get different results every time you run it.
            Kind regards,
            Carlo
            (Stata 18.0 SE)

            Comment


            • #21
              Originally posted by Carlo Lazzaro View Post
              Stef:
              if you remove -set seed 1- from your code, you'll get different results every time you run it.
              Thanks a lot, Carlo.

              Best regards,
              Stef.

              Comment


              • #22
                Originally posted by Carlo Lazzaro View Post
                Stef:
                if you remove -set seed 1- from your code, you'll get different results every time you run it.
                Carlo:
                when the programme picks up the numbers, 30 from 584. Is there 30 different numbers? or could it be that the programme picks up twice or three times the same number?
                For instance, I need to do it also for 500 numbers. All 500 numbers will be different, without duplications?

                Best regards,
                Stef.

                Comment


                • #23
                  Stef:
                  yes, they're different with -sample-;
                  no, n_plications may occurr with -bsample- (but this is not the command you selected).
                  Kind regards,
                  Carlo
                  (Stata 18.0 SE)

                  Comment


                  • #24
                    Originally posted by Carlo Lazzaro View Post
                    Stef:
                    yes, they're different with -sample-;
                    no, n_plications may occurr with -bsample- (but this is not the command you selected).
                    Carlo:
                    Is it possible with Stata to compute correlation?
                    I have 584 numbers and need to get correlations between all stocks, and then to compute the mean of them? Is it possible?



                    Best regards.
                    Stef.

                    Comment


                    • #25
                      Stef:
                      yes.
                      See, among others, -help correlate-.
                      Kind regards,
                      Carlo
                      (Stata 18.0 SE)

                      Comment


                      • #26
                        Just as a side note, if you need to perform this operation 100 times, you probably need to make sure every one may reproduce it , hence you should think about setting seeds.
                        Best regards,

                        Marcos

                        Comment

                        Working...
                        X