-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathanalysis.R
155 lines (151 loc) · 9.61 KB
/
analysis.R
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# ANALYSIS: predictor=dichotomous low/normal TST (TST=total testosterone)-------------------------------------------------------
## men, outcome=depression sum score, unadjusted and adjusted models
summend <- svyglm(depsum ~ tstdikm, data=dffull, design=desmen, family = "gaussian")
summendadj <- svyglm(depsum ~ tstdikm+ age+ bmi +alc+ smo + pa, data=dffull, design=desmen, family = "gaussian")
summ(summendadj, confint=T, scale=T, transform.response = TRUE)
## women, outcome=depression sum score, unadjusted and adjusted models
sumwd <- svyglm(depsum ~ tstdikw, data=dffull, design=deswomen, family = "gaussian")
sumwdadj <- svyglm(depsum ~ tstdikw+ age+ bmi +alc+ smo + pa +preg, data=dffull, design=deswomen, family = "gaussian")
summ(sumwdadj, confint=T, scale=T, transform.response = TRUE)
## men, outcome=depressive symptoms, unadjusted and adjusted models (for adjusted, remove #)
di1 <- svyglm(depd1 ~ tstdikm #+ age+ bmi +alc+ smo + pa
,data=dffull, design=desmen, family = "quasibinomial")
di2 <- svyglm(depd2 ~ tstdikm #+ age+ bmi +alc+ smo + pa
,data=dffull, design=desmen, family = "quasibinomial")
di3 <- svyglm(depd3 ~ tstdikm #+ age+ bmi +alc+ smo + pa
,data=dffull, design=desmen, family = "quasibinomial")
di4 <- svyglm(depd4 ~ tstdikm #+ age+ bmi +alc+ smo + pa
,data=dffull, design=desmen, family = "quasibinomial")
di5 <- svyglm(depd5 ~ tstdikm #+ age+ bmi +alc+ smo + pa
,data=dffull, design=desmen, family = "quasibinomial")
di6 <- svyglm(depd6 ~ tstdikm #+ age+ bmi +alc+ smo + pa
,data=dffull, design=desmen, family = "quasibinomial")
di7 <- svyglm(depd7 ~ tstdikm #+ age+ bmi +alc+ smo + pa
,data=dffull, design=desmen, family = "quasibinomial")
di8 <- svyglm(depd8 ~ tstdikm #+ age+ bmi +alc+ smo + pa
,data=dffull, design=desmen, family = "quasibinomial")
di9 <- svyglm(depd9 ~ tstdikm #+ age+ bmi +alc+ smo + pa
,data=dffull, design=desmen, family = "quasibinomial")
## women, outcome=depressive symptoms, unadjusted and adjusted models (for adjusted, remove #)
diw1 <- svyglm(depd1 ~ tstdikw #+ age+ bmi +alc+ smo + pa + preg
,data=dffull, design=deswomen, family = "quasibinomial")
diw2 <- svyglm(depd2 ~ tstdikw #+ age+ bmi +alc+ smo + pa + preg
,data=dffull, design=deswomen, family = "quasibinomial")
diw3 <- svyglm(depd3 ~ tstdikw #+ age+ bmi +alc+ smo + pa + preg
,data=dffull, design=deswomen, family = "quasibinomial")
diw4 <- svyglm(depd4 ~ tstdikw #+ age+ bmi +alc+ smo + pa + preg
,data=dffull, design=deswomen, family = "quasibinomial")
diw5 <- svyglm(depd5 ~ tstdikw #+ age+ bmi +alc+ smo + pa + preg
,data=dffull, design=deswomen, family = "quasibinomial")
diw6 <- svyglm(depd6 ~ tstdikw #+ age+ bmi +alc+ smo + pa+ preg
,data=dffull, design=deswomen, family = "quasibinomial")
diw7 <- svyglm(depd7 ~ tstdikw #+ age+ bmi +alc+ smo + pa+ preg
,data=dffull, design=deswomen, family = "quasibinomial")
diw8 <- svyglm(depd8 ~ tstdikw #+ age+ bmi +alc+ smo + pa+ preg
,data=dffull, design=deswomen, family = "quasibinomial")
diw9 <- svyglm(depd9 ~ tstdikw #+ age+ bmi +alc+ smo + pa+ preg
,data=dffull, design=deswomen, family = "quasibinomial")
# ANALYSIS: predictor=TST splines-------------------------------------------------------
## men, outcome=depression sum score, unadjusted and adjusted models, without transformation and log transformed TST as predictor
# (for adjusted models, remove #)
summen <- svyglm(depsum ~ ns(tst, df=3) #+ age+ +alc + bmi + smo + pa
, data=dffull, design=desmen, family = "gaussian")
regTermTest(summen, ~ns(tst, df=3))
summenlog <- svyglm(depsum ~ ns(logtst, df=3) #+ age+ +alc + bmi + smo + pa
, data=dffull, design=desmen, family = "gaussian")
regTermTest(summenlog, ~ns(logtst, df=3))
## women, outcome=depression sum score, unadjusted model and adjusted models, without transformation and log transformed TST as predictor
# (for adjusted models, remove #)
sumw <- svyglm(depsum ~ ns(tst, df=3) #+ age+ +alc + bmi + smo + pa +preg
, data=dffull, design=deswomen, family = "gaussian")
regTermTest(sumw, ~ns(tst, df=3))
sumwlog <- svyglm(depsum ~ ns(logtst, df=3) #+ age+ +alc + bmi + smo + pa +preg
, data=dffull, design=deswomen, family = "gaussian")
regTermTest(sumwlog, ~ns(logtst, df=3))
## men, outcome=depressive symptoms, unadjusted and adjusted models, without transformation and log transformed TST as predictor
# (for adjusted models, remove #)
# TST without transformation, men
spl1 <- svyglm(depd1 ~ ns(tst, df=3) #+ age+ +alc + bmi + smo + pa
, data=dffull, design=desmen, family = "quasibinomial")
spl2 <- svyglm(depd2 ~ ns(tst, df=3) #+ age+ +alc + bmi + smo + pa
, data=dffull, design=desmen, family = "quasibinomial")
spl3 <- svyglm(depd3 ~ ns(tst, df=3) #+ age+ +alc + bmi + smo + pa
, data=dffull, design=desmen, family = "quasibinomial")
spl4 <- svyglm(depd4 ~ ns(tst, df=3) #+ age+ +alc + bmi + smo + pa
, data=dffull, design=desmen, family = "quasibinomial")
spl5 <- svyglm(depd5 ~ ns(tst, df=3) #+ age+ +alc + bmi + smo + pa
, data=dffull, design=desmen, family = "quasibinomial")
spl6 <- svyglm(depd6 ~ ns(tst, df=3) #+ age+ +alc + bmi + smo + pa
, data=dffull, design=desmen, family = "quasibinomial")
spl7 <- svyglm(depd7 ~ ns(tst, df=3) #+ age+ +alc + bmi + smo + pa
, data=dffull, design=desmen, family = "quasibinomial")
spl8 <- svyglm(depd8 ~ ns(tst, df=3) #+ age+ +alc + bmi + smo + pa
, data=dffull, design=desmen, family = "quasibinomial")
spl9 <- svyglm(depd9 ~ ns(tst, df=3) #+ age+ +alc + bmi + smo + pa
, data=dffull, design=desmen, family = "quasibinomial")
# log transformed TST, men
spl1log <- svyglm(depd1 ~ ns(logtst, df=3) #+ age+ +alc + bmi + smo + pa
, data=dffull, design=desmen, family = "quasibinomial")
spl2log <- svyglm(depd2 ~ ns(logtst, df=3) #+ age+ +alc + bmi + smo + pa
, data=dffull, design=desmen, family = "quasibinomial")
spl3log <- svyglm(depd3 ~ ns(logtst, df=3) #+ age+ +alc + bmi + smo + pa
, data=dffull, design=desmen, family = "quasibinomial")
spl4log <- svyglm(depd4 ~ ns(logtst, df=3) #+ age+ +alc + bmi + smo + pa
, data=dffull, design=desmen, family = "quasibinomial")
spl5log <- svyglm(depd5 ~ ns(logtst, df=3) #+ age+ +alc + bmi + smo + pa
, data=dffull, design=desmen, family = "quasibinomial")
spl6log <- svyglm(depd6 ~ ns(logtst, df=3) #+ age+ +alc + bmi + smo + pa
, data=dffull, design=desmen, family = "quasibinomial")
spl7log <- svyglm(depd7 ~ ns(logtst, df=3) #+ age+ +alc + bmi + smo + pa
, data=dffull, design=desmen, family = "quasibinomial")
spl8log <- svyglm(depd8 ~ ns(logtst, df=3) #+ age+ +alc + bmi + smo + pa
, data=dffull, design=desmen, family = "quasibinomial")
spl9log <- svyglm(depd9 ~ ns(logtst, df=3) #+ age+ +alc + bmi + smo + pa
, data=dffull, design=desmen, family = "quasibinomial")
## women, outcome=depressive symptoms, unadjusted models and adjusted models, without transformation and log transformed
# (for adjusted models, remove #)
## TST without transformation, women
spl1w <- svyglm(depd1 ~ ns(tst, df=3) #+age+ bmi +alc+ smo + pa +preg
, data=dffull, design=deswomen, family = "quasibinomial")
spl2w <- svyglm(depd2 ~ ns(tst, df=3) #+age+ bmi +alc+ smo + pa +preg
, data=dffull, design=deswomen, family = "quasibinomial")
spl3w <- svyglm(depd3 ~ ns(tst, df=3) #+age+ bmi +alc+ smo + pa +preg
, data=dffull, design=deswomen, family = "quasibinomial")
spl4w <- svyglm(depd4 ~ ns(tst, df=3) #+age+ bmi +alc+ smo + pa +preg
, data=dffull, design=deswomen, family = "quasibinomial")
spl5w <- svyglm(depd5 ~ ns(tst, df=3) #+age+ bmi +alc+ smo + pa +preg
, data=dffull, design=deswomen, family = "quasibinomial")
spl6w <- svyglm(depd6 ~ ns(tst, df=3) #+age+ bmi +alc+ smo + pa +preg
, data=dffull, design=deswomen, family = "quasibinomial")
spl7w <- svyglm(depd7 ~ ns(tst, df=3) #+age+ bmi +alc+ smo + pa +preg
, data=dffull, design=deswomen, family = "quasibinomial")
spl8w <- svyglm(depd8 ~ ns(tst, df=3) #+age+ bmi +alc+ smo + pa +preg
, data=dffull, design=deswomen, family = "quasibinomial")
spl9w <- svyglm(depd9 ~ ns(tst, df=3) #+age+ bmi +alc+ smo + pa +preg
, data=dffull, design=deswomen, family = "quasibinomial")
## log transformed TST, women
spl1wlog <- svyglm(depd1 ~ ns(logtst, df=3) #+age+ bmi +alc+ smo + pa +preg
, data=dffull, design=deswomen, family = "quasibinomial")
spl2wlog <- svyglm(depd2 ~ ns(logtst, df=3) #+age+ bmi +alc+ smo + pa +preg
, data=dffull, design=deswomen, family = "quasibinomial")
spl3wlog <- svyglm(depd3 ~ ns(logtst, df=3) #+age+ bmi +alc+ smo + pa +preg
, data=dffull, design=deswomen, family = "quasibinomial")
spl4wlog <- svyglm(depd4 ~ ns(logtst, df=3) #+age+ bmi +alc+ smo + pa +preg
, data=dffull, design=deswomen, family = "quasibinomial")
spl5wlog <- svyglm(depd5 ~ ns(logtst, df=3) #+age+ bmi +alc+ smo + pa +preg
, data=dffull, design=deswomen, family = "quasibinomial")
spl6wlog <- svyglm(depd6 ~ ns(logtst, df=3) #+age+ bmi +alc+ smo + pa +preg
, data=dffull, design=deswomen, family = "quasibinomial")
spl7wlog <- svyglm(depd7 ~ ns(logtst, df=3) #+age+ bmi +alc+ smo + pa +preg
, data=dffull, design=deswomen, family = "quasibinomial")
spl8wlog <- svyglm(depd8 ~ ns(logtst, df=3) #+age+ bmi +alc+ smo + pa +preg
, data=dffull, design=deswomen, family = "quasibinomial")
spl9wlog <- svyglm(depd9 ~ ns(logtst, df=3) #+age+ bmi +alc+ smo + pa +preg
, data=dffull, design=deswomen, family = "quasibinomial")
# test for the significance of TST, example
regTermTest(spl1, ~ns(tst, df=3)) # men
regTermTest(spl1log, ~ns(logtst, df=3)) # men, logtst
regTermTest(spl1w, ~ns(tst, df=3)) # women
regTermTest(spl1wlog, ~ns(logtst, df=3)) # women, logtst
# sensitivity analysis with subsets of men and women who score >4 on the PHQ9:
# repeat the analysis by changing desmen to desmend (men) or deswomen to deswomend (women)