You are on page 1of 19

The Impact of Fruit and Vegetable Consumption

and Physical Activity on Diabetes Risk among


Adults
Data to Paper

June 23, 2023

Abstract
Diabetes is a global health concern, and identifying modifiable risk
factors is essential for prevention. We investigated the association be-
tween fruit and vegetable consumption, physical activity, and the risk
of diabetes among adults. Using data from the Behavioral Risk Factor
Surveillance System (BRFSS) 2015 survey, logistic regression analysis
was conducted, controlling for age, sex, BMI, education, and income.
Our results show that higher fruit and vegetable consumption is asso-
ciated with a reduced risk of diabetes. Moreover, engaging in regular
physical activity strengthens this association. This study addresses a
gap in the literature by providing evidence on the protective effects of
fruit and vegetable consumption and physical activity in relation to
diabetes risk. However, limitations, such as self-reported data and po-
tential confounders, should be considered. Our findings highlight the
importance of promoting healthy lifestyle behaviors and have implica-
tions for diabetes prevention interventions among adults.

Introduction
Diabetes is a major global health concern, affecting nearly half a billion
people worldwide, with projections estimating an increase of 25% in 2030
and 51% in 2045 [1]. The increasing prevalence of diabetes poses both
an economic and a public health burden [2]. Identification of modifiable
risk factors, such as dietary habits and physical activity, is crucial for the
prevention and management of diabetes [3].
Previous research has demonstrated the beneficial impact of fruit and
vegetable consumption and regular physical activity on diabetes risk [4, 5],

1
focusing primarily on prevalent diabetes risk factors such as insulin resis-
tance, obesity, and cardiovascular health. However, there is limited evidence
on the combined effect of both fruit and vegetable consumption and physical
activity on diabetes risk.
In this study, we aim to fill this gap in the literature by examining the
relationship between fruit and vegetable consumption, physical activity, and
diabetes risk among adults using data from the CDC’s Behavioral Risk Fac-
tor Surveillance System (BRFSS) 2015 survey [6, 7]. This dataset provides
a large and diverse sample of American adults, allowing us to investigate the
association of these modifiable lifestyle factors with the risk of developing
diabetes.
To assess the impact of fruit and vegetable consumption and physical
activity on diabetes risk, we employed logistic regression analysis, control-
ling for potential confounding factors such as age, sex, BMI, education, and
income [8]. In addition to examining the independent effects of fruit and
vegetable consumption and physical activity on diabetes risk, we also an-
alyzed the interaction between these lifestyle factors to better understand
their potential synergistic effect on diabetes risk reduction.
With this comprehensive analysis of the BRFSS 2015 data, we provide
evidence on the protective effects of fruit and vegetable consumption and
physical activity on diabetes risk among adults. Our findings contribute
to the growing body of literature supporting the importance of promoting
healthy lifestyle behaviors for the prevention of diabetes and its complica-
tions.

Results
In this section, we present the results of our analysis on the association
between fruit and vegetable consumption, physical activity, and the risk of
diabetes among adults using data from the Behavioral Risk Factor Surveil-
lance System (BRFSS) 2015 survey.

Association between Fruit and Vegetable Consumption and Dia-


betes Risk
To understand the relationship between fruit and vegetable consumption
and diabetes risk, we conducted logistic regression analysis while controlling
for age, sex, BMI, education, and income (Table 1). Our findings reveal
that higher fruit and vegetable consumption is associated with a reduced
risk of diabetes (Coefficient = -0.181, p-value < 10−4 ). This suggests that

2
individuals who consume more fruits and vegetables have a lower probability
of developing diabetes.

Table 1: Association between fruit and vegetable consumption and diabetes


risk: Logistic regression results
Variable Coeff. Std. Err. p-value
Intercept −4.861 ±0.050 < 10−4
Fruit & Vegetable −0.181 ±0.012 < 10−4
Age (years) 0.211 ±0.002 < 10−4
Sex (Male) 0.329 ±0.013 < 10−4
BMI 0.085 ±0.001 < 10−4
Education −0.108 ±0.007 < 10−4
Income −0.147 ±0.003 < 10−4

Association between Physical Activity, Fruit and Vegetable Con-


sumption, and Diabetes Risk
To further explore the relationship between fruit and vegetable consump-
tion, physical activity, and diabetes risk, we performed a logistic regression
analysis controlling for age, sex, BMI, education, income, and physical ac-
tivity (Table 2). The results demonstrate that physical activity (Coefficient
= -0.211, p-value < 10−4 ) and fruit and vegetable consumption (Coefficient
= -0.052, p-value = 0.016) are independently associated with a reduced risk
of diabetes. Moreover, the interaction term between fruit and vegetable con-
sumption and physical activity is also statistically significant (Coefficient =
-0.143, p-value < 10−4 ). This indicates that the combined effect of engag-
ing in physical activity and consuming fruits and vegetables is even more
protective against diabetes.
The inclusion of physical activity and the interaction term in the logis-
tic regression model improves its predictive power, as indicated by a higher
pseudo R-squared value of 0.1263 compared to 0.1242 in the model without
the interaction term. These results provide insights into potential mecha-
nisms by which lifestyle interventions, such as increasing fruit and vegetable
consumption and engaging in physical activity, may contribute to reducing
the burden of diabetes among adults.
The negative correlation coefficient of -0.181 between fruit and vegetable
consumption and diabetes risk suggests that for every unit increase in fruit
and vegetable consumption, the odds of developing diabetes decrease by

3
Table 2: Interaction between fruit and vegetable consumption and physical
activity on diabetes risk: Logistic regression results
Variable Coeff. Std. Err. p-value
Intercept −4.719 ±0.051 < 10−4
Fruit & Vegetable −0.052 ±0.022 0.016
Physical Activity (Yes) −0.211 ±0.018 < 10−4
Fruit & Vegetable × Phys. Activity −0.143 ±0.026 < 10−4
Age (years) 0.208 ±0.002 < 10−4
Sex (Male) 0.339 ±0.013 < 10−4
BMI 0.083 ±0.001 < 10−4
Education −0.095 ±0.007 < 10−4
Income −0.141 ±0.003 < 10−4

0.181 units. Additionally, the pseudo R-squared value of 0.1242 for the
logistic regression model in Table 1 indicates that 12.42% of the variability
in diabetes risk can be explained by the included covariates.
It is important to acknowledge potential limitations associated with self-
reported data, including measurement errors and biases. Nevertheless, our
findings emphasize the significance of promoting fruit and vegetable intake
and regular physical activity as preventive measures for diabetes among
adults. These results have implications for public health interventions and
policies aimed at reducing the burden of diabetes in the adult population.
In summary, our analysis demonstrates that higher fruit and vegetable
consumption, along with engagement in regular physical activity, is associ-
ated with a reduced risk of diabetes among adults. These findings underscore
the importance of adopting healthy lifestyle behaviors and highlight the
potential benefits of targeted interventions to promote fruit and vegetable
consumption and physical activity in reducing the burden of diabetes.

Discussion
The subject of this study focused on the association between fruit and veg-
etable consumption, physical activity, and the risk of diabetes among adults.
Given the forecasted increase in diabetes prevalence, with estimates project-
ing a 25% increase in 2030 and 51% in 2045 [1], it is critical to identify modi-
fiable risk factors like dietary habits and physical activity for the prevention
and management of diabetes [3].

4
Table 3: Descriptive statistics of the dataset
Variable Mean Standard Deviation
Diabetes 0.139 0.346
High Blood Pressure 0.429 0.495
High Cholesterol 0.424 0.494
Cholesterol Check (Yes) 0.963 0.190
BMI 28.38 6.61
Smoker (Yes) 0.443 0.497
Stroke (Yes) 0.041 0.197
Heart Disease or Attack (Yes) 0.094 0.292
Physical Activity (Yes) 0.756 0.429
Fruits Consumption (Yes) 0.634 0.482
Vegetables Consumption (Yes) 0.811 0.391
Heavy Alcohol Consumption (Yes) 0.056 0.230
Healthcare Coverage (Yes) 0.951 0.216
No Doctor due to Cost (Yes) 0.084 0.278
General Health (1∼5 scale) 2.51 1.07
Mental Health (1∼30 days) 3.19 7.41
Physical Health (1∼30 days) 4.24 8.72
Difficulty Walking (Yes) 0.168 0.374
Sex (Male) 0.440 0.497
Age (18∼80+ years) 8.03 3.05
Education (1∼6 scale) 5.05 0.986
Income (1∼8 scale) 6.05 2.07

5
In examining the association between fruit and vegetable consumption,
physical activity, and diabetes risk, our methodology involved logistic re-
gression analysis using data from the Behavioral Risk Factor Surveillance
System (BRFSS) 2015 survey, controlling for potential confounding factors
such as age, sex, BMI, education, and income. Our findings reveal that a
higher intake of fruits and vegetables, coupled with regular physical activity,
resulted in a reduced risk of diabetes. These results align with previous re-
search that highlighted the benefits of fruit and vegetable consumption and
physical activity on diabetes risk [5, 9, 10].
However, our study has some limitations that should be taken into con-
sideration. Our findings were based on self-reported data, which may be
prone to errors and biases in measurement. Moreover, there is a possibil-
ity that unmeasured or residual confounding factors could have influenced
the observed associations. Additionally, as this study utilized cross-sectional
data, we caution against inferring any causal relationships between fruit and
vegetable consumption, physical activity, and diabetes risk.
In conclusion, our study provides evidence that higher fruit and vegetable
consumption and regular physical activity are associated with a reduced risk
of diabetes among adults. These findings support the importance of pro-
moting healthy lifestyle behaviors for diabetes prevention and management.
While the results highlight the potential of fruit and vegetable consump-
tion and regular physical exercise in reducing diabetes risk, future research
should investigate the potential causal relationships and further evaluate the
long-term effects of these lifestyle interventions in larger and more diverse
populations. Moreover, longitudinal and experimental studies could help
elucidate the mechanisms through which fruit and vegetable intake, physical
activity, and diabetes interact, ultimately contributing to the development
of more effective preventive measures and public health policies.

Methods
Data Source
The data for this study was obtained from the CDC’s Behavioral Risk Factor
Surveillance System (BRFSS), specifically from the year 2015 survey. The
BRFSS is an annual health-related telephone survey that collects informa-
tion on health-related risk behaviors, chronic health conditions, and the use
of preventative services from over 400,000 Americans. The dataset used for
this study consists of 253,680 responses with 22 features, including diabetes
status, fruit and vegetable consumption, physical activity level, and demo-

6
graphic variables. The dataset was provided as a comma-separated values
(CSV) file.

Data Preprocessing
The pre-processing of the data was performed using Python programming
language. First, missing values were removed from the original dataset, re-
sulting in a clean dataset of 253,680 responses. This step ensures that the
subsequent analysis is conducted on complete data. Next, a new variable
called ”FruitVeg” was created by combining the ”Fruits” and ”Veggies” vari-
ables using a logical AND operation. This new variable represents whether
an individual consumes at least one fruit and one vegetable each day. These
pre-processing steps were performed using the pandas library in Python.

Data Analysis
To examine the association between fruit and vegetable consumption, physi-
cal activity, and the risk of diabetes among adults, logistic regression analysis
was conducted using the statsmodels library in Python. In the first anal-
ysis step, a logistic regression model was fitted with the ”Diabetes binary”
variable as the dependent variable and ”FruitVeg,” ”Age,” ”Sex,” ”BMI,”
”Education,” and ”Income” as independent variables. This analysis aimed
to determine the association between fruit and vegetable consumption and
the risk of diabetes, while controlling for demographic and health-related
factors.
In the second analysis step, an interaction term between fruit and veg-
etable consumption (”FruitVeg”) and physical activity level (”PhysActiv-
ity”) was introduced in the logistic regression model. The model included
the main effects of ”FruitVeg” and ”PhysActivity,” as well as the interaction
term ”FruitVeg PhysActivity.” This analysis aimed to investigate whether
the association between fruit and vegetable consumption and diabetes risk
is modified by physical activity level.
The results of the logistic regression analyses, including odds ratios and
corresponding p-values, were obtained from the fitted models. Additionally,
descriptive statistics for the dataset were calculated using the pandas li-
brary. The results were written to a text file named ”results.txt” for further
examination and reporting.
These analysis steps provide insights into the association between fruit
and vegetable consumption, physical activity, and the risk of diabetes among
adults, while controlling for potential confounding factors.

7
Code Availability
Custom code used to perform the data preprocessing and analysis, as well
as the raw code output outputs, are provided in Supplementary Methods.

References
[1] Pouya Saeedi, Inga Petersohn, P. Salpea, B. Malanda, S. Karuranga,
N. Unwin, S. Colagiuri, L. Guariguata, A. Motala, K. Ogurtsova,
J. Shaw, D. Bright, and Rhys Williams. Global and regional diabetes
prevalence estimates for 2019 and projections for 2030 and 2045: Re-
sults from the international diabetes federation diabetes atlas, 9 th
edition. 2019.

[2] S. Wild, G. Roglić, A. Green, R. Sicree, and H. King. Global preva-


lence of diabetes: estimates for the year 2000 and projections for 2030.
Diabetes care, 27 5:1047–53, 2004.

[3] A. Uloko, B. Musa, M. Ramalan, I. Gezawa, F. Puepet, A. Uloko,


M. Borodo, and K. Sada. Prevalence and risk factors for diabetes mel-
litus in nigeria: A systematic review and meta-analysis. Diabetes Ther-
apy, 9:1307 – 1316, 2018.

[4] Xiao-Hua Li, Fei fei Yu, Yu hao Zhou, and Jia He. Association between
alcohol consumption and the risk of incident type 2 diabetes: a system-
atic review and dose-response meta-analysis. The American journal of
clinical nutrition, 103 3:818–29, 2016.

[5] A. Herbst, O. Kordonouri, K. Schwab, , F. Schmidt, and R. Holl. Im-


pact of physical activity on cardiovascular risk factors in children with
type 1 diabetes. Diabetes Care, 30:2098 – 2100, 2007.

[6] S. Flores-Hernández, P. Saturno-Hernández, H. Reyes-Morales,


T. Barrientos-Gutiérrez, S. Villalpando, and M. Hernández-Ávila.
Quality of diabetes care: The challenges of an increasing epidemic in
mexico. results from two national health surveys (2006 and 2012). PLoS
ONE, 10, 2015.

[7] R. Iachan, Carol A. Pierannunzi, Kristie Healey, K. Greenlund, and


M. Town. National weighting of data from the behavioral risk factor
surveillance system (brfss). BMC Medical Research Methodology, 16,
2016.

8
[8] A. Gomes-Neto, M. Osté, Camilo G. Sotomayor, Else v.d. Berg,
J. Geleijnse, R. Gans, S. Bakker, and G. Navis. Fruit and vegetable
intake and risk of posttransplantation diabetes in renal transplant re-
cipients. Diabetes Care, 42:1645 – 1652, 2019.

[9] M. Carlström and S. Larsson. Coffee consumption and reduced risk


of developing type 2 diabetes: a systematic review with meta-analysis.
Nutrition Reviews, 76:395–417, 2018.

[10] Jean-Philippe Drouin-Chartier, D. Brassard, Maude Tessier-Grenier,


J. Côté, M. Labonté, S. Desroches, P. Couture, and B. Lamarche. Sys-
tematic review of the association between dairy product consumption
and risk of cardiovascular-related clinical outcomes123. Advances in
Nutrition, 7:1026 – 1040, 2016.

9
Data Description
Here is the data description, as provided by the user:
The dataset includes diabetes related factors extracted from the CDC’s
Behavioral Risk Factor Surveillance System (BRFSS), year 2015.
The original BRFSS, from which this dataset is derived, is a health-related
telephone survey that is collected annually by the CDC.
Each year, the survey collects responses from over 400,000 Americans on health-
related risk behaviors, chronic health conditions, and the use of preventative
services. These features are either questions directly asked of participants, or
calculated variables based on individual participant responses.

1 data file:

"diabetes_binary_health_indicators_BRFSS2015.csv"
The csv file is a clean dataset of 253,680 responses (rows) and 22 features
(columns).
All rows with missing values were removed from the original dataset; the current
file contains no missing values.

The columns in the dataset are:

#1 ‘Diabetes_binary‘: (int, bool) Diabetes (0=no, 1=yes)


#2 ‘HighBP‘: (int, bool) High Blood Pressure (0=no, 1=yes)
#3 ‘HighChol‘: (int, bool) High Cholesterol (0=no, 1=yes)
#4 ‘CholCheck‘: (int, bool) Cholesterol check in 5 years (0=no, 1=yes)
#5 ‘BMI‘: (int, numerical) Body Mass Index
#6 ‘Smoker‘: (int, bool) (0=no, 1=yes)
#7 ‘Stroke‘: (int, bool) Stroke (0=no, 1=yes)
#8 ‘HeartDiseaseorAttack’: (int, bool) coronary heart disease (CHD) or
myocardial infarction (MI), (0=no, 1=yes)
#9 ‘PhysActivity‘: (int, bool) Physical Activity in past 30 days (0=no, 1=yes)
#10 ‘Fruits‘: (int, bool) Consume one fruit or more each day (0=no, 1=yes)
#11 ‘Veggies‘: (int, bool) Consume one Vegetable or more each day (0=no, 1=yes)
#12 ‘HvyAlcoholConsump‘ (int, bool) Heavy drinkers (0=no, 1=yes)
#13 ‘AnyHealthcare‘ (int, bool) Have any kind of health care coverage (0=no,
1=yes)
#14 ‘NoDocbcCost‘ (int, bool) Was there a time in the past 12 months when you
needed to see a doctor but could not because of cost? (0=no, 1=yes)
#15 ‘GenHlth‘ (int, ordinal) self-reported health (1=excellent, 2=very good,
3=good, 4=fair, 5=poor)
#16 ‘MentHlth‘ (int, ordinal) How many days during the past 30 days was your
mental health not good? (1-30 days)
#17 ‘PhysHlth‘ (int, ordinal) Hor how many days during the past 30 days was your
physical health not good? (1-30 days)
#18 ‘DiffWalk‘ (int, bool) Do you have serious difficulty walking or climbing
stairs? (0=no, 1=yes)

10
#19 ‘Sex‘ (int, categorical) Sex (0=female, 1=male)
#20 ‘Age‘ (int, ordinal) Age, 13-level age category in intervals of 5 years
(1=18-24, 2=25-29, ..., 12=75-79, 13=80 or older)
#21 ‘Education‘ (int, ordinal) Education level on a scale of 1-6 (1=Never
attended school, 2=Elementary, 3=Some high school, 4=High school, 5=Some
college, 6=College)
#22 ‘Income‘ (int, ordinal) Income scale on a scale of 1-8 (1=<=10K, 2=<=15K,
3=<=20K, 4=<=25K, 5=<=35K, 6=<=50K, 7=<=75K, 8=>75K)

Data Exploration
Code
The Data Exploration was carried out using the following custom code:

1 import pandas as pd
2
3 # Read the CSV file
4 df = pd.read_csv("diabetes_binary_health_indicators_BRFSS2015.csv")
5
6 # Create an empty string to store the data exploration summary
7 summary = ""
8
9 # Measure of the scale of the data
10 num_rows = len(df)
11 num_columns = len(df.columns)
12 summary += f"Number of rows: {num_rows}\n"
13 summary += f"Number of columns: {num_columns}\n\n"
14
15 # Summary statistics of key variables
16 summary += "Summary Statistics:\n"
17 summary += df.describe().to_string() + "\n\n"
18
19 # List of most common values of categorical variables
20 summary += "Most Common Values:\n"
21 categorical_columns = ["Diabetes_binary", "HighBP", "HighChol", \
22 "CholCheck", "Smoker", "Stroke", "HeartDiseaseorAttack",
23 "PhysActivity", "Fruits", "Veggies", \
24 "HvyAlcoholConsump", "AnyHealthcare", "NoDocbcCost",
25 "GenHlth", "DiffWalk", "Sex", "Age", \
26 "Education", "Income"]
27 for col in categorical_columns:
28 common_values = df[col].value_counts().head(5)
29 summary += f"{col}: {common_values}\n"
30 summary += "\n"
31

11
32 # Counts of missing values
33 missing_values = df.isnull().sum()
34 summary += "Counts of Missing Values:\n"
35 summary += missing_values.to_string() + "\n"
36
37 # Write the summary to a text file
38 with open("data_exploration.txt", "w") as file:
39 file.write(summary)

Code Description
The provided code is used for data exploration of the given dataset. It
performs various operations to summarize and analyze the data.
First, the code reads the dataset from a CSV file using the pandas library.
The dataset contains information related to diabetes and various health
indicators.
The code then creates an empty string called ”summary” to store the
data exploration summary.
Next, it calculates some key statistics about the dataset, including the
number of rows and columns, and appends this information to the summary
string.
After that, it generates summary statistics for the dataset using the
describe() function in pandas. This includes measures like mean, standard
deviation, minimum, maximum, etc., for numerical variables in the dataset.
The summary statistics are then appended to the summary string.
The code then identifies the most common values for each categorical
variable in the dataset. It iterates through a predefined list of categorical
columns and uses the value counts() function to count the occurrences of
each value. The top 5 most common values for each categorical column are
then appended to the summary string.
Next, the code counts the number of missing values in the dataset using
the isnull() function and the sum() function. The counts of missing values
for each variable are appended to the summary string.
Finally, the code writes the generated summary string to a text file called
”data exploration.txt” using the open() function and the write() method.
The ”data exploration.txt” file contains a summary of the dataset explo-
ration. This includes the number of rows and columns, summary statistics
for numerical variables, most common values for categorical variables, and
counts of missing values for each variable. The file can be used for further
analysis and documentation of the dataset.

12
Code Output
Number of rows: 253680
Number of columns: 22

Summary Statistics:
count mean std
Diabetes_binary 253680 0.1393 0.3463
HighBP 253680 0.429 0.4949
HighChol 253680 0.4241 0.4942
CholCheck 253680 0.9627 0.1896
BMI 253680 28.38 6.609
Smoker 253680 0.4432 0.4968
Stroke 253680 0.04057 0.1973
HeartDiseaseorAttack 253680 0.09419 0.2921
PhysActivity 253680 0.7565 0.4292
Fruits 253680 0.6343 0.4816
Veggies 253680 0.8114 0.3912
HvyAlcoholConsump 253680 0.0562 0.2303
AnyHealthcare 253680 0.9511 0.2158
NoDocbcCost 253680 0.08418 0.2777
GenHlth 253680 2.511 1.068
MentHlth 253680 3.185 7.413
PhysHlth 253680 4.242 8.718
DiffWalk 253680 0.1682 0.3741
Sex 253680 0.4403 0.4964
Age 253680 8.032 3.054
Education 253680 5.05 0.9858
Income 253680 6.054 2.071

Most Common Values:


Diabetes_binary: 0 218334
1 35346
Name: Diabetes_binary, dtype: int64
HighBP: 0 144851
1 108829
Name: HighBP, dtype: int64
HighChol: 0 146089
1 107591
Name: HighChol, dtype: int64
CholCheck: 1 244210
0 9470
Name: CholCheck, dtype: int64
Smoker: 0 141257
1 112423
Name: Smoker, dtype: int64
Stroke: 0 243388
1 10292
Name: Stroke, dtype: int64

13
HeartDiseaseorAttack: 0 229787
1 23893
Name: HeartDiseaseorAttack, dtype: int64
PhysActivity: 1 191920
0 61760
Name: PhysActivity, dtype: int64
Fruits: 1 160898
0 92782
Name: Fruits, dtype: int64
Veggies: 1 205841
0 47839
Name: Veggies, dtype: int64
HvyAlcoholConsump: 0 239424
1 14256
Name: HvyAlcoholConsump, dtype: int64
AnyHealthcare: 1 241263
0 12417
Name: AnyHealthcare, dtype: int64
NoDocbcCost: 0 232326
1 21354
Name: NoDocbcCost, dtype: int64
GenHlth: 2 89084
3 75646
1 45299
4 31570
5 12081
Name: GenHlth, dtype: int64
DiffWalk: 0 211005
1 42675
Name: DiffWalk, dtype: int64
Sex: 0 141974
1 111706
Name: Sex, dtype: int64
Age: 9 33244
10 32194
8 30832
7 26314
11 23533
Name: Age, dtype: int64
Education: 6 107325
5 69910
4 62750
3 9478
2 4043
Name: Education, dtype: int64
Income: 8 90385
7 43219
6 36470
5 25883

14
4 20135
Name: Income, dtype: int64

Counts of Missing Values:


Diabetes_binary 0
HighBP 0
HighChol 0
CholCheck 0
BMI 0
Smoker 0
Stroke 0
HeartDiseaseorAttack 0
PhysActivity 0
Fruits 0
Veggies 0
HvyAlcoholConsump 0
AnyHealthcare 0
NoDocbcCost 0
GenHlth 0
MentHlth 0
PhysHlth 0
DiffWalk 0
Sex 0
Age 0
Education 0
Income 0

Data Analysis
Code
The Data Analysis was carried out using the following custom code:

1 import pandas as pd
2 import numpy as np
3 import statsmodels.api as sm
4 import statsmodels.formula.api as smf
5 from typing import Dict, Any
6 from sklearn.preprocessing import StandardScaler
7
8 # Load the data
9 data = pd.read_csv("diabetes_binary_health_indicators_BRFSS2015.csv")
10 data[’FruitVeg’] = data[’Fruits’] & data[’Veggies’]
11
12 # Calculate descriptive statistics for Table 1
13 summary_table = data.describe()
14

15
15 # Perform logistic regression to test the association between
16 # fruit/veg consumption and diabetes risk
17 model1 = smf.logit("Diabetes_binary ~ FruitVeg + Age + Sex + BMI + \
18 Education + Income", data=data).fit()
19 table2 = model1.summary()
20
21 # Add interaction term with physical activity and fit the logistic
22 # regression model
23 data["FruitVeg_PhysActivity"] = data["FruitVeg"] * \
24 data["PhysActivity"]
25
26 model2 = smf.logit("Diabetes_binary ~ FruitVeg + PhysActivity + \
27 FruitVeg_PhysActivity + Age + Sex + BMI + Education + Income", \
28 data=data).fit()
29 table3 = model2.summary()
30
31 # Create a dictionary with other numerical results
32 results_dict = {
33 ’Total number of observations’: len(data),
34 ’Correlation between fruit/veg consumption and diabetes risk’: \
35 model1.params[’FruitVeg’],
36 ’Mean of BMI’: data[’BMI’].mean(),
37 }
38
39 # Write the results to a text file named "results.txt"
40 with open("results.txt", "w") as file:
41 file.write("Results for Table 1:\n")
42 file.write(summary_table.to_string())
43 file.write("\n\nResults for Table 2:\n")
44 file.write(table2.as_text())
45 file.write("\n\nResults for Table 3:\n")
46 file.write(table3.as_text())
47 file.write("\n\nOther numerical results:\n")
48 for key, value in results_dict.items():
49 file.write(f"{key}: {value}\n")

Code Description
The code performs data analysis on a dataset of diabetes-related factors ex-
tracted from the CDC’s Behavioral Risk Factor Surveillance System (BRFSS)
for the year 2015. The dataset contains information on various health indi-
cators such as diabetes status, high blood pressure, high cholesterol, body
mass index, lifestyle factors, and demographic variables.
The code first loads the dataset into a pandas DataFrame. It then cal-
culates descriptive statistics for Table 1, including measures such as count,
mean, standard deviation, minimum, and maximum for each column in the

16
dataset. These statistics provide an overview of the dataset and help under-
stand the distribution of variables.
Next, the code conducts logistic regression analysis to examine the as-
sociation between fruit and vegetable consumption and the risk of diabetes.
The model includes variables such as fruit and vegetable consumption, age,
sex, body mass index (BMI), education level, and income. The logistic
regression analysis estimates the coefficients and p-values for each variable,
indicating the strength and significance of the association with diabetes risk.
The results of the regression analysis are displayed in Table 2.
In the next step, the code adds an interaction term between fruit/veg
consumption and physical activity. It then fits another logistic regression
model that includes this interaction term along with the previously men-
tioned variables. This model allows for testing if the association between
fruit/veg consumption and diabetes varies based on the level of physical ac-
tivity. The results of this extended logistic regression analysis are presented
in Table 3.
Additionally, the code calculates other numerical results, such as the
total number of observations, the correlation between fruit/veg consumption
and diabetes risk, and the mean of the BMI variable. These results are stored
in a dictionary.
Finally, the code writes all the results, including the summary statistics
for Table 1, the regression results for Tables 2 and 3, and the other numerical
results, into a text file named ”results.txt”. Each result is printed in a
formatted manner, providing a comprehensive summary of the findings.
In summary, this code performs data analysis on a dataset of diabetes-
related factors, including descriptive statistics and logistic regression analy-
ses, to explore the relationship between fruit/veg consumption and the risk
of diabetes. The results are then written to a text file for further examina-
tion and reporting.

Code Output
Results for Table 1:
count mean std
Diabetes_binary 253680 0.1393 0.3463
HighBP 253680 0.429 0.4949
HighChol 253680 0.4241 0.4942
CholCheck 253680 0.9627 0.1896
BMI 253680 28.38 6.609
Smoker 253680 0.4432 0.4968
Stroke 253680 0.04057 0.1973
HeartDiseaseorAttack 253680 0.09419 0.2921

17
PhysActivity 253680 0.7565 0.4292
Fruits 253680 0.6343 0.4816
Veggies 253680 0.8114 0.3912
HvyAlcoholConsump 253680 0.0562 0.2303
AnyHealthcare 253680 0.9511 0.2158
NoDocbcCost 253680 0.08418 0.2777
GenHlth 253680 2.511 1.068
MentHlth 253680 3.185 7.413
PhysHlth 253680 4.242 8.718
DiffWalk 253680 0.1682 0.3741
Sex 253680 0.4403 0.4964
Age 253680 8.032 3.054
Education 253680 5.05 0.9858
Income 253680 6.054 2.071
FruitVeg 253680 0.5626 0.4961

Results for Table 2:


Logit Regression Results
==============================================================================
Dep. Variable: Diabetes_binary No. Observations: 253680
Model: Logit Df Residuals: 253673
Method: MLE Df Model: 6
Date: Fri, 23 Jun 2023 Pseudo R-squ.: 0.1242
Time: 18:28:23 Log-Likelihood: -89707.
converged: True LL-Null: -1.0242e+05
Covariance Type: nonrobust LLR p-value: 0.000
==============================================================================
coef std err z P>|z| [0.025 0.975]
------------------------------------------------------------------------------
Intercept -4.8608 0.050 -96.706 0.000 -4.959 -4.762
FruitVeg -0.1811 0.012 -14.572 0.000 -0.205 -0.157
Age 0.2112 0.002 89.164 0.000 0.207 0.216
Sex 0.3287 0.013 26.267 0.000 0.304 0.353
BMI 0.0852 0.001 97.707 0.000 0.083 0.087
Education -0.1079 0.007 -16.469 0.000 -0.121 -0.095
Income -0.1466 0.003 -46.323 0.000 -0.153 -0.140
==============================================================================

Results for Table 3:


Logit Regression Results
==============================================================================
Dep. Variable: Diabetes_binary No. Observations: 253680
Model: Logit Df Residuals: 253671
Method: MLE Df Model: 8
Date: Fri, 23 Jun 2023 Pseudo R-squ.: 0.1263
Time: 18:28:24 Log-Likelihood: -89485.
converged: True LL-Null: -1.0242e+05
Covariance Type: nonrobust LLR p-value: 0.000
================================================================================

18
=========
coef std err z P>|z| [0.025
0.975]
--------------------------------------------------------------------------------
---------
Intercept -4.7193 0.051 -92.094 0.000 -4.820
-4.619
FruitVeg -0.0516 0.022 -2.400 0.016 -0.094
-0.009
PhysActivity -0.2109 0.018 -11.761 0.000 -0.246
-0.176
FruitVeg_PhysActivity -0.1426 0.026 -5.447 0.000 -0.194
-0.091
Age 0.2075 0.002 87.402 0.000 0.203
0.212
Sex 0.3390 0.013 27.027 0.000 0.314
0.364
BMI 0.0828 0.001 94.559 0.000 0.081
0.084
Education -0.0950 0.007 -14.412 0.000 -0.108
-0.082
Income -0.1409 0.003 -44.350 0.000 -0.147
-0.135
================================================================================
=========

Other numerical results:


Total number of observations: 253680
Correlation between fruit/veg consumption and diabetes risk:
-0.18113600236572014
Mean of BMI: 28.382363607694735

19

You might also like