Using a regresion discontinuity design, and Danish register data to study the effect of sleep disturbance on depression diagnoses

Speedrun

YouTube Video

Depression

Regression Discontinuity

Daylight Savings

Sleep

Author

Michel Nivard

Published

November 15, 2022

ABSTRACT

I study,and try to reproduce, a great paper by Hansen et al. (2017). Hansen et al. estimates that in Denmark, as the clocks roll back in fall, the incidence of unipolar, but not bipolar, depression diagnosis in psychiatric hospitals goes up by about 10%. There is no effect of the clocks rolling forward in spring. To estimate this effect Hansen uses whats called a “Regression discontinuity Design”. I was able to reproduce the tables, figures and statistics in the paper with minimal effort. The specific form of regression discontinuity is fairly advanced, I try alternate simpler models and show these would yield comparable results.

Introduction

In this video we take a deep dive into a very old and popular technique for observational causal inference: the regression discontinuity design. We’ll see how it was used by Hansen et al. (2017) to test for the effects of daylight savings. Daylight savings gets all people with small children spun out of sync with their obligations and social life, one can only wonder whether this has effects on their mental health.

The paper is:

Hansen, B. T., Sønderskov, K. M., Hageman, I., Dinesen, P. T., & Østergaard, S. D. (2017). Daylight savings time transitions and the incidence rate of unipolar depressive episodes. Epidemiology, 28(3), 346-353.

and the Video is up:

Read, watch and come back here for details and code.

Background

Daylight savings is itself worthy of study as its a contentious policy that’s up for debate twice a year. Its also a potential natural experiment to test the effects of disturbed sleep.

There are may appropriate ways to study whether people who are tired, or have their sleep disturbed are more likely to show symptoms of depression, seek treatment or help andare more likely to be diagnosed with depression. Experimental options include keeping people awake, and while that has been done in smaller experimental studies (Kahn-Greene et al. 2007), you could not do that at scale, placebo controlled, or in naturalistic settings.

An alternative design to get a solid estimate of disturbed sleep is to perform regression discontinuity analysis (Thistlethwaite and Campbell 1960) of a sudden shift in sleep or wake hours. Daylight savings can be viewed as such a shift, though we should immediately note that the clock rolling back is hell for parents of young children where it may be a blissful extra hour for teens, students and older adults.

Methods

Regression discontinuity analysis

In Regression discontinuity analysis (RDA, or sometimes RDD, for regression discontinuity design) we compare an outcome in people measured immediately before, and right after, a change in exposure or policy. For example kids born after January 1st may have parents eligible for a tax refund while kids born just before are born in a family that doesn’t receive a tax refund.

In its simplest form an RDA for the change in depression incidence due to daylight savings estimates a difference in depression incidence right before and right after daylight savings goes into effect, or is reversed. Estimation is then based on a regression of incidence on a binary indicator which indicates pre and post daylight savings. Lets look at some simulated data!

Code

library(ggplot2)intercept <-30effect <-3noise <-rnorm(28,0,.5)incidence_2weeks_before <- intercept + noise[1:14]incidence_2weeks_after <- intercept + effect + noise[15:28]exposure <-c(rep(0,14),rep(1,14))incidence <-c(incidence_2weeks_before,incidence_2weeks_after)time <--14:13dataset <-cbind.data.frame(incidence,exposure,time)ggplot(data=dataset,aes(x = time, y = incidence)) +geom_point() +geom_vline(xintercept =-.5) +labs(y ="Incidence", x ="Days since daylight savings")

The effect would then be the difference at the discontinuity, where its critical to get the model around the discontinuity right For a regression discontinuity model to give us results that we can trust are the causal consequence we need certain assumption to hold:

all potentially relevant variables other than the treatment variable and outcome variable are continuous at the discontinuity. So if Denmark has some massive boozy holiday “taksigelse” (Google translate of Thanksgiving) or something, on the evening before Daylight savings, this would mess with he results in.(Hansen et al. 2017)

Bandwidth: When considering a change in exposure, we want to compare those right before to those right after, if we include too long a period after we end up including the Holidays or January, periods with their own potential unrelated mood effects. But there my also be good reasons to include more than just a single week after the discontinuity, effects may take a while to manifest, people may not always be diagnosed in a week for example. We’ll return to this assumption when doing robustness checks later.

Reproducing Hansen et al.

The paper is accompanied by code and aggregate data (here at the bottom of the page under the heading “Supplementary Digital content” ). I had too wrangle the data out of the pdf file “eAppendix2.pdf” and past it into flat text file. Then I used this code to read the data into R:

Due to how pasting the data from pdf to .txt is handled by various programs you may need to edit the code a bit I suspect. Then I can proceed to try and run the author provided code to replicate the key result, an estimated 10% increase in incidence right after the clocks roll back in fall, presented in table 1 of the paper:

Code

########################################TRANSFER FUNCTIONS: REGRESSION TABLES#########################################loading librarieslibrary(TSA)library(doBy)library(stargazer)library(lmtest)library(plyr)library(forecast)library(reshape)#setting wd (NOTE: CHANGE THIS TO THE DIRECTORY OF THE REPLICATION DATA ON YOUR MACHINE)#setwd("C:/Users/mlc872/Dropbox/Terrorism/Natural_Experiments/Daylight saving/Epidemiology/Revision/Data")###############OPENING DATA################full <- read.csv("full_data_v2.csv", as.is=T)full <- (dataset.df)################ARIMAX TABLES#################TABLE 2#dependent variablesdep <-ts(full$depress_count, frequency =365.25/7)mani.bip <-ts(full$manic_bipolar_count, frequency =365.25/7)#transfer dataframesfrom <-data.frame(full$from_clock_change_week)to <-data.frame(full$to_clock_change_week)both <-data.frame(full$from_clock_change_week , full$to_clock_change_week)#running modelsfit1 <-arimax(log(dep),order=c(1,1,1),xtransf=both, transfer=list(c(1,0),c(1,0)))fit2 <-arimax(log(mani.bip),order=c(1,1,1),xtransf=both, transfer=list(c(1,0),c(1,0)))#building table and writing to htmlstargazer(coeftest(fit1),coeftest(fit2),type="html",title ="The effect of daylight saving time on affective disorders",dep.var.caption='Dependent variables in logs',dep.var.labels=c("Depression","Bipolar disorder"),column.labels=c("ARIMA(1,1,1)", "ARIMA(1,1,1)"),covariate.labels =c("Summertime (AR1)","Summertime (MA0)","Wintertime (AR1)", "Wintertime(MA0)"),add.lines=list(c("Obs.",sum(!is.na(fit1$residuals))-fit1["arma"][[1]][6],sum(!is.na(fit2$residuals))-fit2["arma"][[1]][6]),c("Log-likelihood",round(fit1$loglik,d=2),round(fit2$loglik,d=2)),c("AIC", round(fit1$aic,d=2),round(fit2$aic,d=2)) ),ci = T, report="vcs",multicolumn = F, notes.append = F, omit=seq(from=1, to=2, by=1),notes = ("ARMA-coefficients omitted"),out="daylight_saving_tab2.htm")

This code gives me the following html table which I have put side by side with the Table in the paper for your convenience:

Reproduced Table and original Table 2 in Hansen et al. 2017.

Reproduction

Original in Paper

So lets be clear, this is (in my view) 10 out of 10 score for reproducability. I reproduced up to rounding, without matching R or Package versions or really any hard work on my part. Having to wrangle the data out of a PDF was somewhat annoying, but that’s likely the journal/publishing process not the authors fault. Te rest of the code (see the journal website for the original file) quite easily reproduced other tables, figures and analysis in the paper up to rounding so ill opt to move on for now!

Evaluation & robustness

So one special feature of the Hansen et al. data is that its not one discontinuity, but rather a recurring yearly discontinuity. They analyze weekly incidence data from 1995 to 2012. They even refer to their analysis as a “timeseries intervention analysis”, which means they model the dependence of the data across time as a time-series, and add the yearly “intervention” when the clocks roll back or forward as an exogenous time series.

Their basic arima time series the use for the incidence data models 3 things:

auto regression (AR): each weekly measure influences the next weekly measure

differencing/Integration (I): they model the difference in incidence between subsequent week, not the incidence itself. This makes a lot of sense if there is for example a linear trend in incidence in Denmark in the period of study and we want to make sure we font accidentally model that trend in the other parameters of the time series.

Moving average errors (MA): The impulse that influenced the last measure, also influences the current measure directly.

For the daylight savings effect they then allow:

1. a 0th order moving average (the clock shift influences the incidence in thew week right after)

an auto regressive effect (they estimate a parameter which determines how the clock shift effect on incidence decays over the weeks after.)

These are technicalities we may return to in a separate video/post on time-series modeling, or time series intervention modeling but for now I want to highlight and test 3 things that I feel could influence the results of the paper:

The choice fo time series model

The authors pick a 1st order difference, a 1st order auto regression and a 1st order moving average for their time series of incidences. this seems fine, but fairly arbitrary, so would automatically picking the best fitting time series using auto-arima, equally arbitrary perhaps, but also not objectionable or wrong, have changed the results of the paper? letas find out:

the auto arima procedure finds the same time series model the authors used, so no reason to believe a better fitting and obvious time series exists that would have changed the results.

Why assume a peak in week one & slow decay?

The model fit by the authors assumes the effect of daylight savings on the incidence peaks in the first week and the n decays. If the change takes any other form (increase for 2/3 weeks and then decay for example), or if other events in the weeks after have their own modeled influences (the holidays, winter) this will bias the estimated effects. Lets visualize the actual change in depression incidence in the weeks after the clock rolls back.

Code

# MAke a new variable:lag <-rep(NA,940)#Postlag[which(both[,2] ==1)] <-0lag[which(both[,2] ==1) +1] <-1lag[which(both[,2] ==1) +2] <-2lag[which(both[,2] ==1) +3] <-3lag[which(both[,2] ==1) +4] <-4lag[which(both[,2] ==1) +5] <-5# Prelag[which(both[,2] ==1) -1] <--1lag[which(both[,2] ==1) -2] <--2lag[which(both[,2] ==1) -3] <--3lag[which(both[,2] ==1) -4] <--4lag[which(both[,2] ==1) -5] <--5# make the new variable a time series:lag <-ts(lag, frequency =365.25/7)line <-lm(log(dep)~ lag)scatter.smooth(log(dep) ~ lag, span =2/3, degree =2,pch=19,col=rgb(0,0,1,.3),xlab="weeks")abline(a=line$coef[1],b=line$coef[2] )abline(v=-.5,lty="dashed")

To me, this looks like there is an increased followed by a potential decline.I refit their time series model but in a dataset restricted to 5 weeks before and 5 weeks after the week directly after the clock rolls back in fall. I also make the impact simple and binary, no impact int he 5 weeks before and a constant impact in the 5 weeks after after

Code

dep2 <- depdep2[is.na(lag)] <-NA# Arima restriced to a few weeks:arima.narrow <-arima(log(dep2), order =c(1, 1, 1), xreg = (lag >-.1) )arima.narrow

What if we do allow their preferred model for the impact of clocks changing (a direct impact that ‘decays’) but apply it to this narrow 11 week window only, to counter any holiday/winter related effects?

In both alternate models there is a significant 5-6% increase of incidence after the clocks roll back. This is lower then the author estimate but would not alter the substantive interpretation as far as I am concerned.

Conclusion.

The paper by Hansen et al. is exquisitely reproducible, and to the extend I tested their concussions seem robust to alternate model specifications. I invite you to get their data and try further specification and let me know what you find. Beyond reproduction replication could focus on other countries, later years in Denmark, or on individual level symptoms of depression. The change in incidence could be a true change in individual level symptoms, but also a change in diagnostic attention as all doctors undergo the same exposure, and its effects on the health system (changes in the rates of traffic accidents (Carey and Sarma 2017) for example) that may induce time pressures in hospital and diagnostic settings. There is work (Kountouris and Remoundou 2014) that shows no systematic effects on individual level well-being measures correlated to depression symptoms when going to winter time in the UK or Germany.That paper uses models and time windows (days not weeks) sufficiently different for someone to try and revisit with the intend to reconcile the two findings.

References

Carey, Rachel N, and Kiran M Sarma. 2017. “Impact of Daylight Saving Time on Road Traffic Collision Risk: A Systematic Review.”BMJ Open 7 (6): e014319. https://doi.org/10.1136/bmjopen-2016-014319.

Hansen, Bertel T., Kim M. Sønderskov, Ida Hageman, Peter T. Dinesen, and Søren D. Østergaard. 2017. “Daylight Savings Time Transitions and the Incidence Rate of Unipolar Depressive Episodes.”Epidemiology 28 (3): 346–53. https://doi.org/10.1097/ede.0000000000000580.

Kahn-Greene, Ellen T., Desiree B. Killgore, Gary H. Kamimori, Thomas J. Balkin, and William D. S. Killgore. 2007. “The Effects of Sleep Deprivation on Symptoms of Psychopathology in Healthy Adults.”Sleep Medicine 8 (3): 215–21. https://doi.org/10.1016/j.sleep.2006.08.007.

Kountouris, Yiannis, and Kyriaki Remoundou. 2014. “About Time: Daylight Saving Time Transition and Individual Well-Being.”Economics Letters 122 (1): 100–103. https://doi.org/10.1016/j.econlet.2013.10.032.

Thistlethwaite, Donald L., and Donald T. Campbell. 1960. “Regression-Discontinuity Analysis: An Alternative to the Ex Post Facto Experiment.”Journal of Educational Psychology 51 (6): 309–17. https://doi.org/10.1037/h0044319.