-
Notifications
You must be signed in to change notification settings - Fork 0
/
E11.Rmd
183 lines (123 loc) · 5.74 KB
/
E11.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
---
title: "Exercise 11 - EPI536-Assignments"
author: "Matthew Hoctor"
date: "7/20/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: Stratified Analysis
## 1 gender-food security stratified
Calculate gender-food security stratified associations between food assistance and BMI z-score. Record the coefficient, its 95% confidence interval (CI) and p-value in the table below. Enter the data to two decimal places. Place a comma between the lower and upper bounds of the 95% CI.
### a food secure girls and boys
```{stata}
use "NHANES0708_all.dta"
svyset sdmvpsu [pw=wtmec2yr], strata(sdmvstra)
xi: svy,subpop(if subpop2==1 & male==0 & foodinsec==0): regress bmiz food_any ridageyr i.race_eth fpl_2cat i.hinsur pr_male i.pr_ed3 i.pr_age
```
```{stata}
use "NHANES0708_all.dta"
svyset sdmvpsu [pw=wtmec2yr], strata(sdmvstra)
xi: svy,subpop(if subpop2==1 & male==1 & foodinsec==0): regress bmiz food_any ridageyr i.race_eth fpl_2cat i.hinsur pr_male i.pr_ed3 i.pr_age
```
### b Food insecure girls and boys
```{stata}
use "NHANES0708_all.dta"
svyset sdmvpsu [pw=wtmec2yr], strata(sdmvstra)
xi: svy,subpop(if subpop2==1 & male==0 & foodinsec==1): regress bmiz food_any ridageyr i.race_eth fpl_2cat i.hinsur pr_male i.pr_ed3 i.pr_age
```
```{stata}
use "NHANES0708_all.dta"
svyset sdmvpsu [pw=wtmec2yr], strata(sdmvstra)
xi: svy,subpop(if subpop2==1 & male==1 & foodinsec==1): regress bmiz food_any ridageyr i.race_eth fpl_2cat i.hinsur pr_male i.pr_ed3 i.pr_age
```
# B Interaction Analysis
## 1 Association between food assistance and BMI
Fit a model that tests for interactions between food security and food assistance, among boys.
```{stata}
use "NHANES0708_all.dta"
svyset sdmvpsu [pw=wtmec2yr], strata(sdmvstra)
xi: svy,subpop(if subpop2==1 & male==1): regress bmiz i.foodinsec*food_any ridageyr i.race_eth fpl_2cat i.hinsur pr_male i.pr_ed3 i.pr_age
```
## 2
Calculate food-security-specific associations between food assistance and BMI z-score among boys.
### d among food secure
```{stata}
use "NHANES0708_all.dta"
svyset sdmvpsu [pw=wtmec2yr], strata(sdmvstra)
xi: svy,subpop(if subpop2==1 & male==1): regress bmiz i.foodinsec*food_any ridageyr i.race_eth fpl_2cat i.hinsur pr_male i.pr_ed3 i.pr_ag
# Among food secure (long form)
lincom (1*food_any + 0*_Ifoodinsec_1 + 0*_IfooXfood__1) - (0*food_any + 0*_Ifoodinsec_1 + 0*_IfooXfood__1)
# Among food secure (reduced form)
lincom food_any
```
### e among food insecure
```{stata}
use "NHANES0708_all.dta"
svyset sdmvpsu [pw=wtmec2yr], strata(sdmvstra)
xi: svy,subpop(if subpop2==1 & male==1): regress bmiz i.foodinsec*food_any ridageyr i.race_eth fpl_2cat i.hinsur pr_male i.pr_ed3 i.pr_ag
# Among food insecure (long form)
lincom (1*food_any + 1*_Ifoodinsec_1 + 1*_IfooXfood__1) - (0*food_any + 1*_Ifoodinsec_1 + 0*_IfooXfood__1)
# Among food insecure (reduced form)
lincom food_any + _IfooXfood__1
```
# Bonus
Fit a single model that includes food secure and insecure boys and girls (the full sample). Include the full set of interaction terms. Calculate the gender and food security specific associations from the full set of interaction terms.
### among food secure girls
```{stata}
use "NHANES0708_all.dta"
svyset sdmvpsu [pw=wtmec2yr], strata(sdmvstra)
xi: svy,subpop(if subpop2==1): regress bmiz i.foodinsec*food_any i.foodinsec*i.male i.male*food_any ridageyr i.race_eth fpl_2cat i.hinsur pr_male i.pr_ed3 i.pr_ag
# Among food secure (long form)
lincom (1*food_any + 0*_Ifoodinsec_1 + 0*_Imale_1 + 0*_IfooXfood__1 + 0*_ImalXfood__1 + 0*_IfooXmal_1_1) - (0*food_any + 0*_Ifoodinsec_1 + 0*_Imale_1 + 0*_IfooXfood__1 + 0*_ImalXfood__1 + 0*_IfooXmal_1_1)
# Among food secure (reduced form)
lincom food_any
```
### among food insecure girls
```{stata}
use "NHANES0708_all.dta"
svyset sdmvpsu [pw=wtmec2yr], strata(sdmvstra)
xi: svy,subpop(if subpop2==1): regress bmiz i.foodinsec*food_any i.foodinsec*i.male i.male*food_any ridageyr i.race_eth fpl_2cat i.hinsur pr_male i.pr_ed3 i.pr_ag
# Among food secure (long form)
lincom (1*food_any + 1*_Ifoodinsec_1 + 0*_Imale_1 + 1*_IfooXfood__1 + 0*_ImalXfood__1 + 0*_IfooXmal_1_1) - (0*food_any + 1*_Ifoodinsec_1 + 0*_Imale_1 + 0*_IfooXfood__1 + 0*_ImalXfood__1 + 0*_IfooXmal_1_1)
# Among food secure (reduced form)
lincom food_any + _IfooXfood__1
```
### among food secure boys
```{stata}
use "NHANES0708_all.dta"
svyset sdmvpsu [pw=wtmec2yr], strata(sdmvstra)
xi: svy,subpop(if subpop2==1): regress bmiz i.foodinsec*food_any i.foodinsec*i.male i.male*food_any ridageyr i.race_eth fpl_2cat i.hinsur pr_male i.pr_ed3 i.pr_ag
# Among food secure (long form)
lincom (1*food_any + 0*_Ifoodinsec_1 + 1*_Imale_1 + 0*_IfooXfood__1 + 1*_ImalXfood__1 + 0*_IfooXmal_1_1) - (0*food_any + 0*_Ifoodinsec_1 + 1*_Imale_1 + 0*_IfooXfood__1 + 0*_ImalXfood__1 + 0*_IfooXmal_1_1)
# Among food secure (reduced form)
lincom food_any + _ImalXfood__1
```
### among food insecure boys
```{stata}
use "NHANES0708_all.dta"
svyset sdmvpsu [pw=wtmec2yr], strata(sdmvstra)
xi: svy,subpop(if subpop2==1): regress bmiz i.foodinsec*food_any i.foodinsec*i.male i.male*food_any ridageyr i.race_eth fpl_2cat i.hinsur pr_male i.pr_ed3 i.pr_ag
# Among food secure (long form)
lincom (1*food_any + 1*_Ifoodinsec_1 + 1*_Imale_1 + 1*_IfooXfood__1 + 1*_ImalXfood__1 + 1*_IfooXmal_1_1) - (0*food_any + 1*_Ifoodinsec_1 + 1*_Imale_1 + 0*_IfooXfood__1 + 0*_ImalXfood__1 + 1*_IfooXmal_1_1)
# Among food secure (reduced form)
lincom food_any + _IfooXfood__1 + _ImalXfood__1
```