|
| 1 | +{smcl} |
| 2 | +{* *! version 1.0.0}{...} |
| 3 | +{vieweralsosee "mestreg" "help mestreg"}{...} |
| 4 | +{vieweralsosee "stmixed" "help stmixed"}{...} |
| 5 | +{viewerjumpto "Syntax" "modexpt##syntax"}{...} |
| 6 | +{viewerjumpto "Description" "modexpt##description"}{...} |
| 7 | +{viewerjumpto "Options" "modexpt##options"}{...} |
| 8 | +{viewerjumpto "Examples" "modexpt##examples"}{...} |
| 9 | +{viewerjumpto "Author" "modexpt##author"}{...} |
| 10 | + |
| 11 | +{synopt :{cmd: modexpt} {hline 2} Export estimation results of {cmd: mestreg} and {cmd: stmixed} models to an Excel file} |
| 12 | + |
| 13 | +{marker syntax}{...} |
| 14 | +{title: Syntax} |
| 15 | + |
| 16 | +{phang} |
| 17 | +Export results of {cmd: mestreg} and {cmd: stmixed} models to an Excel file: |
| 18 | +{p_end} |
| 19 | + |
| 20 | +{phang2} |
| 21 | +{cmd: modexpt}, {opt filename(string)} [{opt replace}] |
| 22 | +{p_end} |
| 23 | + |
| 24 | +{synoptset}{...} |
| 25 | +{marker options_table}{...} |
| 26 | +{synopthdr: Option} |
| 27 | +{synoptline} |
| 28 | +{synopt: {cmdab: filen:ame(}{it: string})}Name of the file to export results to{p_end} |
| 29 | +{synopt: {cmdab: replace}}Overwrite Excel file{p_end} |
| 30 | +{synoptline} |
| 31 | + |
| 32 | +{pstd}See {helpb putexcel}, which is used under-the-hood, for more details. |
| 33 | + |
| 34 | +{marker description}{...} |
| 35 | +{title: Description} |
| 36 | + |
| 37 | +{pstd} |
| 38 | +{cmd: modexpt} can be used to export an Excel file with estimated coefficients and their variance-covariance matrix of {cmd: mestreg} and {cmd: stmixed} models. |
| 39 | +Specifically, {cmd: e(b)} and {cmd: e(V)} that are stored in {cmd: ereturn} by {cmd: mestreg} and {cmd: stmixed} are exported in separate tabs of the Excel file specified with {opt filename(string)}. |
| 40 | +Note that some ancillary information, such as the model distribution/family, are exported as well. |
| 41 | + |
| 42 | +{marker options}{...} |
| 43 | +{title: Options} |
| 44 | + |
| 45 | +{phang} |
| 46 | +{opt filename(string)} specifies the name of the Excel file to be used to export the estimation results after {cmd: mestreg} or {cmd: stmixed}. |
| 47 | +The name must be a string, potentially including the path to a location other than the working directory. |
| 48 | +{p_end} |
| 49 | + |
| 50 | +{phang} |
| 51 | +{opt replace} overwrites the specified Excel file, if needed. |
| 52 | + |
| 53 | +{marker examples}{...} |
| 54 | +{title: Examples} |
| 55 | + |
| 56 | +{pstd} |
| 57 | +We start by replicating one of the examples from the {helpb mestreg} help file: |
| 58 | + |
| 59 | +{phang}{stata webuse catheter: . webuse catheter}{p_end} |
| 60 | +{phang}{stata "mestreg age female || patient:, distribution(weibull)": . mestreg age female || patient:, distribution(weibull)}{p_end} |
| 61 | + |
| 62 | +{pstd} |
| 63 | +Note that everything would work the same if we had fit a {cmd: stmixed} model instead. |
| 64 | +Then, we export the estimation results in a file named {cmd: test.xlsx}, located in the current working directory: |
| 65 | + |
| 66 | +{phang}{stata modexpt, filename("test.xlsx"): . modexpt, filename("test.xlsx")}{p_end} |
| 67 | + |
| 68 | +{pstd} |
| 69 | +If we were to run the above command again we would get an error, as the file already exists. |
| 70 | +We can overcome this by using the {opt replace} option: |
| 71 | + |
| 72 | +{phang}{stata modexpt, filename("test.xlsx") replace: . modexpt, filename("test.xlsx") replace}{p_end} |
| 73 | + |
| 74 | +{pstd} |
| 75 | +Finally, for {cmd: stmixed} models, we would replicate the above as: |
| 76 | + |
| 77 | +{phang}{stata webuse catheter: . webuse catheter}{p_end} |
| 78 | +{phang}{stata "stmixed age female || patient:, distribution(weibull)": . stmixed age female || patient:, distribution(weibull)}{p_end} |
| 79 | +{phang}{stata modexpt, filename("test.xlsx"): . modexpt, filename("test.xlsx")}{p_end} |
| 80 | + |
| 81 | +{marker author}{...} |
| 82 | +{title: Author} |
| 83 | + |
| 84 | +{pstd}Alessandro Gasparini{p_end} |
| 85 | +{pstd}Red Door Analytics AB{p_end} |
| 86 | +{pstd}Stockholm, Sweden{p_end} |
| 87 | +{pstd}E-mail: {browse "mailto:alessandro.gasparini@reddooranalytics.se":alessandro.gasparini@reddooranalytics.se}.{p_end} |
| 88 | + |
| 89 | +{phang} |
| 90 | +Please report any errors you may find, e.g., on {browse "https://github.com/RedDoorAnalytics/stdmest":GitHub} or by e-mail. |
| 91 | +{p_end} |
0 commit comments