Announcement

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

  • Is there any chance that Stata 14 and Stata 13 creates different result from same command?

    It just happened with me. e.g. In Stata 14 the command I used produce 90 sample. I sent it to someone for review. He has Stata 13. So I saved as old format and sent the .dta and .do file to him. When he ran same .do file in Stata 13, it produced 91 sample. How is this even possible? or is it possible?

  • #2
    Very generally, this should not happen due to the estimation command's interpretation of the data. All cases with missing data are deleted listwise in most regression commands. You should note that after a regression, all cases used there are marked using e(sample). If your friend runs this code after estimation:

    Code:
    gen sample_13 = e(sample)
    All observations that his copy of Stata used would be flagged. If he sends you that data file back, you can then open it. Also, you can make this happen yourself, by asking Stata to use an older version:

    Code:
    version 13.1
    regress y x1 x2 x3
    gen sample_13 = e(sample)
    version 14.1
    regress y x1 x2 x3
    gen sample_14 = e(sample)
    tab sample_13 sample_14
    list if sample_13 == 1 & sample_14 == 0
    Obviously, your friend can't do the reverse.

    I can't imagine how this happened. Maybe if you had exported your .dta file to .csv or to an older Stata version, something changed with the coding or the import of one variable (maybe to a 0 from a missing?).
    Be aware that it can be very hard to answer a question without sample data. You can use the dataex command for this. Type help dataex at the command line.

    When presenting code or results, please use the code delimiters format them. Use the # button on the formatting toolbar, between the " (double quote) and <> buttons.

    Comment


    • #3
      Welcome to Statalist.

      Our ability to imagine how this might happen would be enhanced if you were to more fully tell us what you did.

      Please review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post. Note especially sections 9-12 on how to best pose your question.

      Section 12.1 is particularly pertinent

      12.1 What to say about your commands and your problem

      Say exactly what you typed and exactly what Stata typed (or did) in response. N.B. exactly!
      At a minimum it would be useful to see the do-file you ran. Please do not post it as an attachment; instead follow the guidance in the FAQ to copy the contents of the do-file and paste it into a Statalist post using CODE delimiters.

      The more you help others understand your problem, the more likely others are to be able to help you solve your problem.

      Comment


      • #4
        I can offer a possible explanation. I saw a similar problem when my students used different versions of Stata for a class exercise that involved taking random samples. Even though they used the same random number seed, different versions generated different outputs. I assume (without definite knowledge) that Stata changed its random number generator between versions. From memory, if this is what happened to you, you could include the command version 13 at the top of your do file and it would generate the same results as your colleague will get running on Stata 13. (Caveat: my experience was a while ago, so I could be misremembering). I hope that's a helpful lead. Good luck.
        _______________________________________

        Glenn Hoetker
        Professor in Business Strategy

        Melbourne Business School, University of Melbourne
        200 Leicester Street, Carlton, Victoria 3053, Australia
        Email: [email protected]

        I acknowledge the Traditional Owners of the land on which I work, the Wurundjeri people of the Kulin Nations, and pay my respects to their Elders, past and present.

        Comment


        • #5
          Indeed, the random number generator was enhanced in Stata 14. The set rng command allows Stata 14 users to choose the previous version of the random number generator. See the output of help set rng for further details.

          Comment


          • #6
            I'm sure all the changes Stata has made to its random number generator are good ones. But, for all us lazy people who are content with set seed 1234, it can get a little confusing when we try to replicate results from earlier versions of Stata.
            -------------------------------------------
            Richard Williams, Notre Dame Dept of Sociology
            StataNow Version: 19.5 MP (2 processor)

            EMAIL: [email protected]
            WWW: https://www3.nd.edu/~rwilliam

            Comment


            • #7
              Thank you very much for your replies.

              Comment


              • #8
                I used the following do file (e.g.)-

                Code:
                use "mergerd with Upazilla", clear
                keep if Upazilla==1
                sort union village 
                destring pop, replace
                
                gen cumulative=sum(pop[_n]) 
                gen cumul_last=(cumulative[_n-1])
                replace cumul_last=0 in 1
                
                set seed 9999
                gen rand=uniform()
                gen rand1=rand in 1
                egen rand2=min(rand1)
                
                gen clus1=rand2*7122 /*interval: based on total population of 220789 divided by 31 as some are very large population*/  
                local i=2
                while `i'<=31 {
                gen clus`i'=clus1+7122*(`i'-1) /* interval */
                local i=`i'+1
                }
                
                gen sample=0
                local i=1
                while `i'<=31 {
                replace sample=1 if clus`i'>=cumul_last&clus`i'<=cumulative
                local i=`i'+1
                }
                
                drop clus*
                keep if sample==1
                save "Muladi", replace

                Comment


                • #9
                  The output of help set rng suggests that preceding your set seed command with set rng kiss32 will allow you to duplicate your colleague's Stata 13 results on your installation of Stata 14. There is no way for your colleague to duplicate your results using Stata 13.

                  Code:
                  . clear
                  
                  . set obs 5
                  number of observations (_N) was 0, now 5
                  
                  . version
                  version 15.1
                  
                  . 
                  . // default random number generator
                  . 
                  . set seed  9999
                  
                  . generate rand = uniform()
                  
                  . list rand, clean
                  
                             rand  
                    1.   .4127389  
                    2.   .4933316  
                    3.   .6376464  
                    4.    .384367  
                    5.   .8797952  
                  
                  . 
                  . // version 13 random number generator
                  . 
                  . set rng kiss32
                  
                  . set seed  9999
                  
                  . generate rand13 = uniform()
                  
                  . list rand13, clean
                  
                           rand13  
                    1.   .5706419  
                    2.   .7122409  
                    3.   .9121964  
                    4.   .3174115  
                    5.   .8693877

                  Comment

                  Working...
                  X