11.07.2015 Views

[U] User's Guide

[U] User's Guide

[U] User's Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

[ U ] 18.10 Saving results 2333. Codeereturn name = expereturn local name . . .ereturn matrix name matname(same syntax as scalar without the ereturn)(same syntax as local without the ereturn)(moves matname to e(name))to save results in e(). You do not save the coefficient vector and variance matrix e(b) ande(V) in this way; instead you use ereturn post.4. Codesreturn local name . . .(same syntax as local without the sreturn)to save results in s(). (The s-class has only macros.)A program must be exclusively r-class, e-class, or s-class.18.10.1 Saving results in r()In [U] 18.8 Accessing results calculated by other programs, we showed an example that reportedthe mean and standard error of the mean. A better version would save in r() the results of itscalculations and would readprogram meanse, rclassquietly summarize ‘1’local mean = r(mean)local sem = sqrt(r(Var)/r(N))display " mean = " ‘mean’display "SE of mean = " ‘sem’return scalar mean = ‘mean’return scalar se = ‘sem’endRunning meanse now sets r(mean) and r(se):. meanse mpgmean = 21.297297SE of mean = .67255109. return listscalars:r(se) = .6725510870764975r(mean) = 21.2972972972973In this modification, we added the rclass option to the program statement, and we added tworeturn commands to the end of the program.Although we placed the return statements at the end of the program, they may be placed at thepoint of calculation if that is more convenient. A more concise version of this program would readprogram meanse, rclassquietly summarize ‘1’return scalar mean = r(mean)return scalar se = sqrt(r(Var)/r(N))display " mean = " return(mean)display "SE of mean = " return(se)end

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!