These pages contain Stata commands and Stata programs with a minimum of documentation or explanation. These pages often reflect samples that we have created in solving a problem for someone during consulting. If we do not have time to make a proper FAQ or Learning Module, we place the example program here so it may be publicly available until we have time to make a proper FAQ page or Learning Module page. Until then, we hope that these example may prove useful to some of you. If you are not sure if you are properly using any of these code fragments (and you are a member of the UCLA research community) please use our consulting services so we may help you properly use these examples. Many of these examples are tricky and complicated, so if you are in doubt, please let us assist you.

## Graphics

- Combining histogram and boxplot in one graph
- Graphing binary logistic regression given parameters
- Graphing ordinal logistic regression given parameters
- Many boxplots (Stata 8)
- Graphing logistic regression with a continuous variable by continuous variable interaction
- Graphing predicted probabilities with two interaction terms
- Creating a pyramid plot by subgroup
- Graphing means and confidence intervals by multiple group variables
- Creating and extending boxplots using twoway graphs

**Data management **

- Random sampling with replacement
- Computing spells
- Working across variables
- Reading Stata data into mata
- Computing the sum difference between two lattitude and longitude points using Mata
- Compute Dispersion using Mata
- Generate Anonymous Keys using Mata
- Creating an adjacency matrix
- Merging the NSAF data files
- How to a read binary file
- Simulating discrete (geometric, poisson and
zero-inflated poisson, negative binomial and zero-inflated

negative binomial) random Variables

Miscellaneous commands

- Testing bootstrapping
- Retrospective power analysis for anova
- Comparing regression coefficients across groups using suest
- Descriptives, ttests, anova and regression
- ANOVA
- Choosing between nonnested models
- Getting adjusted values in probit
- Displaying hazard ratio by different baseline characteristics
- Using ml commands to maximize a user specified likelihood function
- Manually generate predicted probabilities from a multinomial logistic regression in Stata
- Running a simulation
- Fitting a seemingly unrelated regression (sureg) manually
- Computing Šidák-Holm adjusted p-values
- Simple linear and nonlinear models using Stata’s ml command
- CFA using mata optimize
- Compute SRMR from SEM using mata
- Compute Adjusted Values from Cox Model using Mata
- Reading and Analyzing the Hospital Doctor Patient Dataset