-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathREADME.Rmd
More file actions
102 lines (67 loc) · 3.02 KB
/
README.Rmd
File metadata and controls
102 lines (67 loc) · 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
---
title: "Comparison of new psychiatric diagnoses among children and adolescents before and during the COVID-19 pandemic: A nationwide register-based study"
output: rmarkdown::github_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
[](https://zenodo.org/badge/latestdoi/511254713)
## Introduction
This document shows how to perform the analyses and vizualize the results as described in the manuscript 'Comparison of new psychiatric diagnoses among children and adolescents before and during the COVID-19 pandemic: A nationwide register-based study'.
## Reproducing analyses
Clone the repository from <https://github.com/davgyl/covid_psyserv.git>.
## Prepare the denominator
The program to edit the data containing the number at risk is found in `code/01_prep_denominator.R`.
## Time series data
The time series data used for running the analyses is found in `data/ts_aggregated.rds` and it has the following structure.
```{r chunk_01}
source("code//00_pkgs_utils.R")
ts_m <- read_rds("data/ts_aggregated.rds")
ts_m %>% glimpse()
```
The variables `ts` and `lab_ts` clusters the time series to
- One time serie of any diagnosis without stratification (`01_any`)
- Two time series of any diagnosis stratified by sex (`02_sex`)
- Two time series of any diagnosis stratified by age group (`03_age`)
- Two time series of any diagnosis stratified by geomgraphic area (`04_area`)
- Seven time series of diagnostic groups as outcomes (`04_area`)
```{r chunk_02, echo=FALSE}
ts_m %>% select(ts, lab_ts) %>% unique() %>% kable()
```
## Modelling and visualization
- The program for modelling data is found in `code/02_model_functions.R`.
- To model the associations, run `code/03_model_all_ts.R`.
- To edit tables, run `code/04_viz_table1_descr.R` and `code/05_viz_table2.R`.
- To visualize the associations as figures, run `code/06_viz_fig_aim1.R` for Figure 1 and `code/07_viz_fig_aim2.R` for Figure 2.
- To plot supplemental figures, run `code/08_covid_patients_hospital.R` and `code/10_stratification.R`.
- To examine immigration and emigration, run `code/09_emigration_immigration.R`
## Immigration and emigration
The number and percentage of youth immigrating and emigrating per year is shown in the table below as described in detail in `code/09_emigration_immigration.R`.
```{r chunk_03, echo=FALSE, message=FALSE}
source("code//09_emigration_immigration.R")
```
```{r chunk_04, echo=FALSE}
im_em_tab %>% kable()
```
## Versions
R version: `r getRversion()`. Version of packages are shown in the table below.
```{r chunk_05, echo=FALSE}
packages <-
list(
"MASS",
"tidyverse",
"stringr",
"openxlsx",
"knitr",
"lubridate",
"codebook",
"haven",
"broom"
)
tab_pkg_vs <- matrix(NA, nrow = length(packages), ncol = 2)
for(i in 1:length(packages)) {
tab_pkg_vs[i, 1] <- packages[[i]]
tab_pkg_vs[i, 2] <- packageVersion(packages[[i]]) %>% paste()
}
kable(tab_pkg_vs, col.names = c("Package", "Version"))
```