Hey!
I am currently trying to generate a matrix from stata data in mata, using groups of observations as rows. Normally I would collapse the data to the desired level of observations. I however do not want to ruin the dataset since this would not enable me to run regressions on the original level of observations anymore.
The dataset looks something like an extended version of this: (each observation contains information about a route and airline, where route_airline and route are id (numeric) variables at different levels of observation)
The desired matrix should be with a "collapsed" version of routes as rows and all airline.i as dummy variables as columns.
Thanks a lot for your help!
Frank
I am currently trying to generate a matrix from stata data in mata, using groups of observations as rows. Normally I would collapse the data to the desired level of observations. I however do not want to ruin the dataset since this would not enable me to run regressions on the original level of observations anymore.
The dataset looks something like an extended version of this: (each observation contains information about a route and airline, where route_airline and route are id (numeric) variables at different levels of observation)
route_airline | route | airline1 | airline2 | airline3 | airline4 |
30011 | 3001 | 1 | 0 | 0 | 0 |
30013 | 3001 | 0 | 0 | 1 | 0 |
30014 | 3001 | 0 | 0 | 0 | 1 |
30021 | 3002 | 1 | 0 | 0 | 0 |
30022 | 3002 | 0 | 1 | 0 | 0 |
30031 | 3003 | 1 | 0 | 0 | 0 |
30032 | 3003 | 0 | 1 | 0 | 0 |
30033 | 3003 | 0 | 0 | 1 | 0 |
Thanks a lot for your help!
Frank
Comment