There may be times that you receive a file that has many (or all) of the variables defined as strings, that is, character variables. The variables may contain numeric values,…
Read More
Search Results for: stata
How can I access the random effects after mixed using _diparm? | Stata FAQ
Consider the following mixed model: use https://stats.idre.ucla.edu/stat/data/depression, clear mixed depression i.group visit || sid: visit, cov(un) stddev Performing EM optimization: Performing gradient-based optimization: Iteration 0: log likelihood = -826.15973 Iteration…
Read More
How can I reshape doubly (or triply) wide data to long? | Stata FAQ
I don’t know if there is a standard definition of doubly wide data, but we will use it to mean data collected by subject on multiple time points on multiple…
Read More
How can I create dummy variables in Stata? | Stata FAQ
There are two easy ways to create dummy variables in Stata. Let’s begin with a simple dataset that has three levels of the variable group: input group 1 1 2…
Read More
How can I detect duplicate observations? | Stata FAQ
How do we detect if our data set has duplicate observations in Stata? Let’s look at the following data set with some duplicate observations in it. list id female race…
Read More
How can I create dyad IDs? | Stata FAQ
Data management with dyadic data can be difficult. Before analyzing dyadic data, one may wish to know how many unique dyads appear in a dataset and create an ID variable…
Read More
How can I identify cases used by an estimation command using e(sample)? | Stata FAQ
When performing data analysis, it is very common for a given model (e.g. a regression model), to not use all cases in the dataset. This can occur for a number…
Read More
How can I perform a factor analysis with categorical (or categorical and continuous) variables? | Stata FAQ
Standard methods of performing factor analysis ( i.e., those based on a matrix of Pearson’s correlations) assume that the variables are continuous and follow a multivariate normal distribution. If the…
Read More
How can I do EFA within a CFA framework? | Stata FAQ
EFA within a CFA framework, as the name implies, combines aspects of both EFA and CFA. It produces a factor solution that is close to an EFA solution while providing…
Read More
How do I do elementwise operations on a matrix? | Stata FAQ
Here is a small (3×3) Stata example of a matrix in which each element is exponentiated. You can generalize this example to any kind of elementwise matrix operation. matrix x…
Read More
