Announcement

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

  • How to save temporary files in order to reuse them later?

    Dear Statalist,

    I am running several and time-consuming models (gsem). To do so, I used some methods to enhance and make easier the estimations. For instance, I run a model, save the coefficients matrix then use it as starting values in a following estimation.

    But I must reiterate each estimation once I closed Stata. I would like to know if I can perform a complete save including the temporary files (e.g., coefficients matrices).

    Thanks in advance !

    Kind regards,

    Gabin.

  • #2
    Stata does not have the ability to save matrices. However, instead of putting your estimation results into matrices, you can use the -estimates save- command. This will create a file in your working directory, with filename extension .ster, that contains everything that is contained in -e()-. So that includes the coefficients and much more. When you want to reuse these estimates later, the -estimates use- command will bring them back into memory. Do read -help estimates- to learn more about these and related commands for working with regression results.

    Note that these .ster files are not temporary files in the Stata sense of -tempfile-s. They are real files, located in your working directory, and they persist after you close Stata. They will only go away when you specifically delete them.

    Comment


    • #3
      Is it just the coefficient estimates you want to save? You can do this in a variety of ways, but Clyde's solution is superior than what I had originally posted. Go with that!.
      Last edited by Erik Ruzek; 09 Sep 2024, 14:05. Reason: Removed savmat suggestion

      Comment


      • #4
        Originally posted by Clyde Schechter View Post
        Stata does not have the ability to save matrices. However, instead of putting your estimation results into matrices, you can use the -estimates save- command. This will create a file in your working directory, with filename extension .ster, that contains everything that is contained in -e()-. So that includes the coefficients and much more. When you want to reuse these estimates later, the -estimates use- command will bring them back into memory. Do read -help estimates- to learn more about these and related commands for working with regression results.

        Note that these .ster files are not temporary files in the Stata sense of -tempfile-s. They are real files, located in your working directory, and they persist after you close Stata. They will only go away when you specifically delete them.
        Perfect, thank you both so much for your help!

        Comment

        Working...
        X