-
Notifications
You must be signed in to change notification settings - Fork 0
/
E8.Rmd
191 lines (128 loc) · 5.81 KB
/
E8.Rmd
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
---
title: "Exercise 8 - EPI536-Assignments"
author: "Matthew Hoctor"
date: "7/9/2021"
output:
html_document:
number_sections: no
theme: lumen
toc: yes
toc_float:
collapsed: yes
smooth_scroll: no
pdf_document:
toc: yes
word_document:
toc: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(engine.path = list(
stata = "C:/Program Files/Stata17/StataBE-64"
))
```
```{r libraries, include=FALSE}
library(Statamarkdown)
```
# A: Comparison of exposures and outcomes with possible confounders
## 1: associations between the exposure variable (food assistance) and independent variables
Among food-secure boys.
### a: Cross-tabulate food assistance with categorical covariates
```{stata}
use "NHANES0708_all.dta"
svyset sdmvpsu [pw=wtmec2yr], strata(sdmvstra)
svy, subpop(if subpop2==1 & male==1 & foodinsec==0): ta race_eth food_any,col percent
svy, subpop(if subpop2==1 & male==1 & foodinsec==0): ta hinsur food_any,col percent
svy, subpop(if subpop2==1 & male==1 & foodinsec==0): ta age_3cat food_any,col percent
```
### b: Calculate mean values of continuous covariates within each category of food assistance
Formally compare these mean values using the adjusted Wald test. Example: age (ridageyr).
```{stata}
use "NHANES0708_all.dta"
svyset sdmvpsu [pw=wtmec2yr], strata(sdmvstra)
svy, subpop(if subpop2==1 & male==1 & foodinsec==0): mean ridageyr,over(food_any)
test _b[[email protected]_any] =_b[[email protected]_any]
```
## 2 Calculate associations between the dependent variable (high waist circumference [wccata]) and independent variables
Among food secure boys
First, conduct descriptive analysis (a and b), then crude regression analysis (c).
### a: Cross-tabulate high waist circumference with categorical independent variables (exposure and covariates)
Test these associations for each variable using the Design-based F test (survey analysis equivalent to the chi-square test for independence).
```{stata}
use "NHANES0708_all.dta"
svyset sdmvpsu [pw=wtmec2yr], strata(sdmvstra)
svy, subpop(if subpop2==1 & male==1 & foodinsec==0): ta food_any wccata,col percent
svy, subpop(if subpop2==1 & male==1 & foodinsec==0): ta race_eth wccata,col percent
svy, subpop(if subpop2==1 & male==1 & foodinsec==0): ta hinsur wccata,col percent
svy, subpop(if subpop2==1 & male==1 & foodinsec==0): ta pr_age wccata,col percent
```
### b: Calculate mean values of continuous independent variables (covariates) within each category of high waist circumference, among food secure boys.
```{stata}
use "NHANES0708_all.dta"
svyset sdmvpsu [pw=wtmec2yr], strata(sdmvstra)
svy, subpop(if subpop2==1 & male==1 & foodinsec==0): mean ridageyr,over(wccata)coeflegend
svy, subpop(if subpop2==1 & male==1 & foodinsec==0): mean ridageyr,over(wccata)
test _b[[email protected]] =_b[[email protected]]
```
### c: Using simple logistic regression models, calculate the crude odds ratios (OR) for the associations between each independent variable and waist circumference among food secure boys.
Descriptive analysis provides information about the absolute prevalence or means of characteristics among participants with and without the outcome. Calculation of crude odds ratios is also an important first step to regression analysis and provides initial ORs as you build your multivariable models.
For this exercise, include child age as a linear term. We will work with this variable more in Exercise E9.
#### Food Assistance
```{stata}
use "NHANES0708_all.dta"
svyset sdmvpsu [pw=wtmec2yr], strata(sdmvstra)
xi: svy,subpop(if subpop2==1 & male==1 & foodinsec==0): logit wccata i.food_any
xi: svy,subpop(if subpop2==1 & male==1 & foodinsec==0): logit wccata i.food_any,or
```
#### Race/Ethnicity
```{stata}
use "NHANES0708_all.dta"
svyset sdmvpsu [pw=wtmec2yr], strata(sdmvstra)
xi: svy,subpop(if subpop2==1 & male==1 & foodinsec==0): logit wccata i.race_eth
xi: svy,subpop(if subpop2==1 & male==1 & foodinsec==0): logit wccata i.race_eth,or
#xi: svy,subpop(if subpop2==1 & male==1 & foodinsec==0): logistic wccata i.race_eth
```
#### Health Insurance (hinsur)
```{stata}
use "NHANES0708_all.dta"
svyset sdmvpsu [pw=wtmec2yr], strata(sdmvstra)
xi: svy,subpop(if subpop2==1 & male==1 & foodinsec==0): logit wccata i.hinsur
xi: svy,subpop(if subpop2==1 & male==1 & foodinsec==0): logit wccata i.hinsur,or
#xi: svy,subpop(if subpop2==1 & male==1 & foodinsec==0): logistic wccata i.hinsur
```
#### Primary Respondant Age Category (pr_age)
```{stata}
use "NHANES0708_all.dta"
svyset sdmvpsu [pw=wtmec2yr], strata(sdmvstra)
xi: svy,subpop(if subpop2==1 & male==1 & foodinsec==0): logit wccata i.pr_age
xi: svy,subpop(if subpop2==1 & male==1 & foodinsec==0): logit wccata i.pr_age,or
#xi: svy,subpop(if subpop2==1 & male==1 & foodinsec==0): logistic wccata i.pr_age
```
#### Age
```{stata}
use "NHANES0708_all.dta"
svyset sdmvpsu [pw=wtmec2yr], strata(sdmvstra)
xi: svy,subpop(if subpop2==1 & male==1 & foodinsec==0): logit wccata ridageyr
xi: svy,subpop(if subpop2==1 & male==1 & foodinsec==0): logit wccata ridageyr,or
#xi: svy,subpop(if subpop2==1 & male==1 & foodinsec==0): logistic wccata ridageyr
```
# B
## 4 Cross-tabulate each pair of the three categorical covariates among food secure boys
### race/eth vs health insurance
```{stata}
use "NHANES0708_all.dta"
svyset sdmvpsu [pw=wtmec2yr], strata(sdmvstra)
svy, subpop(if subpop2==1 & male==1 & foodinsec==0): ta race_eth hinsur,row percent
```
### race/eth vs respondant age
```{stata}
use "NHANES0708_all.dta"
svyset sdmvpsu [pw=wtmec2yr], strata(sdmvstra)
svy, subpop(if subpop2==1 & male==1 & foodinsec==0): ta race_eth pr_age,row percent
```
### health insurance vs respondant age
```{stata}
use "NHANES0708_all.dta"
svyset sdmvpsu [pw=wtmec2yr], strata(sdmvstra)
svy, subpop(if subpop2==1 & male==1 & foodinsec==0): ta hinsur pr_age,row percent
```