Announcement

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

  • creating do files for standard statistical analyses

    Dear all,

    I am fairly new to Stata, so my apologies if this appears to be a dumb question. One of the reasons I was drawn to Stata is the possibility to create do files. I had envisioned creating a set of do files for standard operations such as validating a scale, checking regression assumptions, or performing factor analysis etc. I have searched a lot for topics and discussions related to this, and aside from someone mentioning to do this as a summer project, have come up rather empty. Initially, I would even have assumed that this might be discussed in some of the books on Stata, but again, I have not been able to find it. Now, I am wondering if my approach is maybe too naive or if I am missing something obvious or have misinterpreted the use of do files? I would very much appreciate any input and advice from senior Stata users.

    Thanks for your help,
    Christoph

  • #2
    Exact advise depends on the exact details of what you want to do. But standardization to different degrees using .(a)do files is definately possible:
    • You can create a .do file and run it repeatedly.
    • You can make that .do file more general by making it accept arguments. If you have a .do file called foo.do then you can type in Stata do foo bla blup and while Stata does the file foo.do the local macros 1 and 2 will be defined to contain "bla" and "blup" respectively.
    • You can make it more general by making it into a full program.
    How far you want to go depends on how much time you want/can invest up front and how much time you can expect to save after it is done.
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      I would suggest you don't try and immediately create these do-files. Since you're new to Stata, your first task should be to learn the basics, such as the type of postestimation commands that are available and the use of macros etc. Since typically a statistician's job involves many different kinds of analyses, it's hard to imagine having a do-file that is suitable in all situations. For example, residual checks are different depending on whether you're running -regress- or -logit- or -stcox-, etc. In terms of exploratory analyses, there are also potentially many things you can do to a variable, e.g. checking for patterns of missing values, plotting a histogram, counting the number of distinct categories, etc., and a do-file that tries to do everything. You'll also be examining whether transformation of variables make sense, and typically, you consider transformation only on selected variables, you don't want to apply the same procedure to all variables.

      Eventually, however, you may find that there are certain procedures that you often repeat, and that's when you may want to write a program to automate it a little. But by then you should already have amassed a number of do-files with the same sequence of commands. It's then a matter of converting these commands to a do-file or an ado-file format. To do this, I would go straight to the manual or the help files for -program-. Learn also how to use the -syntax- command.

      HTH,

      Tim

      Comment


      • #4
        A book on how .do files are (should be) used in actual research is:
        J. Scott Long (2009) "The Workflow of Data Analysis Using Stata". College Station, TX: Stata Press.
        http://www.stata-press.com/books/wor...nalysis-stata/
        A book that focusses more on how to program in Stata is:
        Christopher F. Baum (2009) "An Introduction to Stata Programming". College Station, TX: Stata Press.
        http://www.stata-press.com/books/int...a-programming/

        ---------------------------------
        Maarten L. Buis
        University of Konstanz
        Department of history and sociology
        box 40
        78457 Konstanz
        Germany
        http://www.maartenbuis.nl
        ---------------------------------

        Comment


        • #5
          Thanks everyone for your thoughtful comments. I realize that I may have been overly optimistic even though I did not envision one do-file to perform all tasks. I do like the approach of having do files emerge from my work though as I can definitely see that I will perform certain analyses more often than others. I have read parts of the book by Long and will be sure to check out the book by Baum.

          Comment

          Working...
          X