Things I Love About Stata — egen mean

egen mean I work a lot with clustered data, including group psychotherapy data (people clustered in groups), individual psychotherapy data (people clustered within therapists), and longitudinal data (observations clustered within people). Consequently, I often need to create cluster-level means and grand means for graphing and modeling. The egen mean function makes creating means easy. CombiningContinue reading “Things I Love About Stata — egen mean”

Stata: Using generate to create new variables

The primary method for creating new variables in Stata is the generate command. Load the auto dataset. New Variable from Existing Variables Let’s create a new variable that is the sum of weight and length (ignore for the moment that summing weights and lengths doesn’t make a ton of sense). The syntax of generate is:Continue reading “Stata: Using generate to create new variables”

Stata: Predicted Scores and Residuals

Predicted Scores in Stata As we discussed in class, the predicted value of the outcome variable can be created using the regression model. For example, we can use the auto dataset from Stata to look at the relationship between miles per gallon and weight across various cars. We estimate the follow equation Thus, we seeContinue reading “Stata: Predicted Scores and Residuals”