class: center, middle, inverse, title-slide # The self-controlled case series (SCCS) ## 성균관의대 사회의학교실 강의 ### 김진섭 ### 2019-02-18 (updated: 2019-02-06) --- layout: true <div class="my-footer"><span><a href="https://www.anpanman.co.kr">ANPANMAN Co.,Ltd</a>                             <a href="https://github.com/jinseob2kim">김진섭</a></span></div> --- # Executive Summary .large[ * Self-controlled methods는 자기 자신을 대조군으로 비교, time-invariant confounders의 영향을 최소화할 수 있다. * **Self-controlled case series (SCCS)**, case-crossover (CCO) design, sequence symmetry analysis (SSA)가 대표적이다. * SCCS는 위험에 노출된 기간과 그렇지 않은 기간의 **상대위험도 (RR)** 를 구한다. * 한 사람에게 일어나는 각 **사건(ex: 노출, 발생, 나이)이 변화할 때 마다 데이터를 만든다** (Long format data). * Matched case-control study와 유사, **Conditional logistic regression**으로도 분석할 수 있다. ] --- # Self-controlled methods 비교 <div class="figure" style="text-align: center"> <img src="https://media.springernature.com/lw785/springer-static/image/art%3A10.1186%2Fs12874-017-0457-7/MediaObjects/12874_2017_457_Fig1_HTML.gif" alt="a: SCCS, b: CCO, c: SSA" width="50%" /> <p class="caption">a: SCCS, b: CCO, c: SSA</p> </div> Figure from <a name=cite-Takeuchi2018></a>[Takeuchi, Shinozaki, and Matsuyama [1]](https://doi.org/10.1186/s12874-017-0457-7) ---
Table from [Takeuchi, Shinozaki, and Matsuyama [1]](https://doi.org/10.1186/s12874-017-0457-7) --- # R example ```r library(readr);library(tidyr);library(purrr);library(dplyr);library(rmarkdown) ## Raw data dat <- read_tsv("http://statistics.open.ac.uk/sccs/R/ox.txt") paged_table(dat) ``` <div data-pagedtable="false"> <script data-pagedtable-source type="application/json"> {"columns":[{"label":["indiv"],"name":[1],"type":["dbl"],"align":["right"]},{"label":["eventday"],"name":[2],"type":["dbl"],"align":["right"]},{"label":["start"],"name":[3],"type":["dbl"],"align":["right"]},{"label":["end"],"name":[4],"type":["dbl"],"align":["right"]},{"label":["exday"],"name":[5],"type":["dbl"],"align":["right"]}],"data":[{"1":"1","2":"398","3":"365","4":"730","5":"458"},{"1":"2","2":"413","3":"365","4":"730","5":"392"},{"1":"3","2":"449","3":"365","4":"730","5":"429"},{"1":"4","2":"455","3":"365","4":"730","5":"433"},{"1":"5","2":"472","3":"365","4":"730","5":"432"},{"1":"6","2":"474","3":"365","4":"730","5":"395"},{"1":"7","2":"485","3":"365","4":"730","5":"470"},{"1":"8","2":"524","3":"365","4":"730","5":"496"},{"1":"9","2":"700","3":"365","4":"730","5":"428"},{"1":"10","2":"399","3":"365","4":"730","5":"716"}],"options":{"columns":{"min":{},"max":[10]},"rows":{"min":[10],"max":[10]},"pages":{}}} </script> </div> From https://rpubs.com/kaz_yos/sccs1 --- # Assumptions - 노출 위험 기간: 노출 시작부터 14-35일. - 나이 바뀌는 날: 365-730일의 중간인 547일. -- <div data-pagedtable="false"> <script data-pagedtable-source type="application/json"> {"columns":[{"label":["indiv"],"name":[1],"type":["dbl"],"align":["right"]},{"label":["eventday"],"name":[2],"type":["dbl"],"align":["right"]},{"label":["start"],"name":[3],"type":["dbl"],"align":["right"]},{"label":["end"],"name":[4],"type":["dbl"],"align":["right"]},{"label":["exday"],"name":[5],"type":["dbl"],"align":["right"]}],"data":[{"1":"1","2":"398","3":"365","4":"730","5":"458"}],"options":{"columns":{"min":{},"max":[10]},"rows":{"min":[10],"max":[10]},"pages":{}}} </script> </div> - 365: 관찰 시작 - 472: 노출 시작 (458 + 14) - 493: 노출 종료 (458 + 35) - 547: 나이 증가 - 730: 관찰 종료 4개 구간 각각의 **사건 발생, 노출 상태, 나이** 데이터를 만들어야 함. --- # Long format data ```r datLong <- dat %>% mutate(start1 = exday +14, end1 = exday + 35, age1 = 547) %>% split(.$indiv) %>% map_dfr(MakeLongformat) %>% filter(start < 730) paged_table(datLong) ``` <div data-pagedtable="false"> <script data-pagedtable-source type="application/json"> {"columns":[{"label":["indiv"],"name":[1],"type":["dbl"],"align":["right"]},{"label":["exday"],"name":[2],"type":["dbl"],"align":["right"]},{"label":["eventday"],"name":[3],"type":["dbl"],"align":["right"]},{"label":["start"],"name":[4],"type":["dbl"],"align":["right"]},{"label":["end"],"name":[5],"type":["dbl"],"align":["right"]},{"label":["event"],"name":[6],"type":["int"],"align":["right"]},{"label":["exgr"],"name":[7],"type":["int"],"align":["right"]},{"label":["agegr"],"name":[8],"type":["int"],"align":["right"]},{"label":["interval"],"name":[9],"type":["dbl"],"align":["right"]},{"label":["loginterval"],"name":[10],"type":["dbl"],"align":["right"]}],"data":[{"1":"1","2":"458","3":"398","4":"365","5":"472","6":"1","7":"0","8":"0","9":"107","10":"4.672829"},{"1":"1","2":"458","3":"398","4":"472","5":"493","6":"0","7":"1","8":"0","9":"21","10":"3.044522"},{"1":"1","2":"458","3":"398","4":"493","5":"547","6":"0","7":"0","8":"0","9":"54","10":"3.988984"},{"1":"1","2":"458","3":"398","4":"547","5":"730","6":"0","7":"0","8":"1","9":"183","10":"5.209486"},{"1":"2","2":"392","3":"413","4":"365","5":"406","6":"0","7":"0","8":"0","9":"41","10":"3.713572"},{"1":"2","2":"392","3":"413","4":"406","5":"427","6":"1","7":"1","8":"0","9":"21","10":"3.044522"},{"1":"2","2":"392","3":"413","4":"427","5":"547","6":"0","7":"0","8":"0","9":"120","10":"4.787492"},{"1":"2","2":"392","3":"413","4":"547","5":"730","6":"0","7":"0","8":"1","9":"183","10":"5.209486"},{"1":"3","2":"429","3":"449","4":"365","5":"443","6":"0","7":"0","8":"0","9":"78","10":"4.356709"},{"1":"3","2":"429","3":"449","4":"443","5":"464","6":"1","7":"1","8":"0","9":"21","10":"3.044522"},{"1":"3","2":"429","3":"449","4":"464","5":"547","6":"0","7":"0","8":"0","9":"83","10":"4.418841"},{"1":"3","2":"429","3":"449","4":"547","5":"730","6":"0","7":"0","8":"1","9":"183","10":"5.209486"},{"1":"4","2":"433","3":"455","4":"365","5":"447","6":"0","7":"0","8":"0","9":"82","10":"4.406719"},{"1":"4","2":"433","3":"455","4":"447","5":"468","6":"1","7":"1","8":"0","9":"21","10":"3.044522"},{"1":"4","2":"433","3":"455","4":"468","5":"547","6":"0","7":"0","8":"0","9":"79","10":"4.369448"},{"1":"4","2":"433","3":"455","4":"547","5":"730","6":"0","7":"0","8":"1","9":"183","10":"5.209486"},{"1":"5","2":"432","3":"472","4":"365","5":"446","6":"0","7":"0","8":"0","9":"81","10":"4.394449"},{"1":"5","2":"432","3":"472","4":"446","5":"467","6":"0","7":"1","8":"0","9":"21","10":"3.044522"},{"1":"5","2":"432","3":"472","4":"467","5":"547","6":"1","7":"0","8":"0","9":"80","10":"4.382027"},{"1":"5","2":"432","3":"472","4":"547","5":"730","6":"0","7":"0","8":"1","9":"183","10":"5.209486"},{"1":"6","2":"395","3":"474","4":"365","5":"409","6":"0","7":"0","8":"0","9":"44","10":"3.784190"},{"1":"6","2":"395","3":"474","4":"409","5":"430","6":"0","7":"1","8":"0","9":"21","10":"3.044522"},{"1":"6","2":"395","3":"474","4":"430","5":"547","6":"1","7":"0","8":"0","9":"117","10":"4.762174"},{"1":"6","2":"395","3":"474","4":"547","5":"730","6":"0","7":"0","8":"1","9":"183","10":"5.209486"},{"1":"7","2":"470","3":"485","4":"365","5":"484","6":"0","7":"0","8":"0","9":"119","10":"4.779123"},{"1":"7","2":"470","3":"485","4":"484","5":"505","6":"1","7":"1","8":"0","9":"21","10":"3.044522"},{"1":"7","2":"470","3":"485","4":"505","5":"547","6":"0","7":"0","8":"0","9":"42","10":"3.737670"},{"1":"7","2":"470","3":"485","4":"547","5":"730","6":"0","7":"0","8":"1","9":"183","10":"5.209486"},{"1":"8","2":"496","3":"524","4":"365","5":"510","6":"0","7":"0","8":"0","9":"145","10":"4.976734"},{"1":"8","2":"496","3":"524","4":"510","5":"531","6":"1","7":"1","8":"0","9":"21","10":"3.044522"},{"1":"8","2":"496","3":"524","4":"531","5":"547","6":"0","7":"0","8":"0","9":"16","10":"2.772589"},{"1":"8","2":"496","3":"524","4":"547","5":"730","6":"0","7":"0","8":"1","9":"183","10":"5.209486"},{"1":"9","2":"428","3":"700","4":"365","5":"442","6":"0","7":"0","8":"0","9":"77","10":"4.343805"},{"1":"9","2":"428","3":"700","4":"442","5":"463","6":"0","7":"1","8":"0","9":"21","10":"3.044522"},{"1":"9","2":"428","3":"700","4":"463","5":"547","6":"0","7":"0","8":"0","9":"84","10":"4.430817"},{"1":"9","2":"428","3":"700","4":"547","5":"730","6":"1","7":"0","8":"1","9":"183","10":"5.209486"},{"1":"10","2":"716","3":"399","4":"365","5":"547","6":"1","7":"0","8":"0","9":"182","10":"5.204007"},{"1":"10","2":"716","3":"399","4":"547","5":"730","6":"0","7":"0","8":"1","9":"183","10":"5.209486"}],"options":{"columns":{"min":{},"max":[10]},"rows":{"min":[10],"max":[10]},"pages":{}}} </script> </div> --- ```r MakeLongformat <- function(df) { ## Cut points cuts <- with(df, sort(c(start, end, start1, end1, age1))) ## Split observation times out <- tibble(indiv = df$indiv, exday = df$exday, eventday = df$eventday, start = head(cuts, -1), end = cuts[-1]) ## Event, exposure, and age group status for each interval out %>% mutate(event = as.integer(start <= eventday & eventday <= end), exgr = as.integer(df$start1 <= start & end <= df$end1), agegr = as.integer(start >= df$age1), interval = end - start, loginterval = log(interval)) } ``` --- # Poisson regression with matched sample A Poisson distribution during the period `\(k\)` of patient `\(i\)` with expected events: `\(\lambda_{ik}\)` `$$\lambda_{ik} = t_{ik}\exp(\phi_i + \beta X_i(k))$$` - `\(t_{ik}\)`: Length of period `\(k\)` (as an **offset term**) - `\(\exp(\phi_i)\)`: The baseline (i.e., unexposed) incidence rate - `\(X_i(k)\)`: The exposure status of period `\(k\)` (0 for the control period and 1 for the exposure period) of patient `\(i\)` -- **[gnm](https://cran.r-project.org/package=gnm)** package 이용<a name=cite-dnmRpackage></a>[[2](https://cran.r-project.org/package=gnm)]. --- ```r library(gnm) gnm(event ~ exgr + agegr + offset(loginterval), eliminate = factor(indiv), family = poisson, data = datLong) %>% summary ``` ``` ## ## Call: ## ## gnm(formula = event ~ exgr + agegr + offset(loginterval), eliminate = factor(indiv), ## family = poisson, data = datLong) ## ## Deviance Residuals: ## Min 1Q Median 3Q Max ## -1.05409 -0.60311 -0.42566 0.08177 1.72741 ## ## Coefficients of interest: ## Estimate Std. Error z value Pr(>|z|) ## exgr 2.4880 0.7085 3.512 0.000445 *** ## agegr -1.4906 1.1182 -1.333 0.182543 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## (Dispersion parameter for poisson family taken to be 1) ## ## Residual deviance: 20.177 on 26 degrees of freedom ## AIC: 64.177 ## ## Number of iterations: 5 ``` --- # Conditional logistic regression Event는 포아송 분포를 따른다는 가정, 그러나 **0 아니면 1** 두 가지 뿐. - Conditional logistic regression을 이용해도 같은 결과를 얻음. - `offset(loginterval)` 옵션 추가로 끝. - **[survival](https://CRAN.R-project.org/package=survival)** 패키지의 `clogit` 함수<a name=cite-survival-package></a>[[3](https://CRAN.R-project.org/package=survival)]. --- ```r library(survival) clogit(event ~ exgr + agegr + offset(loginterval) + strata(indiv), data = datLong) %>% summary ``` ``` ## Call: ## coxph(formula = Surv(rep(1, 38L), event) ~ exgr + agegr + offset(loginterval) + ## strata(indiv), data = datLong, method = "exact") ## ## n= 38, number of events= 10 ## ## coef exp(coef) se(coef) z Pr(>|z|) ## exgr 2.4880 12.0369 0.7085 3.512 0.000445 *** ## agegr -1.4906 0.2252 1.1182 -1.333 0.182543 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## exp(coef) exp(-coef) lower .95 upper .95 ## exgr 12.0369 0.08308 3.00226 48.259 ## agegr 0.2252 4.43965 0.02517 2.016 ## ## Concordance= 0.75 (se = 0.138 ) ## Rsquare= 0.392 (max possible= 0.643 ) ## Likelihood ratio test= 18.92 on 2 df, p=8e-05 ## Wald test = 19.1 on 2 df, p=7e-05 ## Score (logrank) test = 42.29 on 2 df, p=7e-10 ``` --- # 조심 .large[ - Time-varying confounder - Time trends in both exposures and events - Erroneously long risk periods - Patient restriction based on event history ] ---
Table from <a name=cite-Petersen2016></a>[Petersen, Douglas, and Whitaker [4]](https://doi.org/10.1136/bmj.i4515) --- class: center, middle # END --- # References <a name=bib-Takeuchi2018></a>[[1]](#cite-Takeuchi2018) Y. Takeuchi, T. Shinozaki and Y. Matsuyama. "A comparison of estimators from self-controlled case series, case-crossover design, and sequence symmetry analysis for pharmacoepidemiological studies". In: _BMC Medical Research Methodology_ 18.1 (Jan. 2018). DOI: [10.1186/s12874-017-0457-7](https://doi.org/10.1186/s12874-017-0457-7). URL: [https://doi.org/10.1186/s12874-017-0457-7](https://doi.org/10.1186/s12874-017-0457-7). <a name=bib-dnmRpackage></a>[[2]](#cite-dnmRpackage) H. Turner and D. Firth. _Generalized nonlinear models in R: An overview of the gnm package_. R package version 1.1-0. 2018. URL: [https://cran.r-project.org/package=gnm](https://cran.r-project.org/package=gnm). <a name=bib-survival-package></a>[[3]](#cite-survival-package) T. M. Therneau. _A Package for Survival Analysis in S_. version 2.38. 2015. URL: [https://CRAN.R-project.org/package=survival](https://CRAN.R-project.org/package=survival). <a name=bib-Petersen2016></a>[[4]](#cite-Petersen2016) I. Petersen, I. Douglas and H. Whitaker. "Self controlled case series methods: an alternative to standard epidemiological study designs". In: _BMJ_ (Sep. 2016), p. i4515. DOI: [10.1136/bmj.i4515](https://doi.org/10.1136/bmj.i4515). URL: [https://doi.org/10.1136/bmj.i4515](https://doi.org/10.1136/bmj.i4515).