Thursday, October 04, 2018

Stata undocumented commands and options

Stata undocumented commands and options
Stata undocumented/obsolete commands and options are usually used by limited people such as Stata programmers of StataCorp in developing Stata. However, sometimes I find they are quite handy.

verification or validation

Verification or Validation
  • Verification and validation are quite different and used for different purposes. For example, verification answers, "Am I building the model right?", and validation answers, "Am I building the right model?"
  • Wikipedia: Verification and validation of computer simulation models
  • Wikipedia: Verification and validation
  • Verification: The evaluation of whether or not a product, service, or system complies with a regulation, requirement, specification, or imposed condition. It is often an internal process
  • Validation: The assurance that a product, service, or system meets the needs of the customer and other identified stakeholders. It often involves acceptance and suitability with external customers.

Tuesday, October 02, 2018

Stata: output and reuse the estimates of histogram

Stata: Output and reuse the estimates of a histogram
Sometimes we would like to export the estimates of a histogram and make a histogram plot using other software such as Excel.  The undocumented command - twoway__ histogram_gen - can help.
  • Stata tip 20: Generating histogram bin variables, for example (modified):
    • sysuse auto,clear
    • histogram weight, percent bin(20)
    • twoway__histogram_gen weight, bin(20) percent gen (hvalue xvalue, replace)
    • twoway bar hvalue xvalue, barwidth(.15) bstyle(histogram)
    • list hvalue xvalue if !missing(hvalue), sum(hvalue) clean
    • or, you can copy columns from the "Data Editor" window and paste them into Excel sheet.
  • or use - serset -, the data in the .gph file are stored in the serset format
    • sysuse auto,clear
    • histogram weight, percent width(100)
    • preserve
    • serset use,clear
    • then, you can copy the first and third columns (such as __000001, __000003) from the "Data Editor" window and paste them into an Excel sheet.
    • restore
  • - grexport - a user-written ado file, an alternative to -graph export-
    • sysuse auto,clear
    • histogram weight, percent width(100)
    • grexport, list //list results in the result window