https://github.com/andyphilips/mkduration
Stata command to create duration variable with binary cross-sectional time series data
https://github.com/andyphilips/mkduration
bcsts duration-models panel-data stata
Last synced: 5 months ago
JSON representation
Stata command to create duration variable with binary cross-sectional time series data
- Host: GitHub
- URL: https://github.com/andyphilips/mkduration
- Owner: andyphilips
- License: mit
- Created: 2019-10-18T21:36:41.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-12-24T15:56:28.000Z (over 5 years ago)
- Last Synced: 2025-09-09T07:41:44.954Z (9 months ago)
- Topics: bcsts, duration-models, panel-data, stata
- Language: Stata
- Homepage:
- Size: 821 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mkduration
Stata command to create duration variable with binary cross-sectional time series data
## Description
`mkduration` is a Stata command to generate a duration variable for duration/event history data where the data are xtset and in long format. In other words, given CSTS-style data for i units observed over t time periods, and where there is some dichotomous variable (where "1" indicates the instance of an event, and "0" indicates an absence):
| Unit | Time | Event |
|------|------|-------|
| 1 | 1 | 0 |
| 1 | 2 | 0 |
| 1 | 3 | 1 |
| 1 | 4 | 0 |
| 1 | 5 | 1 |
| 2 | 1 | 0 |
| 2 | 2 | 1 |
| 2 | 3 | 0 |
| 2 | 4 | 0 |
| 2 | 5 | 0 |
`mkduration` will generate a duration variable:
| Unit | Time | Event | Duration |
|------|------|-------|----------|
| 1 | 1 | 0 | 1 |
| 1 | 2 | 0 | 2 |
| 1 | 3 | 1 | 3 |
| 1 | 4 | 0 | 1 |
| 1 | 5 | 1 | 2 |
| 2 | 1 | 0 | 1 |
| 2 | 2 | 1 | 2 |
| 2 | 3 | 0 | 1 |
| 2 | 4 | 0 | 2 |
| 2 | 5 | 0 | 3 |
More information is available in the help file.
## Examples and Citing
You can see more details in the [Stata Journal article](https://journals.sagepub.com/doi/10.1177/1536867X20976322), or the [ungated version](https://github.com/andyphilips/mkduration/blob/master/Philips-2020-SJ.pdf).
If you use `mkduration` in your own work, I'd love it if you cited me:
* Philips, Andrew Q. 2020. "An easy way to create duration variables in binary cross-sectional time series data." The Stata Journal 20(4): 916-930.
## Install
The easiest way to install `mkduration` is by directly typing into Stata:
```
net install st0621
net get st0621
```
Alternatively, you can install `mkduration` directly from GitHub if you're connected to the internet:
```
capture ado uninstall mkduration
net install mkduration, from(https://github.com/andyphilips/mkduration/raw/master/src/)
```
Last, you can download the files from the source folder and either call directly to the .ado files or place them in your "ado/plus/" folder.
## Version
Version 1.0.4, April 27, 2020