Announcement

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

  • Save margin results and CIs and reuse it later

    Is there a way to save the margins results and make the marginsplot in another Stata session?

    Code:
    sysuse auto, clear
    mlogit rep78 mpg displ i.foreign
    margins foreign, predict(outcome(1))
    /// save margins 
    clear all
    /// use saved margin results and CIs
    marginsplot
    Error: previous command was not margins

  • #2
    Yes, like this:
    Code:
    sysuse auto, clear
    mlogit rep78 mpg displ i.foreign
    margins foreign, predict(outcome(1)) post
    estimates save margins_output, replace
    
    clear all
    sysuse auto
    estimates use margins_output
    marginsplot
    Notes: The -post- option to -margins- causes the estimates from -mlogit- to be overwritten. So if you will still need the -mlogit- estimates themselves, you will have to also save or store them separately.

    -estimates save margins_output- will create a file in your current working directory names margins_output.ster. It will contain the margins results.

    You must not only use the margins output estimates file as shown, but you must also reload the data. If the data at the time the -margins- command was originally run is not simply a saved data set but some data set that has been modified, you will need to save the modified data set, too, and then -use- that before doing the -marginsplot-. The data from which -margins- were calculated must be in memory when -marginsplot- runs.

    Comment

    Working...
    X