- Laura Whiting

# Some Thoughts on Stata Modelling Commands -me- and -xt-

When choosing between **me **and **xt **commands to fit your model in Stata, it is important to have a solid understanding of your data. In many cases the differences between results from an **me **command versus the same command with **xt** are small. However there are differences in the algorithms behind the two commands, and also some differences in how the commands fit a model. For example, **xt **estimation commands will fit a random-effects model (no fixed-effects included) with only one random effects level. However the **me **commands allow for a mix of fixed-effects and random-effects with multiple random effects levels. Given these differences, it’s important to make sure you are using the commands that best fit your data.

The **xt **commands are mainly for fitting models to longitudinal or panel data, which involve measurements over time. A simple example of longitudinal data – you might have a dataset that contains information on people’s income and occupation every year for 10 years. This allows you to look at changes in occupation and/or income for individuals over that period of 10 years. If you had this information for only one year (you only have one time point) then the data is no longer longitudinal because it only represents one point in time instead of many. If your data has a longitudinal (many time-points) structure, then you need to use **xt **commands in your analysis.

It is also worth noting that some **xt **commands come with the option to fit a fixed-effects model (ie no random effects present). There are no fixed-effects-only options with the **me **commands, so if you are looking to fit a fixed-effects model you will need to use the **xt **commands.

The **me **commands are for fitting mixed-effects models. A mixed-effects model includes both fixed and random effects. The fixed effects are essentially the same as standard regression coefficients, and so Stata can estimate those directly. The random effects cannot be estimated directly. Instead they are summarised by their variances and covariances. They have a grouping structure that is either nested or in multiple levels. These commands are more suitable for non-longitudinal data.