Hi, I am currently looking at datasets from several hospitals to assess the impact of COVID-19 pandemic on the surgical volume changes through an interrupted time series analysis. With each row in my dataset being a unique surgical operation, I created a variable for monthly surgery and then aggregated the dataset by the count of surgical volume per month in order to declare it a time series dataset.
Code:
// Set up the data by month
gen surgery_date_month = mofd(surgdate_mdy)
format surgery_date_month %tm
// Collapse data by month
foreach var of varlist record_id{
bysort surgery_date_month: egen count`var'=count(`var')
}
keep surgery_date_month count*
duplicates drop surgery_date_month, force
tsset surgery_date_month, monthly
The output:
Code:
time variable: surgery_dat~h, 2019m1 to 2021m2, but with a gap
delta: 1 month
I tried running the -itsa- command but got the error "surgery_date_month is not regularly spaced" likely due to 2020m7 missing because there was zero operation that month at this site. I manually edited by adding an observation 2020m7 with a count of 0, but I was wondering if there's a way to avoid this type of manual editing by changing my unsophisticated coding as I create the monthly count.
Thank you in advance.
0 Response to ITSA Error on Monthly Time Series Data with a Gap Due to Zero Count
Post a Comment