# Stata

## Stata for health researchers

Here is a quick review of the fourth edition of An introduction to Stata for Health Researchers, by Svend Juul and Morten Frydenberg. I have several books from Stata Press (and I’d love getting more of them). I always found them very well written, and they generally offer a good balance between theory and application. There is a companion website (other than material provided by Stata Press) as well. There is also some comments to exercices for the present book.

## lost+found 2014

Here are some draft notes, written in 2014, unfilled but not lost forever. With slight edits to accomodate a proper archive blog post. Stata for structural equation modeling (October 2014) As Mplus syntax often appears a bit cryptic to carry out basic operations in Confirmatory Factor Analysis (CFA), I decided to write out some of the notes I took when using Mplus for recent psychometric studies. In what follows, I will use data described and analysed in Acock’s Stata textbook, Discovering Structural Equation Modeling Using Stata.

## Weaving Stata

Here are some possibilities for weaving Stata commands without much effort. I used to use StatWeave, as described in this post. In essence, it is similar to Sweave and you write code chunks with options, etc. A concise description is provided in these slides. Although less sophisticated than Sweave or knitr, it provided enough features for me to write a full textbook for a course I teach at the university.

## Structural equation modeling with Stata

Stata 12 came with a module to perform Structural Equation Modeling. Like Amos, there is a SEM diagram builder and fancy dialog boxes but as always commands are directly returned on the command-line so it is not difficult to learn how to write your SEM model directly at Stata prompt or in a do file. Recently, a book on Discovering Structural Equation Modeling Using Stata was published by Stata Press (Alan C.

## Bar charts of counts in Stata

The second part of my course on R and Stata has just started (four weeks to go). This is about Stata this time. First part of the course is about data management, descriptive statistics and basic test of association. Although I prefer dotplots over barcharts, I often miss some of the facilities we have with R base barplot, or its lattice equivalent barchart, used in combination with table or xtabs.

## Weaving Stata Documents

StatWeave has been recently updated and it has become a powerful engine for weaving Stata documents. StatWeave The good news is that we can now use graphical commands with Statweave. There’s a minimal working example in the testing suite: Stata-test.swv. The Statweave package offers some handy customizations like code formatting (see \StataweaveOpts{}), and basically all we need to do is to put our Stata code in a Statacode environment. For R, we would use a Rcode environment.

## Weaving scientific documents

Some notes about installing and testing StatWeave with R and Stata. StatWeave is yet another way to weave code chunks and text into a single document. The idea of interlacing code and doucmentation is borrowed from the famous web and cweb systems developed by D Knuth who also coined the term “literate programming”. There is a draft article on Lightweight Literate Programming, which has evolved as an extended discussion of the following paper:

## Interaction terms in nonlinear models

This discussion is primarily based on the following article, but see also(1,2): Ai, C. and Norton, E.C. (2003). Interaction terms in logit and probit models. Economics Letters, 80: 123-129.