*! version 1.1.0 01jul2024
help epichecks

Syntax

epichecks , diaryid(string)

Description

epichecks -- performs a few quality checks on the episode file and its key variables: 'start' and 'end'.
First, the program checks for missing values in 'start' and 'end'.
Second, the program checks that the diary starts at minute 0 and ends at minute 1440, as it should.
Third, the program checks that there are no gaps between episodes and no partially or totally overlapping episodes
(in other words, the beginning of every episode of activity must coincide exactly with the end of the previous episode).

If all these conditions are fulfilled, the episodes of activity are correctly defined and will add up to 1440 minutes per day.
If the program finds that any of these conditions is not fulfilled, it will display a red message in the results window to warn the user about the problem so that it can be fixed.
The program creates flag variables to facilitate inspection and correction of the problematic cases.
It is a good idea to run epichecks before using any of the commands included in the timeuse package that use an episode file as a starting point, as otherwise, the programs may not produce the desired results.

Arguments

diaryid(string): the names of the variable or variables that when considered jointly uniquely identify the diary.

Variables that need to exist

The following variables do need to exist in order for the program to work.

start: start time of the episode expressed as minute of day.
'start' can take values from 0 to 1439. The first episode of the diary
should start at minute 0.

end: end time of the episode expressed as minute of day. 'end' can take values from 1 to 1440. The last episode of the diary should end at minute 1440.

Outcomes

flag_start: flags diaries with some missing/invalid value in 'start'.

flag_end: flags diaries with with some missing/invalid value in 'end'.

flag_badstart: flags diaries where the first episode of activity does not start at minute 0.

flag_badend: flags diaries where the last episode of activity does not end at minute 1440.

flag_gaps: flags diaries containing at least one episode where start_n!=end_n-1.

Examples

The following examples start by loading the dataset "diary.dta" and run the quality checks.
In the first example, the report shows that the diary file is unproblematic.
In the remaining examples, we introduce errors and show how the report displays them.
After the errors are fixed (by either actually fixing them or dropping the diaries that have problems), the program epichecks is run again to show how the report is clean once the problems have been solved.

Example 1: a file without problems

. net get timeuse

. use diary, clear

. epichecks, diaryid(personid diaryid)

Example 2: a file problems in the diary start time

. net get timeuse

. use diary, clear

. replace start=5 if personid<5 & epnum==1

. epichecks, diaryid(personid diaryid)

. replace start=0 if personid<5 & epnum==1

. epichecks, diaryid(personid diaryid)

Example 3: a file problems in the diary end time

. net get timeuse

. use diary, clear

. bysort personid diaryid: egen lastep=max(epnum)

. replace end=1430 if personid<=5 & epnum==lastep

. epichecks, diaryid(personid diaryid)

. replace end=1440 if personid<=5 & epnum==lastep

. epichecks, diaryid(personid diaryid)

Example 4: a file with partly overlapping episodes

. net get timeuse

. use diary, clear

. egen udid=group(personid diaryid)

. xtset udid epnum

. replace start=l1.end+2 if epnum==3 & udid<=5

. epichecks, diaryid(personid diaryid)

. drop if flag_gaps==1

. epichecks, diaryid(personid diaryid)

Author:

Juana Lamote de Grignon Pérez, Centre for Time Use Research (UCL), juana.lamote@gmail.com

Thanks for citing this software as follows:

Lamote de Grignon, J. (2024). epichecks: Stata module to detect errors in episode files. Available from: https://ideas.repec.org/c/boc/bocode/s459346.html.

Acknowledgments:

I am grateful to Elena Mylona and Margarita Vega Rapún for their feedback during the development of the program.