Getting Started:

# Start Session
rm(list = ls())
gc()
##          used (Mb) gc trigger (Mb) max used (Mb)
## Ncells 544108 29.1    1211364 64.7   686460 36.7
## Vcells 994401  7.6    8388608 64.0  1876788 14.4
# Load Packages
library(readxl)
library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(sf)
## Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.3.1; sf_use_s2() is TRUE
library(sp)
library(tidyr)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats   1.0.0     ✔ readr     2.1.5
## ✔ lubridate 1.9.3     ✔ stringr   1.5.1
## ✔ purrr     1.0.2     ✔ tibble    3.2.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(descr) 
library(leaflet)
library(ggthemes)
library(writexl)
library(readr)
library(haven)
library(leaflet)
library(knitr)
library(car)  # For VIF
## Warning: package 'car' was built under R version 4.4.3
## Loading required package: carData
## Warning: package 'carData' was built under R version 4.4.3
## 
## Attaching package: 'car'
## 
## The following object is masked from 'package:purrr':
## 
##     some
## 
## The following object is masked from 'package:dplyr':
## 
##     recode
library(MASS) # For AIC and BIC
## Warning: package 'MASS' was built under R version 4.4.3
## 
## Attaching package: 'MASS'
## 
## The following object is masked from 'package:dplyr':
## 
##     select
library(lmtest) # For Likelihood Ratio Test
## Warning: package 'lmtest' was built under R version 4.4.3
## Loading required package: zoo
## Warning: package 'zoo' was built under R version 4.4.3
## 
## Attaching package: 'zoo'
## 
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric

Reading Assignment:

Including interaction terms in logit regression models presents several challenges that can lead to misinterpretation if not properly addressed. Unlike in linear models, where interaction effects are straightforward, the interaction coefficient in a logit model does not directly represent the marginal effect of the interaction term. Instead, the actual interaction effect depends on all other covariates in the model and can even have the opposite sign of the coefficient itself. This means that standard statistical software often reports misleading results, as it calculates only the marginal effect of the interaction term rather than the true interaction effect on the probability scale. Additionally, the statistical significance of interaction terms cannot be determined using simple t-tests because the effect varies across observations. Since interaction effects in nonlinear models follow an S-shaped pattern, their impact is strongest for some predicted probability ranges (such as around 0.5) and weakest at extreme values close to 0 or 1. Consequently, failing to account for these complexities can lead to incorrect conclusions about the relationship between interacting variables.

A simulation-based approach offers a more accurate and intuitive way to interpret interaction effects in logit models. Instead of relying on raw coefficients, simulations calculate differences in predicted probabilities associated with changes in key independent variables. This approach allows researchers to visualize the interaction effect across different values of the covariates, revealing nonlinearities and variations in statistical significance. Furthermore, simulations generate confidence intervals for interaction effects, providing a more precise measure of uncertainty than traditional methods. By incorporating estimation uncertainty, the simulation-based approach ensures that results are robust and correctly interpreted. It also translates complex statistical outputs into meaningful, real-world interpretations, making findings more accessible to researchers and policymakers. Overall, using simulations to analyze interaction effects in logit models, as recommended by Ai and Norton (2003), Zelner (2009), and King et al. (2000), improves accuracy, enhances visualization, and facilitates clearer communication of statistical relationships.

Citations:

Ai, C., Norton, E. C., University of Florida, & Department of Health Policy and Administration, University of North Carolina. (2003). Interaction terms in logit and probit models. In Economics Letters (Vol. 80, pp. 123–129). Elsevier Science B.V.

King, G., Tomz, M., Wittenberg, J., & Harvard University. (2000). Making the most of statistical analyses: improving interpretation and presentation. In Midwest Political Science Association, American Journal of Political Science (Vol. 44, Issue 2, pp. 341–355).

Zelner, B. A. (2009). Using simulation to interpret results from logit, probit, and other nonlinear models. Strategic Management Journal, 30(12), 1335–1348. https://doi.org/10.1002/smj.783

Data Analysis Assignment

The dataset used for this analysis comes from the National Health and Nutrition Examination Survey (NHANES), specifically from the August 2021–August 2023 data collection cycle. NHANES is a nationally representative survey conducted by the Centers for Disease Control and Prevention (CDC), designed to assess the health and nutritional status of adults and children in the United States. It combines interviews, physical examinations, and laboratory tests to provide comprehensive health-related data. The NHANES dataset is widely used in public health research to examine relationships between demographic, socioeconomic, behavioral, and health outcomes.

For this analysis, we used three specific NHANES data files:

  1. ALQ_L (Alcohol Use Data) – Contains self-reported responses about alcohol consumption habits, including whether an individual has ever consumed alcohol (ALQ111), how frequently they drink, and binge drinking patterns​.

  2. INQ_L (Income Data) – Provides information about family income levels, including the income-to-poverty ratio (INDFMPIR), which helps classify participants based on economic status.

  3. DEMO_L (Demographics Data) – Includes key demographic variables such as age (RIDAGEYR), gender (RIAGENDR), race/ethnicity, marital status, and education level​.

These datasets were merged using the SEQN (Respondent Sequence Number), a unique identifier for each participant. The goal of this analysis was to investigate how demographic and socioeconomic factors influence the likelihood of an individual having ever consumed alcohol, using logistic regression modeling.

# NHANES August 2021 – August 2023 Dataset
Demo <- read_xlsx("DEMO_L.xlsx")
## New names:
## • `` -> `...1`
Income <- read_xlsx("INQ_L.xlsx")
## New names:
## • `` -> `...1`
Alcohol <- read_xlsx("ALQ_L.xlsx")
## New names:
## • `` -> `...1`
# Variable names
names(c(Demo, Income, Alcohol))
##  [1] "...1"     "SEQN"     "SDDSRVYR" "RIDSTATR" "RIAGENDR" "RIDAGEYR"
##  [7] "RIDAGEMN" "RIDRETH1" "RIDRETH3" "RIDEXMON" "RIDEXAGM" "DMQMILIZ"
## [13] "DMDBORN4" "DMDYRUSR" "DMDEDUC2" "DMDMARTZ" "RIDEXPRG" "DMDHHSIZ"
## [19] "DMDHRGND" "DMDHRAGZ" "DMDHREDZ" "DMDHRMAZ" "DMDHSEDZ" "WTINT2YR"
## [25] "WTMEC2YR" "SDMVSTRA" "SDMVPSU"  "INDFMPIR" "...1"     "SEQN"    
## [31] "INDFMMPI" "INDFMMPC" "INQ300"   "IND310"   "...1"     "SEQN"    
## [37] "ALQ111"   "ALQ121"   "ALQ130"   "ALQ142"   "ALQ270"   "ALQ280"  
## [43] "ALQ151"   "ALQ170"
# Merging datasets on SEQN (Respondent ID)
data <- Alcohol %>%
  inner_join(Income, by = "SEQN") %>%
  inner_join(Demo, by = "SEQN")

# Printing column names to check for exact matches
print(colnames(data))
##  [1] "...1.x"   "SEQN"     "ALQ111"   "ALQ121"   "ALQ130"   "ALQ142"  
##  [7] "ALQ270"   "ALQ280"   "ALQ151"   "ALQ170"   "...1.y"   "INDFMMPI"
## [13] "INDFMMPC" "INQ300"   "IND310"   "...1"     "SDDSRVYR" "RIDSTATR"
## [19] "RIAGENDR" "RIDAGEYR" "RIDAGEMN" "RIDRETH1" "RIDRETH3" "RIDEXMON"
## [25] "RIDEXAGM" "DMQMILIZ" "DMDBORN4" "DMDYRUSR" "DMDEDUC2" "DMDMARTZ"
## [31] "RIDEXPRG" "DMDHHSIZ" "DMDHRGND" "DMDHRAGZ" "DMDHREDZ" "DMDHRMAZ"
## [37] "DMDHSEDZ" "WTINT2YR" "WTMEC2YR" "SDMVSTRA" "SDMVPSU"  "INDFMPIR"
# Ensuring that the correct column names are used in select()
selected_columns <- c("ALQ111", "RIAGENDR", "RIDAGEYR", "INDFMPIR")

# Checking if all selected columns exist in the dataset
missing_cols <- setdiff(selected_columns, colnames(data))
if (length(missing_cols) > 0) {
  stop(paste("Missing columns in dataset:", paste(missing_cols, collapse = ", ")))
}

# Recode ALQ111 (Ever had a drink of any kind of alcohol)
data <- data %>%
  mutate(ALQ111 = ifelse(ALQ111 == 2, 0, 1))  # Recode No (2) as 0

# Selecting only relevant independent variables manually
data <- data[, selected_columns] %>% na.omit()  # Remove missing values

# Converting categorical variables to factors
data$RIAGENDR <- as.factor(data$RIAGENDR)
# Model 1: Simple Logistic Regression with Gender
model1 <- glm(ALQ111 ~ RIAGENDR, data = data, family = binomial)

# Model 2: Add Age
model2 <- glm(ALQ111 ~ RIAGENDR + RIDAGEYR, data = data, family = binomial)

# Model 3: Add Income (Full Model)
model3 <- glm(ALQ111 ~ RIAGENDR + RIDAGEYR + INDFMPIR, data = data, family = binomial)

# Model Comparison
summary(model1)
## 
## Call:
## glm(formula = ALQ111 ~ RIAGENDR, family = binomial, data = data)
## 
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  2.43118    0.06863  35.426   <2e-16 ***
## RIAGENDR2   -0.16535    0.08992  -1.839   0.0659 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 3777.0  on 6336  degrees of freedom
## Residual deviance: 3773.6  on 6335  degrees of freedom
## AIC: 3777.6
## 
## Number of Fisher Scoring iterations: 5
summary(model2)
## 
## Call:
## glm(formula = ALQ111 ~ RIAGENDR + RIDAGEYR, family = binomial, 
##     data = data)
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  2.091681   0.139676  14.975  < 2e-16 ***
## RIAGENDR2   -0.163671   0.089971  -1.819  0.06889 .  
## RIDAGEYR     0.006585   0.002404   2.739  0.00616 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 3777.0  on 6336  degrees of freedom
## Residual deviance: 3766.1  on 6334  degrees of freedom
## AIC: 3772.1
## 
## Number of Fisher Scoring iterations: 5
summary(model3)
## 
## Call:
## glm(formula = ALQ111 ~ RIAGENDR + RIDAGEYR + INDFMPIR, family = binomial, 
##     data = data)
## 
## Coefficients:
##                                 Estimate Std. Error z value Pr(>|z|)    
## (Intercept)                    1.832e+00  4.241e-01   4.319 1.57e-05 ***
## RIAGENDR2                     -1.644e-01  9.703e-02  -1.695   0.0902 .  
## RIDAGEYR                       4.431e-03  2.642e-03   1.677   0.0936 .  
## INDFMPIR0.01                  -5.093e-01  1.190e+00  -0.428   0.6688    
## INDFMPIR0.02                  -4.122e-01  8.808e-01  -0.468   0.6398    
## INDFMPIR0.03                  -1.359e+00  7.469e-01  -1.820   0.0687 .  
## INDFMPIR0.04                   2.897e-01  1.130e+00   0.256   0.7976    
## INDFMPIR0.05                  -8.502e-01  7.817e-01  -1.088   0.2768    
## INDFMPIR0.06                  -5.715e-01  1.190e+00  -0.480   0.6310    
## INDFMPIR0.08                   1.760e+01  5.368e+03   0.003   0.9974    
## INDFMPIR0.09                   1.757e+01  5.371e+03   0.003   0.9974    
## INDFMPIR0.1                   -1.323e+00  8.158e-01  -1.621   0.1050    
## INDFMPIR0.11                  -2.996e-01  1.169e+00  -0.256   0.7977    
## INDFMPIR0.12                   1.750e+01  7.603e+03   0.002   0.9982    
## INDFMPIR0.13                   1.767e+01  6.207e+03   0.003   0.9977    
## INDFMPIR0.14000000000000001   -7.484e-01  1.225e+00  -0.611   0.5411    
## INDFMPIR0.15                  -2.161e-01  1.170e+00  -0.185   0.8535    
## INDFMPIR0.16                   1.766e+01  4.385e+03   0.004   0.9968    
## INDFMPIR0.17                   1.758e+01  6.199e+03   0.003   0.9977    
## INDFMPIR0.18                   1.683e-01  1.136e+00   0.148   0.8823    
## INDFMPIR0.19                   1.763e+01  4.806e+03   0.004   0.9971    
## INDFMPIR0.2                    1.767e+01  4.806e+03   0.004   0.9971    
## INDFMPIR0.21                   1.780e+01  7.604e+03   0.002   0.9981    
## INDFMPIR0.22                  -2.148e+01  1.075e+04  -0.002   0.9984    
## INDFMPIR0.23                  -1.422e+00  1.000e+00  -1.422   0.1551    
## INDFMPIR0.24                  -1.964e-01  1.169e+00  -0.168   0.8666    
## INDFMPIR0.25                   1.769e+01  4.808e+03   0.004   0.9971    
## INDFMPIR0.26                   1.767e+01  4.389e+03   0.004   0.9968    
## INDFMPIR0.27                  -1.379e-01  1.154e+00  -0.119   0.9049    
## INDFMPIR0.28000000000000003   -2.152e+01  1.075e+04  -0.002   0.9984    
## INDFMPIR0.28999999999999998   -3.381e-01  1.169e+00  -0.289   0.7725    
## INDFMPIR0.3                   -1.421e+00  9.998e-01  -1.422   0.1551    
## INDFMPIR0.31                   1.756e+01  4.807e+03   0.004   0.9971    
## INDFMPIR0.32                   1.766e+01  6.208e+03   0.003   0.9977    
## INDFMPIR0.33                   1.762e+01  5.371e+03   0.003   0.9974    
## INDFMPIR0.34                   1.776e+01  6.208e+03   0.003   0.9977    
## INDFMPIR0.35                   1.769e+01  6.204e+03   0.003   0.9977    
## INDFMPIR0.36                  -1.601e+00  1.001e+00  -1.599   0.1097    
## INDFMPIR0.37                  -7.966e-01  9.125e-01  -0.873   0.3827    
## INDFMPIR0.38                   1.770e+01  6.208e+03   0.003   0.9977    
## INDFMPIR0.39                   1.772e+01  7.604e+03   0.002   0.9981    
## INDFMPIR0.4                   -5.863e-03  1.144e+00  -0.005   0.9959    
## INDFMPIR0.41                  -2.097e-01  1.154e+00  -0.182   0.8559    
## INDFMPIR0.42                   1.769e+01  7.602e+03   0.002   0.9981    
## INDFMPIR0.43                   1.433e-01  1.136e+00   0.126   0.8996    
## INDFMPIR0.44                   1.765e+01  4.386e+03   0.004   0.9968    
## INDFMPIR0.45                  -4.630e-02  1.155e+00  -0.040   0.9680    
## INDFMPIR0.46                   3.156e-01  1.130e+00   0.279   0.7800    
## INDFMPIR0.47                   1.773e+01  1.075e+04   0.002   0.9987    
## INDFMPIR0.48                   1.768e+01  4.062e+03   0.004   0.9965    
## INDFMPIR0.49                  -8.520e-01  1.225e+00  -0.696   0.4866    
## INDFMPIR0.5                   -1.264e+00  1.290e+00  -0.979   0.3274    
## INDFMPIR0.51                   1.767e+01  5.376e+03   0.003   0.9974    
## INDFMPIR0.52                   6.109e-02  8.580e-01   0.071   0.9432    
## INDFMPIR0.53                   1.751e+01  6.207e+03   0.003   0.9977    
## INDFMPIR0.54                  -1.831e+00  1.472e+00  -1.244   0.2134    
## INDFMPIR0.55000000000000004   -3.952e-01  8.806e-01  -0.449   0.6536    
## INDFMPIR0.56000000000000005   -1.230e+00  1.292e+00  -0.952   0.3409    
## INDFMPIR0.56999999999999995    1.762e+01  3.398e+03   0.005   0.9959    
## INDFMPIR0.57999999999999996   -3.613e-01  7.545e-01  -0.479   0.6321    
## INDFMPIR0.59                   1.771e+01  6.208e+03   0.003   0.9977    
## INDFMPIR0.6                   -8.526e-01  1.225e+00  -0.696   0.4866    
## INDFMPIR0.61                  -1.421e+00  8.359e-01  -1.700   0.0892 .  
## INDFMPIR0.62                   3.266e-01  1.125e+00   0.290   0.7716    
## INDFMPIR0.63                  -3.057e-01  8.748e-01  -0.349   0.7268    
## INDFMPIR0.64                   1.759e+01  1.075e+04   0.002   0.9987    
## INDFMPIR0.65                  -2.817e-01  8.743e-01  -0.322   0.7473    
## INDFMPIR0.66                  -9.809e-01  6.272e-01  -1.564   0.1178    
## INDFMPIR0.67                   1.757e+01  6.201e+03   0.003   0.9977    
## INDFMPIR0.68                  -8.653e-02  8.616e-01  -0.100   0.9200    
## INDFMPIR0.69                   2.940e-02  8.554e-01   0.034   0.9726    
## INDFMPIR0.7                    6.379e-01  1.112e+00   0.574   0.5662    
## INDFMPIR0.71                  -6.981e-01  8.992e-01  -0.776   0.4375    
## INDFMPIR0.72                   1.761e+01  3.241e+03   0.005   0.9957    
## INDFMPIR0.73                  -3.381e-01  1.169e+00  -0.289   0.7725    
## INDFMPIR0.74                   4.309e-02  6.689e-01   0.064   0.9486    
## INDFMPIR0.75                  -7.882e-01  7.740e-01  -1.018   0.3085    
## INDFMPIR0.76                  -1.988e-01  1.154e+00  -0.172   0.8633    
## INDFMPIR0.77                   8.334e-01  1.108e+00   0.752   0.4518    
## INDFMPIR0.78                   1.750e+01  4.807e+03   0.004   0.9971    
## INDFMPIR0.79                   1.120e+00  1.100e+00   1.018   0.3086    
## INDFMPIR0.8                   -1.328e-01  1.154e+00  -0.115   0.9084    
## INDFMPIR0.81                   1.756e+01  3.102e+03   0.006   0.9955    
## INDFMPIR0.82                  -1.138e-01  7.418e-01  -0.153   0.8781    
## INDFMPIR0.83                  -5.733e-01  8.889e-01  -0.645   0.5190    
## INDFMPIR0.84                   1.759e+01  3.398e+03   0.005   0.9959    
## INDFMPIR0.85                  -2.545e-01  8.689e-01  -0.293   0.7696    
## INDFMPIR0.86                   3.024e-01  1.130e+00   0.268   0.7889    
## INDFMPIR0.87                  -9.102e-01  7.105e-01  -1.281   0.2002    
## INDFMPIR0.88                  -5.060e-01  6.071e-01  -0.834   0.4045    
## INDFMPIR0.89                   1.756e+01  3.582e+03   0.005   0.9961    
## INDFMPIR0.9                    1.775e+01  7.604e+03   0.002   0.9981    
## INDFMPIR0.91                  -6.239e-01  7.672e-01  -0.813   0.4160    
## INDFMPIR0.92                   3.532e-01  1.125e+00   0.314   0.7535    
## INDFMPIR0.93                  -9.521e-01  7.892e-01  -1.207   0.2276    
## INDFMPIR0.94                  -2.459e-01  1.169e+00  -0.210   0.8333    
## INDFMPIR0.95                   1.759e+01  6.199e+03   0.003   0.9977    
## INDFMPIR0.96                   1.247e+00  1.098e+00   1.136   0.2559    
## INDFMPIR0.97                   6.055e-01  1.117e+00   0.542   0.5879    
## INDFMPIR0.98                  -1.172e-01  8.613e-01  -0.136   0.8917    
## INDFMPIR0.99                  -1.346e+00  6.495e-01  -2.073   0.0382 *  
## INDFMPIR1                     -2.671e+00  1.293e+00  -2.066   0.0388 *  
## INDFMPIR1.01                   3.921e-02  7.375e-01   0.053   0.9576    
## INDFMPIR1.02                  -1.242e+00  9.578e-01  -1.297   0.1946    
## INDFMPIR1.03                   1.041e+00  1.101e+00   0.945   0.3447    
## INDFMPIR1.04                  -1.043e+00  9.311e-01  -1.120   0.2626    
## INDFMPIR1.05                   7.851e-01  1.110e+00   0.708   0.4792    
## INDFMPIR1.06                   6.196e-01  1.112e+00   0.557   0.5774    
## INDFMPIR1.07                  -1.258e+00  8.162e-01  -1.541   0.1234    
## INDFMPIR1.08                   1.763e+01  3.800e+03   0.005   0.9963    
## INDFMPIR1.0900000000000001    -6.243e-01  6.137e-01  -1.017   0.3090    
## INDFMPIR1.1000000000000001     1.006e+00  1.103e+00   0.912   0.3618    
## INDFMPIR1.1100000000000001     1.750e+01  7.600e+03   0.002   0.9982    
## INDFMPIR1.1200000000000001    -1.371e+00  6.905e-01  -1.986   0.0470 *  
## INDFMPIR1.1299999999999999    -1.942e-01  7.461e-01  -0.260   0.7946    
## INDFMPIR1.1399999999999999    -2.014e-02  8.582e-01  -0.023   0.9813    
## INDFMPIR1.1499999999999999     1.765e+01  3.240e+03   0.005   0.9957    
## INDFMPIR1.1599999999999999    -3.101e-01  8.702e-01  -0.356   0.7215    
## INDFMPIR1.17                  -1.045e+00  7.171e-01  -1.458   0.1449    
## INDFMPIR1.18                   2.170e-01  1.130e+00   0.192   0.8477    
## INDFMPIR1.19                   1.761e+01  4.385e+03   0.004   0.9968    
## INDFMPIR1.2                    1.755e+01  3.799e+03   0.005   0.9963    
## INDFMPIR1.21                   1.765e+01  4.387e+03   0.004   0.9968    
## INDFMPIR1.22                  -1.937e-01  1.155e+00  -0.168   0.8668    
## INDFMPIR1.23                  -4.542e-01  6.854e-01  -0.663   0.5075    
## INDFMPIR1.24                  -1.566e+00  1.001e+00  -1.565   0.1177    
## INDFMPIR1.25                   3.696e-01  1.125e+00   0.329   0.7425    
## INDFMPIR1.26                  -5.281e-01  7.584e-01  -0.696   0.4862    
## INDFMPIR1.27                   9.555e-02  1.136e+00   0.084   0.9330    
## INDFMPIR1.28                   1.761e+01  5.366e+03   0.003   0.9974    
## INDFMPIR1.29                  -5.707e-01  8.888e-01  -0.642   0.5208    
## INDFMPIR1.3                    1.760e+01  2.239e+03   0.008   0.9937    
## INDFMPIR1.31                  -8.243e-01  7.017e-01  -1.175   0.2401    
## INDFMPIR1.32                  -3.185e-01  6.802e-01  -0.468   0.6396    
## INDFMPIR1.33                   1.765e+01  5.372e+03   0.003   0.9974    
## INDFMPIR1.34                   1.765e+01  3.581e+03   0.005   0.9961    
## INDFMPIR1.35                   1.757e+01  6.198e+03   0.003   0.9977    
## INDFMPIR1.36                   1.749e+01  7.602e+03   0.002   0.9982    
## INDFMPIR1.37                  -8.732e-01  5.980e-01  -1.460   0.1442    
## INDFMPIR1.38                   1.753e+01  3.797e+03   0.005   0.9963    
## INDFMPIR1.39                  -5.340e-01  8.887e-01  -0.601   0.5479    
## INDFMPIR1.4                    1.758e+01  2.606e+03   0.007   0.9946    
## INDFMPIR1.41                  -1.299e+00  7.347e-01  -1.768   0.0770 .  
## INDFMPIR1.42                   1.628e-01  1.136e+00   0.143   0.8860    
## INDFMPIR1.43                  -9.183e-01  1.225e+00  -0.750   0.4533    
## INDFMPIR1.44                  -6.529e-01  6.977e-01  -0.936   0.3494    
## INDFMPIR1.46                   1.760e+01  3.799e+03   0.005   0.9963    
## INDFMPIR1.47                   1.762e+01  1.960e+03   0.009   0.9928    
## INDFMPIR1.48                   1.489e-01  1.136e+00   0.131   0.8957    
## INDFMPIR1.49                  -1.473e+00  8.359e-01  -1.762   0.0781 .  
## INDFMPIR1.5                    1.754e+01  1.075e+04   0.002   0.9987    
## INDFMPIR1.51                  -2.000e-01  7.444e-01  -0.269   0.7881    
## INDFMPIR1.52                  -2.674e-02  8.583e-01  -0.031   0.9752    
## INDFMPIR1.53                  -1.054e+00  9.315e-01  -1.131   0.2580    
## INDFMPIR1.54                   1.765e+01  7.602e+03   0.002   0.9981    
## INDFMPIR1.55                   4.800e-01  1.118e+00   0.429   0.6677    
## INDFMPIR1.56                   1.759e+01  7.594e+03   0.002   0.9982    
## INDFMPIR1.57                   1.671e-01  1.136e+00   0.147   0.8830    
## INDFMPIR1.58                   1.758e+01  3.399e+03   0.005   0.9959    
## INDFMPIR1.59                  -8.428e-01  1.224e+00  -0.688   0.4912    
## INDFMPIR1.6                    1.992e-01  1.130e+00   0.176   0.8601    
## INDFMPIR1.61                   4.440e-01  1.121e+00   0.396   0.6920    
## INDFMPIR1.62                   5.866e-01  1.115e+00   0.526   0.5987    
## INDFMPIR1.64                   2.252e-01  8.484e-01   0.265   0.7906    
## INDFMPIR1.65                   5.131e-01  1.118e+00   0.459   0.6461    
## INDFMPIR1.66                   1.763e+01  5.374e+03   0.003   0.9974    
## INDFMPIR1.67                  -2.762e-01  7.483e-01  -0.369   0.7121    
## INDFMPIR1.68                   1.767e+01  4.806e+03   0.004   0.9971    
## INDFMPIR1.69                   1.031e+00  1.102e+00   0.935   0.3496    
## INDFMPIR1.7                    1.762e+01  6.205e+03   0.003   0.9977    
## INDFMPIR1.71                   1.360e+00  1.096e+00   1.242   0.2143    
## INDFMPIR1.72                  -1.250e+00  6.766e-01  -1.847   0.0647 .  
## INDFMPIR1.73                   1.759e+01  1.075e+04   0.002   0.9987    
## INDFMPIR1.74                   1.770e+01  4.386e+03   0.004   0.9968    
## INDFMPIR1.75                   1.760e+01  2.774e+03   0.006   0.9949    
## INDFMPIR1.76                   1.758e+01  7.604e+03   0.002   0.9982    
## INDFMPIR1.77                   9.156e-01  1.105e+00   0.829   0.4072    
## INDFMPIR1.78                  -8.842e-01  9.129e-01  -0.969   0.3327    
## INDFMPIR1.79                   1.776e+01  1.075e+04   0.002   0.9987    
## INDFMPIR1.8                    1.763e+01  2.687e+03   0.007   0.9948    
## INDFMPIR1.81                  -4.034e-01  1.170e+00  -0.345   0.7303    
## INDFMPIR1.82                   1.761e+01  4.806e+03   0.004   0.9971    
## INDFMPIR1.83                   1.752e+01  5.375e+03   0.003   0.9974    
## INDFMPIR1.84                   2.857e-01  8.470e-01   0.337   0.7359    
## INDFMPIR1.85                   6.447e-03  7.383e-01   0.009   0.9930    
## INDFMPIR1.86                  -5.047e-01  8.816e-01  -0.573   0.5670    
## INDFMPIR1.87                   1.773e+01  1.075e+04   0.002   0.9987    
## INDFMPIR1.88                   1.761e+01  1.075e+04   0.002   0.9987    
## INDFMPIR1.89                  -1.422e+00  8.368e-01  -1.699   0.0893 .  
## INDFMPIR1.9                   -1.592e+00  9.992e-01  -1.594   0.1110    
## INDFMPIR1.91                  -2.391e-01  6.781e-01  -0.353   0.7243    
## INDFMPIR1.92                   6.122e-02  1.136e+00   0.054   0.9570    
## INDFMPIR1.93                   1.753e+01  5.372e+03   0.003   0.9974    
## INDFMPIR1.94                   5.874e-01  1.115e+00   0.527   0.5982    
## INDFMPIR1.95                   1.759e+01  3.399e+03   0.005   0.9959    
## INDFMPIR1.96                  -2.131e+01  1.075e+04  -0.002   0.9984    
## INDFMPIR1.97                   1.760e+01  2.774e+03   0.006   0.9949    
## INDFMPIR1.98                   1.258e-01  1.136e+00   0.111   0.9119    
## INDFMPIR1.99                   1.428e-01  8.526e-01   0.167   0.8670    
## INDFMPIR2                      1.762e+01  4.062e+03   0.004   0.9965    
## INDFMPIR2.0099999999999998    -5.437e-01  1.190e+00  -0.457   0.6478    
## INDFMPIR2.02                   1.756e+01  4.385e+03   0.004   0.9968    
## INDFMPIR2.0299999999999998     8.928e-01  1.105e+00   0.808   0.4189    
## INDFMPIR2.04                   1.753e+01  5.373e+03   0.003   0.9974    
## INDFMPIR2.0499999999999998    -3.350e-01  1.169e+00  -0.287   0.7744    
## INDFMPIR2.06                   1.755e+01  2.533e+03   0.007   0.9945    
## INDFMPIR2.0699999999999998     1.752e+01  3.800e+03   0.005   0.9963    
## INDFMPIR2.08                   1.766e+01  4.389e+03   0.004   0.9968    
## INDFMPIR2.09                   2.982e-02  1.144e+00   0.026   0.9792    
## INDFMPIR2.1                    1.763e+01  4.061e+03   0.004   0.9965    
## INDFMPIR2.11                   1.764e+01  5.367e+03   0.003   0.9974    
## INDFMPIR2.12                   1.765e+01  5.373e+03   0.003   0.9974    
## INDFMPIR2.13                   1.058e+00  1.101e+00   0.961   0.3366    
## INDFMPIR2.14                   1.748e+01  1.075e+04   0.002   0.9987    
## INDFMPIR2.15                   1.760e+01  4.064e+03   0.004   0.9965    
## INDFMPIR2.16                   2.355e-01  7.310e-01   0.322   0.7474    
## INDFMPIR2.17                  -4.722e-01  7.579e-01  -0.623   0.5332    
## INDFMPIR2.1800000000000002     5.173e-02  7.356e-01   0.070   0.9439    
## INDFMPIR2.19                   1.767e+01  2.981e+03   0.006   0.9953    
## INDFMPIR2.2000000000000002     1.768e+01  7.604e+03   0.002   0.9981    
## INDFMPIR2.21                   1.415e+00  1.094e+00   1.293   0.1961    
## INDFMPIR2.2200000000000002     1.768e+01  7.595e+03   0.002   0.9981    
## INDFMPIR2.23                   1.749e+01  7.599e+03   0.002   0.9982    
## INDFMPIR2.2400000000000002     1.763e+01  5.370e+03   0.003   0.9974    
## INDFMPIR2.25                   1.760e+01  4.390e+03   0.004   0.9968    
## INDFMPIR2.2599999999999998     1.765e+01  5.375e+03   0.003   0.9974    
## INDFMPIR2.27                   1.753e+01  1.075e+04   0.002   0.9987    
## INDFMPIR2.2799999999999998    -8.082e-01  7.019e-01  -1.151   0.2496    
## INDFMPIR2.29                   1.764e+01  3.799e+03   0.005   0.9963    
## INDFMPIR2.2999999999999998     1.766e+01  4.062e+03   0.004   0.9965    
## INDFMPIR2.31                   6.383e-01  1.114e+00   0.573   0.5667    
## INDFMPIR2.3199999999999998    -7.482e-01  9.002e-01  -0.831   0.4059    
## INDFMPIR2.33                   4.176e-01  8.426e-01   0.496   0.6201    
## INDFMPIR2.34                   1.763e+01  4.387e+03   0.004   0.9968    
## INDFMPIR2.35                  -1.341e+00  9.585e-01  -1.399   0.1618    
## INDFMPIR2.36                  -3.986e-01  1.170e+00  -0.341   0.7334    
## INDFMPIR2.37                   1.751e+01  7.601e+03   0.002   0.9982    
## INDFMPIR2.38                   1.754e+01  5.369e+03   0.003   0.9974    
## INDFMPIR2.39                  -4.959e-02  8.609e-01  -0.058   0.9541    
## INDFMPIR2.4                    8.424e-01  1.107e+00   0.761   0.4466    
## INDFMPIR2.41                   1.764e+01  2.979e+03   0.006   0.9953    
## INDFMPIR2.42                   1.766e+01  7.602e+03   0.002   0.9981    
## INDFMPIR2.4300000000000002     7.011e-01  1.112e+00   0.630   0.5285    
## INDFMPIR2.44                   1.758e+01  7.604e+03   0.002   0.9982    
## INDFMPIR2.4500000000000002    -1.965e+00  1.471e+00  -1.335   0.1817    
## INDFMPIR2.46                   1.759e+01  2.344e+03   0.008   0.9940    
## INDFMPIR2.4700000000000002     3.370e-02  1.144e+00   0.029   0.9765    
## INDFMPIR2.48                  -4.433e-01  8.811e-01  -0.503   0.6149    
## INDFMPIR2.4900000000000002    -3.034e-01  1.170e+00  -0.259   0.7954    
## INDFMPIR2.5                    1.763e+01  3.398e+03   0.005   0.9959    
## INDFMPIR2.5099999999999998    -6.042e-01  1.191e+00  -0.507   0.6119    
## INDFMPIR2.52                   1.763e+01  4.387e+03   0.004   0.9968    
## INDFMPIR2.5299999999999998     1.759e+01  7.604e+03   0.002   0.9982    
## INDFMPIR2.54                   1.762e+01  2.979e+03   0.006   0.9953    
## INDFMPIR2.5499999999999998     1.767e+01  7.602e+03   0.002   0.9981    
## INDFMPIR2.56                  -1.051e+00  9.301e-01  -1.130   0.2584    
## INDFMPIR2.57                  -2.007e+00  9.126e-01  -2.200   0.0278 *  
## INDFMPIR2.58                  -2.372e-01  6.765e-01  -0.351   0.7258    
## INDFMPIR2.59                   1.757e+01  6.205e+03   0.003   0.9977    
## INDFMPIR2.61                   6.840e-01  8.375e-01   0.817   0.4141    
## INDFMPIR2.62                   3.520e-01  1.122e+00   0.314   0.7537    
## INDFMPIR2.63                   1.757e+01  1.075e+04   0.002   0.9987    
## INDFMPIR2.64                   1.769e+01  6.205e+03   0.003   0.9977    
## INDFMPIR2.65                   1.752e+01  4.388e+03   0.004   0.9968    
## INDFMPIR2.66                   1.753e+01  5.375e+03   0.003   0.9974    
## INDFMPIR2.67                   1.758e+01  5.371e+03   0.003   0.9974    
## INDFMPIR2.68                   1.775e+01  7.602e+03   0.002   0.9981    
## INDFMPIR2.69                   1.763e+01  5.369e+03   0.003   0.9974    
## INDFMPIR2.7                    1.763e+01  4.062e+03   0.004   0.9965    
## INDFMPIR2.71                  -9.146e-01  9.124e-01  -1.002   0.3162    
## INDFMPIR2.72                   1.771e+01  4.389e+03   0.004   0.9968    
## INDFMPIR2.73                   6.577e-01  8.369e-01   0.786   0.4319    
## INDFMPIR2.74                   4.928e-01  8.404e-01   0.586   0.5576    
## INDFMPIR2.75                   1.752e+01  4.807e+03   0.004   0.9971    
## INDFMPIR2.76                  -1.376e+00  1.292e+00  -1.065   0.2869    
## INDFMPIR2.77                   1.766e+01  4.388e+03   0.004   0.9968    
## INDFMPIR2.78                   1.761e+01  3.582e+03   0.005   0.9961    
## INDFMPIR2.79                   4.963e-01  1.118e+00   0.444   0.6570    
## INDFMPIR2.8                   -1.297e-02  1.144e+00  -0.011   0.9910    
## INDFMPIR2.81                   1.755e+01  4.806e+03   0.004   0.9971    
## INDFMPIR2.82                   1.762e+01  3.101e+03   0.006   0.9955    
## INDFMPIR2.83                  -1.121e+00  7.248e-01  -1.547   0.1218    
## INDFMPIR2.84                   1.753e+01  4.388e+03   0.004   0.9968    
## INDFMPIR2.85                   1.766e+01  3.398e+03   0.005   0.9959    
## INDFMPIR2.86                   1.758e+01  4.807e+03   0.004   0.9971    
## INDFMPIR2.87                  -1.706e-01  7.433e-01  -0.229   0.8185    
## INDFMPIR2.88                  -8.506e-01  7.056e-01  -1.206   0.2280    
## INDFMPIR2.89                   1.755e+01  7.596e+03   0.002   0.9982    
## INDFMPIR2.9                   -2.152e+01  1.075e+04  -0.002   0.9984    
## INDFMPIR2.91                   1.759e+01  1.075e+04   0.002   0.9987    
## INDFMPIR2.92                   8.528e-01  1.108e+00   0.770   0.4414    
## INDFMPIR2.93                   1.756e+01  1.075e+04   0.002   0.9987    
## INDFMPIR2.94                   1.050e+00  1.101e+00   0.954   0.3400    
## INDFMPIR2.95                   9.479e-03  1.144e+00   0.008   0.9934    
## INDFMPIR2.96                  -8.425e-01  1.225e+00  -0.688   0.4915    
## INDFMPIR2.98                   1.766e+01  5.370e+03   0.003   0.9974    
## INDFMPIR3                      1.991e-01  8.489e-01   0.234   0.8146    
## INDFMPIR3.02                   7.528e-01  1.109e+00   0.679   0.4974    
## INDFMPIR3.03                   1.768e+01  7.600e+03   0.002   0.9981    
## INDFMPIR3.04                   1.265e+00  1.097e+00   1.153   0.2489    
## INDFMPIR3.06                   2.145e-01  1.130e+00   0.190   0.8494    
## INDFMPIR3.07                   1.759e+01  1.075e+04   0.002   0.9987    
## INDFMPIR3.08                   1.760e+01  3.398e+03   0.005   0.9959    
## INDFMPIR3.09                   1.009e+00  1.102e+00   0.915   0.3599    
## INDFMPIR3.1                    1.773e+01  7.600e+03   0.002   0.9981    
## INDFMPIR3.11                   1.770e-01  1.130e+00   0.157   0.8755    
## INDFMPIR3.12                  -1.333e+00  1.291e+00  -1.032   0.3019    
## INDFMPIR3.13                  -9.276e-01  7.894e-01  -1.175   0.2400    
## INDFMPIR3.14                  -2.389e-01  1.156e+00  -0.207   0.8362    
## INDFMPIR3.15                  -1.250e+00  1.291e+00  -0.969   0.3328    
## INDFMPIR3.16                   1.759e+01  3.582e+03   0.005   0.9961    
## INDFMPIR3.17                   1.757e+01  3.399e+03   0.005   0.9959    
## INDFMPIR3.18                   1.770e+01  1.075e+04   0.002   0.9987    
## INDFMPIR3.19                   1.769e+01  5.373e+03   0.003   0.9974    
## INDFMPIR3.21                   1.781e+01  1.075e+04   0.002   0.9987    
## INDFMPIR3.22                   5.903e-01  1.117e+00   0.528   0.5973    
## INDFMPIR3.23                   1.760e+01  6.205e+03   0.003   0.9977    
## INDFMPIR3.24                  -2.847e-01  8.693e-01  -0.327   0.7433    
## INDFMPIR3.25                   1.768e+01  7.604e+03   0.002   0.9981    
## INDFMPIR3.26                   1.760e+01  3.580e+03   0.005   0.9961    
## INDFMPIR3.27                   1.764e+01  7.602e+03   0.002   0.9981    
## INDFMPIR3.28                   4.114e-01  7.277e-01   0.565   0.5718    
## INDFMPIR3.29                   1.756e+01  4.385e+03   0.004   0.9968    
## INDFMPIR3.3                    2.779e-01  8.460e-01   0.329   0.7425    
## INDFMPIR3.31                   1.756e+01  3.240e+03   0.005   0.9957    
## INDFMPIR3.32                   1.763e+01  1.075e+04   0.002   0.9987    
## INDFMPIR3.33                   8.295e-03  8.581e-01   0.010   0.9923    
## INDFMPIR3.34                   1.759e+01  7.589e+03   0.002   0.9982    
## INDFMPIR3.35                   1.751e+01  5.374e+03   0.003   0.9974    
## INDFMPIR3.36                   1.770e+01  5.374e+03   0.003   0.9974    
## INDFMPIR3.37                   1.755e+01  1.075e+04   0.002   0.9987    
## INDFMPIR3.38                  -9.016e-01  9.123e-01  -0.988   0.3230    
## INDFMPIR3.39                  -9.189e-01  1.225e+00  -0.750   0.4530    
## INDFMPIR3.4                    1.759e+01  6.208e+03   0.003   0.9977    
## INDFMPIR3.41                   1.768e+01  6.204e+03   0.003   0.9977    
## INDFMPIR3.42                   5.328e-01  8.412e-01   0.633   0.5264    
## INDFMPIR3.43                   9.969e-01  1.102e+00   0.905   0.3655    
## INDFMPIR3.44                   1.754e+01  3.399e+03   0.005   0.9959    
## INDFMPIR3.45                   1.768e+01  5.373e+03   0.003   0.9974    
## INDFMPIR3.46                   1.759e+01  5.377e+03   0.003   0.9974    
## INDFMPIR3.47                  -2.626e-03  8.578e-01  -0.003   0.9976    
## INDFMPIR3.49                   1.759e+01  4.062e+03   0.004   0.9965    
## INDFMPIR3.5                    1.765e+01  7.603e+03   0.002   0.9981    
## INDFMPIR3.52                   1.775e+01  1.075e+04   0.002   0.9987    
## INDFMPIR3.53                   1.754e+01  3.801e+03   0.005   0.9963    
## INDFMPIR3.54                   1.746e+01  7.602e+03   0.002   0.9982    
## INDFMPIR3.55                  -6.413e-01  6.454e-01  -0.994   0.3204    
## INDFMPIR3.56                   1.756e+01  1.075e+04   0.002   0.9987    
## INDFMPIR3.57                   1.759e+01  3.583e+03   0.005   0.9961    
## INDFMPIR3.58                   1.761e+01  4.385e+03   0.004   0.9968    
## INDFMPIR3.6                    1.085e+00  1.101e+00   0.986   0.3242    
## INDFMPIR3.61                   1.742e+01  1.075e+04   0.002   0.9987    
## INDFMPIR3.62                   1.765e+01  4.803e+03   0.004   0.9971    
## INDFMPIR3.64                   1.758e+01  6.199e+03   0.003   0.9977    
## INDFMPIR3.65                  -1.318e+00  1.291e+00  -1.021   0.3073    
## INDFMPIR3.66                   1.752e+01  7.599e+03   0.002   0.9982    
## INDFMPIR3.67                   1.763e+01  7.604e+03   0.002   0.9982    
## INDFMPIR3.68                   7.941e-01  1.108e+00   0.717   0.4735    
## INDFMPIR3.69                   1.764e+01  2.605e+03   0.007   0.9946    
## INDFMPIR3.7                   -2.093e-01  1.154e+00  -0.181   0.8561    
## INDFMPIR3.71                  -1.993e+00  1.471e+00  -1.355   0.1754    
## INDFMPIR3.72                   1.752e+01  6.206e+03   0.003   0.9977    
## INDFMPIR3.73                   1.758e+01  6.204e+03   0.003   0.9977    
## INDFMPIR3.74                   1.773e+01  1.075e+04   0.002   0.9987    
## INDFMPIR3.75                   1.763e+01  4.804e+03   0.004   0.9971    
## INDFMPIR3.76                  -4.065e-01  1.168e+00  -0.348   0.7279    
## INDFMPIR3.77                   1.758e+01  2.685e+03   0.007   0.9948    
## INDFMPIR3.78                   1.763e+01  7.599e+03   0.002   0.9981    
## INDFMPIR3.8                    1.752e+01  2.981e+03   0.006   0.9953    
## INDFMPIR3.82                   1.755e+01  2.193e+03   0.008   0.9936    
## INDFMPIR3.83                  -1.021e+00  9.300e-01  -1.097   0.2725    
## INDFMPIR3.84                   1.771e+01  7.604e+03   0.002   0.9981    
## INDFMPIR3.85                   1.770e+01  1.075e+04   0.002   0.9987    
## INDFMPIR3.86                   1.761e+01  6.200e+03   0.003   0.9977    
## INDFMPIR3.87                   1.761e+01  6.202e+03   0.003   0.9977    
## INDFMPIR3.88                   1.759e+01  4.388e+03   0.004   0.9968    
## INDFMPIR3.89                   1.775e+01  1.075e+04   0.002   0.9987    
## INDFMPIR3.9                   -2.052e-01  1.155e+00  -0.178   0.8590    
## INDFMPIR3.91                   1.755e+01  4.059e+03   0.004   0.9965    
## INDFMPIR3.92                  -8.564e-01  1.226e+00  -0.699   0.4848    
## INDFMPIR3.93                  -1.296e+00  1.293e+00  -1.002   0.3165    
## INDFMPIR3.94                   1.770e+01  7.603e+03   0.002   0.9981    
## INDFMPIR3.96                   5.805e-01  1.115e+00   0.521   0.6026    
## INDFMPIR3.97                   1.764e+01  3.581e+03   0.005   0.9961    
## INDFMPIR3.98                   1.758e+01  1.075e+04   0.002   0.9987    
## INDFMPIR3.99                   1.750e+01  6.205e+03   0.003   0.9977    
## INDFMPIR4                     -4.619e-01  8.808e-01  -0.524   0.6000    
## INDFMPIR4.01                   1.751e+01  7.600e+03   0.002   0.9982    
## INDFMPIR4.0199999999999996     1.758e+01  3.102e+03   0.006   0.9955    
## INDFMPIR4.03                  -1.803e+00  1.473e+00  -1.224   0.2209    
## INDFMPIR4.04                   1.761e+01  4.806e+03   0.004   0.9971    
## INDFMPIR4.05                   1.755e+01  2.533e+03   0.007   0.9945    
## INDFMPIR4.0599999999999996     7.757e-01  1.108e+00   0.700   0.4837    
## INDFMPIR4.08                   1.767e+01  1.075e+04   0.002   0.9987    
## INDFMPIR4.0999999999999996     1.762e+01  2.402e+03   0.007   0.9941    
## INDFMPIR4.1100000000000003     1.758e+01  1.075e+04   0.002   0.9987    
## INDFMPIR4.12                   1.761e+01  2.291e+03   0.008   0.9939    
## INDFMPIR4.13                   1.761e+01  7.594e+03   0.002   0.9981    
## INDFMPIR4.1399999999999997     1.772e+01  7.604e+03   0.002   0.9981    
## INDFMPIR4.1500000000000004    -1.310e+00  1.290e+00  -1.015   0.3101    
## INDFMPIR4.16                   1.777e+01  1.075e+04   0.002   0.9987    
## INDFMPIR4.17                   1.762e+01  4.387e+03   0.004   0.9968    
## INDFMPIR4.18                   1.753e+01  7.601e+03   0.002   0.9982    
## INDFMPIR4.1900000000000004     1.765e+01  6.205e+03   0.003   0.9977    
## INDFMPIR4.21                   1.757e+01  6.201e+03   0.003   0.9977    
## INDFMPIR4.22                  -3.360e-01  1.169e+00  -0.287   0.7738    
## INDFMPIR4.2300000000000004     1.752e+01  6.206e+03   0.003   0.9977    
## INDFMPIR4.25                   1.766e+01  6.206e+03   0.003   0.9977    
## INDFMPIR4.26                   1.751e+01  7.600e+03   0.002   0.9982    
## INDFMPIR4.2699999999999996     1.761e+01  3.582e+03   0.005   0.9961    
## INDFMPIR4.29                   1.757e+01  7.592e+03   0.002   0.9982    
## INDFMPIR4.3                    1.764e+01  1.075e+04   0.002   0.9987    
## INDFMPIR4.3099999999999996     1.760e+01  3.238e+03   0.005   0.9957    
## INDFMPIR4.32                   1.764e+01  2.686e+03   0.007   0.9948    
## INDFMPIR4.33                   3.817e-02  1.143e+00   0.033   0.9734    
## INDFMPIR4.34                   3.287e-02  8.552e-01   0.038   0.9693    
## INDFMPIR4.3600000000000003    -2.044e+00  1.472e+00  -1.389   0.1650    
## INDFMPIR4.37                   1.247e+00  1.097e+00   1.137   0.2557    
## INDFMPIR4.4000000000000004     1.767e+01  7.599e+03   0.002   0.9981    
## INDFMPIR4.41                   1.758e+01  5.373e+03   0.003   0.9974    
## INDFMPIR4.42                   1.130e+00  1.099e+00   1.027   0.3042    
## INDFMPIR4.43                   1.766e+01  6.198e+03   0.003   0.9977    
## INDFMPIR4.4400000000000004     1.764e+01  3.796e+03   0.005   0.9963    
## INDFMPIR4.45                   1.766e+01  7.603e+03   0.002   0.9981    
## INDFMPIR4.46                   1.757e+01  3.102e+03   0.006   0.9955    
## INDFMPIR4.4800000000000004     1.751e+01  6.206e+03   0.003   0.9977    
## INDFMPIR4.49                   1.774e+01  1.075e+04   0.002   0.9987    
## INDFMPIR4.5                    1.772e+01  7.604e+03   0.002   0.9981    
## INDFMPIR4.51                   1.747e+01  7.599e+03   0.002   0.9982    
## INDFMPIR4.53                   1.768e+01  5.370e+03   0.003   0.9974    
## INDFMPIR4.54                   1.763e+01  6.202e+03   0.003   0.9977    
## INDFMPIR4.55                   1.761e+01  4.386e+03   0.004   0.9968    
## INDFMPIR4.5599999999999996     1.142e+00  1.099e+00   1.039   0.2987    
## INDFMPIR4.57                   1.762e+01  1.075e+04   0.002   0.9987    
## INDFMPIR4.59                   1.757e+01  3.240e+03   0.005   0.9957    
## INDFMPIR4.5999999999999996     1.750e+01  5.374e+03   0.003   0.9974    
## INDFMPIR4.6100000000000003     1.752e+01  6.204e+03   0.003   0.9977    
## INDFMPIR4.62                  -1.317e+00  1.293e+00  -1.019   0.3083    
## INDFMPIR4.63                   1.759e+01  5.376e+03   0.003   0.9974    
## INDFMPIR4.6399999999999997     1.757e+01  3.101e+03   0.006   0.9955    
## INDFMPIR4.66                   1.751e+01  4.063e+03   0.004   0.9966    
## INDFMPIR4.67                   2.126e-01  1.130e+00   0.188   0.8507    
## INDFMPIR4.68                   1.763e+01  4.387e+03   0.004   0.9968    
## INDFMPIR4.6900000000000004     1.752e+01  6.205e+03   0.003   0.9977    
## INDFMPIR4.71                  -2.082e+00  1.474e+00  -1.413   0.1578    
## INDFMPIR4.72                  -9.827e-01  1.227e+00  -0.801   0.4232    
## INDFMPIR4.7300000000000004     1.754e+01  1.075e+04   0.002   0.9987    
## INDFMPIR4.75                   1.749e+01  1.075e+04   0.002   0.9987    
## INDFMPIR4.78                   1.760e+01  2.606e+03   0.007   0.9946    
## INDFMPIR4.8                    1.754e+01  3.103e+03   0.006   0.9955    
## INDFMPIR4.8099999999999996     1.763e+01  1.075e+04   0.002   0.9987    
## INDFMPIR4.82                   1.759e+01  3.102e+03   0.006   0.9955    
## INDFMPIR4.83                   1.763e+01  3.798e+03   0.005   0.9963    
## INDFMPIR4.8600000000000003     1.766e+01  4.807e+03   0.004   0.9971    
## INDFMPIR4.87                   1.761e+01  1.075e+04   0.002   0.9987    
## INDFMPIR4.88                  -3.177e-01  1.170e+00  -0.272   0.7859    
## INDFMPIR4.8899999999999997     1.762e+01  7.604e+03   0.002   0.9982    
## INDFMPIR4.9000000000000004     1.754e+01  1.075e+04   0.002   0.9987    
## INDFMPIR4.92                   9.537e-01  1.103e+00   0.864   0.3874    
## INDFMPIR4.93                  -5.509e-01  1.190e+00  -0.463   0.6434    
## INDFMPIR4.9400000000000004    -3.295e-01  1.169e+00  -0.282   0.7781    
## INDFMPIR4.95                   1.761e+01  1.075e+04   0.002   0.9987    
## INDFMPIR4.97                   1.757e+01  4.387e+03   0.004   0.9968    
## INDFMPIR4.99                   1.772e+01  1.075e+04   0.002   0.9987    
## INDFMPIR5                      9.697e-01  4.235e-01   2.290   0.0220 *  
## INDFMPIR7.0000000000000007E-2 -1.210e+00  9.583e-01  -1.262   0.2068    
## INDFMPIRNA                     2.157e-01  4.208e-01   0.512   0.6083    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 3777.0  on 6336  degrees of freedom
## Residual deviance: 3204.3  on 5870  degrees of freedom
## AIC: 4138.3
## 
## Number of Fisher Scoring iterations: 18
# Variance Inflation Factor (VIF) for Multicollinearity Check
vif_model3 <- vif(model3)

# Likelihood Ratio Test (LRT) to compare models
lr_test_1_2 <- lrtest(model1, model2)  # Compare Model 1 vs Model 2
lr_test_2_3 <- lrtest(model2, model3)  # Compare Model 2 vs Model 3

# AIC and BIC for model selection
aic_values <- AIC(model1, model2, model3)
bic_values <- BIC(model1, model2, model3)
# Displaying Results
print("Likelihood Ratio Test (Model 1 vs Model 2):")
## [1] "Likelihood Ratio Test (Model 1 vs Model 2):"
print(lr_test_1_2)
## Likelihood ratio test
## 
## Model 1: ALQ111 ~ RIAGENDR
## Model 2: ALQ111 ~ RIAGENDR + RIDAGEYR
##   #Df  LogLik Df  Chisq Pr(>Chisq)   
## 1   2 -1886.8                        
## 2   3 -1883.1  1 7.4649   0.006291 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
print("Likelihood Ratio Test (Model 2 vs Model 3):")
## [1] "Likelihood Ratio Test (Model 2 vs Model 3):"
print(lr_test_2_3)
## Likelihood ratio test
## 
## Model 1: ALQ111 ~ RIAGENDR + RIDAGEYR
## Model 2: ALQ111 ~ RIAGENDR + RIDAGEYR + INDFMPIR
##   #Df  LogLik  Df  Chisq Pr(>Chisq)   
## 1   3 -1883.1                         
## 2 467 -1602.2 464 561.85   0.001214 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
print("AIC Values for Model Comparison:")
## [1] "AIC Values for Model Comparison:"
print(aic_values)
##         df      AIC
## model1   2 3777.610
## model2   3 3772.145
## model3 467 4138.294
print("BIC Values for Model Comparison:")
## [1] "BIC Values for Model Comparison:"
print(bic_values)
##         df      BIC
## model1   2 3791.118
## model2   3 3792.407
## model3 467 7292.487
print("Variance Inflation Factor (VIF) for Model 3:")
## [1] "Variance Inflation Factor (VIF) for Model 3:"
print(vif_model3)
##              GVIF  Df GVIF^(1/(2*Df))
## RIAGENDR 1.054705   1        1.026988
## RIDAGEYR 1.149351   1        1.072078
## INDFMPIR 1.212125 464        1.000207
# Odds Ratio Calculation
odds_ratios <- exp(coef(model3))  # Convert log-odds to odds ratio
print("Odds Ratios for Model 3:")
## [1] "Odds Ratios for Model 3:"
print(odds_ratios)
##                   (Intercept)                     RIAGENDR2 
##                  6.245804e+00                  8.483752e-01 
##                      RIDAGEYR                  INDFMPIR0.01 
##                  1.004440e+00                  6.008933e-01 
##                  INDFMPIR0.02                  INDFMPIR0.03 
##                  6.621831e-01                  2.567989e-01 
##                  INDFMPIR0.04                  INDFMPIR0.05 
##                  1.335994e+00                  4.273454e-01 
##                  INDFMPIR0.06                  INDFMPIR0.08 
##                  5.646641e-01                  4.390862e+07 
##                  INDFMPIR0.09                   INDFMPIR0.1 
##                  4.269743e+07                  2.664420e-01 
##                  INDFMPIR0.11                  INDFMPIR0.12 
##                  7.411067e-01                  3.973997e+07 
##                  INDFMPIR0.13   INDFMPIR0.14000000000000001 
##                  4.717783e+07                  4.731158e-01 
##                  INDFMPIR0.15                  INDFMPIR0.16 
##                  8.056940e-01                  4.679469e+07 
##                  INDFMPIR0.17                  INDFMPIR0.18 
##                  4.330256e+07                  1.183307e+00 
##                  INDFMPIR0.19                   INDFMPIR0.2 
##                  4.523269e+07                  4.717439e+07 
##                  INDFMPIR0.21                  INDFMPIR0.22 
##                  5.369972e+07                  4.684190e-10 
##                  INDFMPIR0.23                  INDFMPIR0.24 
##                  2.412290e-01                  8.216860e-01 
##                  INDFMPIR0.25                  INDFMPIR0.26 
##                  4.836436e+07                  4.723271e+07 
##                  INDFMPIR0.27   INDFMPIR0.28000000000000003 
##                  8.712049e-01                  4.518804e-10 
##   INDFMPIR0.28999999999999998                   INDFMPIR0.3 
##                  7.131554e-01                  2.413736e-01 
##                  INDFMPIR0.31                  INDFMPIR0.32 
##                  4.209823e+07                  4.650969e+07 
##                  INDFMPIR0.33                  INDFMPIR0.34 
##                  4.474006e+07                  5.168581e+07 
##                  INDFMPIR0.35                  INDFMPIR0.36 
##                  4.824946e+07                  2.017100e-01 
##                  INDFMPIR0.37                  INDFMPIR0.38 
##                  4.508552e-01                  4.869822e+07 
##                  INDFMPIR0.39                   INDFMPIR0.4 
##                  4.948504e+07                  9.941542e-01 
##                  INDFMPIR0.41                  INDFMPIR0.42 
##                  8.108335e-01                  4.835061e+07 
##                  INDFMPIR0.43                  INDFMPIR0.44 
##                  1.154035e+00                  4.616699e+07 
##                  INDFMPIR0.45                  INDFMPIR0.46 
##                  9.547561e-01                  1.371039e+00 
##                  INDFMPIR0.47                  INDFMPIR0.48 
##                  4.991334e+07                  4.779075e+07 
##                  INDFMPIR0.49                   INDFMPIR0.5 
##                  4.265676e-01                  2.826243e-01 
##                  INDFMPIR0.51                  INDFMPIR0.52 
##                  4.738134e+07                  1.062999e+00 
##                  INDFMPIR0.53                  INDFMPIR0.54 
##                  4.007809e+07                  1.601878e-01 
##   INDFMPIR0.55000000000000004   INDFMPIR0.56000000000000005 
##                  6.735630e-01                  2.922065e-01 
##   INDFMPIR0.56999999999999995   INDFMPIR0.57999999999999996 
##                  4.511258e+07                  6.967936e-01 
##                  INDFMPIR0.59                   INDFMPIR0.6 
##                  4.900305e+07                  4.263187e-01 
##                  INDFMPIR0.61                  INDFMPIR0.62 
##                  2.415011e-01                  1.386268e+00 
##                  INDFMPIR0.63                  INDFMPIR0.64 
##                  7.366440e-01                  4.348601e+07 
##                  INDFMPIR0.65                  INDFMPIR0.66 
##                  7.544814e-01                  3.749678e-01 
##                  INDFMPIR0.67                  INDFMPIR0.68 
##                  4.272359e+07                  9.171097e-01 
##                  INDFMPIR0.69                   INDFMPIR0.7 
##                  1.029839e+00                  1.892446e+00 
##                  INDFMPIR0.71                  INDFMPIR0.72 
##                  4.975358e-01                  4.426261e+07 
##                  INDFMPIR0.73                  INDFMPIR0.74 
##                  7.131502e-01                  1.044036e+00 
##                  INDFMPIR0.75                  INDFMPIR0.76 
##                  4.546750e-01                  8.197526e-01 
##                  INDFMPIR0.77                  INDFMPIR0.78 
##                  2.301221e+00                  3.998733e+07 
##                  INDFMPIR0.79                   INDFMPIR0.8 
##                  3.064370e+00                  8.756379e-01 
##                  INDFMPIR0.81                  INDFMPIR0.82 
##                  4.218599e+07                  8.924772e-01 
##                  INDFMPIR0.83                  INDFMPIR0.84 
##                  5.636848e-01                  4.366167e+07 
##                  INDFMPIR0.85                  INDFMPIR0.86 
##                  7.753240e-01                  1.353151e+00 
##                  INDFMPIR0.87                  INDFMPIR0.88 
##                  4.024283e-01                  6.028941e-01 
##                  INDFMPIR0.89                   INDFMPIR0.9 
##                  4.242667e+07                  5.091856e+07 
##                  INDFMPIR0.91                  INDFMPIR0.92 
##                  5.358275e-01                  1.423663e+00 
##                  INDFMPIR0.93                  INDFMPIR0.94 
##                  3.859128e-01                  7.819854e-01 
##                  INDFMPIR0.95                  INDFMPIR0.96 
##                  4.354382e+07                  3.480141e+00 
##                  INDFMPIR0.97                  INDFMPIR0.98 
##                  1.832093e+00                  8.893733e-01 
##                  INDFMPIR0.99                     INDFMPIR1 
##                  2.601985e-01                  6.915268e-02 
##                  INDFMPIR1.01                  INDFMPIR1.02 
##                  1.039994e+00                  2.886781e-01 
##                  INDFMPIR1.03                  INDFMPIR1.04 
##                  2.830709e+00                  3.523123e-01 
##                  INDFMPIR1.05                  INDFMPIR1.06 
##                  2.192720e+00                  1.858263e+00 
##                  INDFMPIR1.07                  INDFMPIR1.08 
##                  2.843610e-01                  4.544954e+07 
##    INDFMPIR1.0900000000000001    INDFMPIR1.1000000000000001 
##                  5.356235e-01                  2.734347e+00 
##    INDFMPIR1.1100000000000001    INDFMPIR1.1200000000000001 
##                  3.991745e+07                  2.537621e-01 
##    INDFMPIR1.1299999999999999    INDFMPIR1.1399999999999999 
##                  8.234921e-01                  9.800658e-01 
##    INDFMPIR1.1499999999999999    INDFMPIR1.1599999999999999 
##                  4.625218e+07                  7.333379e-01 
##                  INDFMPIR1.17                  INDFMPIR1.18 
##                  3.515410e-01                  1.242284e+00 
##                  INDFMPIR1.19                   INDFMPIR1.2 
##                  4.450739e+07                  4.197636e+07 
##                  INDFMPIR1.21                  INDFMPIR1.22 
##                  4.614187e+07                  8.238715e-01 
##                  INDFMPIR1.23                  INDFMPIR1.24 
##                  6.349243e-01                  2.087792e-01 
##                  INDFMPIR1.25                  INDFMPIR1.26 
##                  1.447151e+00                  5.897370e-01 
##                  INDFMPIR1.27                  INDFMPIR1.28 
##                  1.100264e+00                  4.438838e+07 
##                  INDFMPIR1.29                   INDFMPIR1.3 
##                  5.651246e-01                  4.382783e+07 
##                  INDFMPIR1.31                  INDFMPIR1.32 
##                  4.385218e-01                  7.272323e-01 
##                  INDFMPIR1.33                  INDFMPIR1.34 
##                  4.620909e+07                  4.609744e+07 
##                  INDFMPIR1.35                  INDFMPIR1.36 
##                  4.280961e+07                  3.932854e+07 
##                  INDFMPIR1.37                  INDFMPIR1.38 
##                  4.175996e-01                  4.123379e+07 
##                  INDFMPIR1.39                   INDFMPIR1.4 
##                  5.862591e-01                  4.320726e+07 
##                  INDFMPIR1.41                  INDFMPIR1.42 
##                  2.727477e-01                  1.176817e+00 
##                  INDFMPIR1.43                  INDFMPIR1.44 
##                  3.991960e-01                  5.205304e-01 
##                  INDFMPIR1.46                  INDFMPIR1.47 
##                  4.380736e+07                  4.502604e+07 
##                  INDFMPIR1.48                  INDFMPIR1.49 
##                  1.160501e+00                  2.293283e-01 
##                   INDFMPIR1.5                  INDFMPIR1.51 
##                  4.162226e+07                  8.186907e-01 
##                  INDFMPIR1.52                  INDFMPIR1.53 
##                  9.736183e-01                  3.486477e-01 
##                  INDFMPIR1.54                  INDFMPIR1.55 
##                  4.645007e+07                  1.616034e+00 
##                  INDFMPIR1.56                  INDFMPIR1.57 
##                  4.346530e+07                  1.181875e+00 
##                  INDFMPIR1.58                  INDFMPIR1.59 
##                  4.318016e+07                  4.304960e-01 
##                   INDFMPIR1.6                  INDFMPIR1.61 
##                  1.220424e+00                  1.558906e+00 
##                  INDFMPIR1.62                  INDFMPIR1.64 
##                  1.797843e+00                  1.252631e+00 
##                  INDFMPIR1.65                  INDFMPIR1.66 
##                  1.670514e+00                  4.549447e+07 
##                  INDFMPIR1.67                  INDFMPIR1.68 
##                  7.586889e-01                  4.705129e+07 
##                  INDFMPIR1.69                   INDFMPIR1.7 
##                  2.804121e+00                  4.498580e+07 
##                  INDFMPIR1.71                  INDFMPIR1.72 
##                  3.898081e+00                  2.865647e-01 
##                  INDFMPIR1.73                  INDFMPIR1.74 
##                  4.367911e+07                  4.883021e+07 
##                  INDFMPIR1.75                  INDFMPIR1.76 
##                  4.393291e+07                  4.302098e+07 
##                  INDFMPIR1.77                  INDFMPIR1.78 
##                  2.498243e+00                  4.130350e-01 
##                  INDFMPIR1.79                   INDFMPIR1.8 
##                  5.171422e+07                  4.549675e+07 
##                  INDFMPIR1.81                  INDFMPIR1.82 
##                  6.680735e-01                  4.463554e+07 
##                  INDFMPIR1.83                  INDFMPIR1.84 
##                  4.082111e+07                  1.330685e+00 
##                  INDFMPIR1.85                  INDFMPIR1.86 
##                  1.006468e+00                  6.036663e-01 
##                  INDFMPIR1.87                  INDFMPIR1.88 
##                  4.991334e+07                  4.428575e+07 
##                  INDFMPIR1.89                   INDFMPIR1.9 
##                  2.413293e-01                  2.034574e-01 
##                  INDFMPIR1.91                  INDFMPIR1.92 
##                  7.873015e-01                  1.063131e+00 
##                  INDFMPIR1.93                  INDFMPIR1.94 
##                  4.117936e+07                  1.799245e+00 
##                  INDFMPIR1.95                  INDFMPIR1.96 
##                  4.365465e+07                  5.543104e-10 
##                  INDFMPIR1.97                  INDFMPIR1.98 
##                  4.382509e+07                  1.134003e+00 
##                  INDFMPIR1.99                     INDFMPIR2 
##                  1.153502e+00                  4.511782e+07 
##    INDFMPIR2.0099999999999998                  INDFMPIR2.02 
##                  5.806212e-01                  4.216963e+07 
##    INDFMPIR2.0299999999999998                  INDFMPIR2.04 
##                  2.441907e+00                  4.116681e+07 
##    INDFMPIR2.0499999999999998                  INDFMPIR2.06 
##                  7.153281e-01                  4.171114e+07 
##    INDFMPIR2.0699999999999998                  INDFMPIR2.08 
##                  4.055840e+07                  4.690726e+07 
##                  INDFMPIR2.09                   INDFMPIR2.1 
##                  1.030269e+00                  4.513622e+07 
##                  INDFMPIR2.11                  INDFMPIR2.12 
##                  4.565126e+07                  4.624324e+07 
##                  INDFMPIR2.13                  INDFMPIR2.14 
##                  2.880716e+00                  3.892650e+07 
##                  INDFMPIR2.15                  INDFMPIR2.16 
##                  4.391014e+07                  1.265480e+00 
##                  INDFMPIR2.17    INDFMPIR2.1800000000000002 
##                  6.236309e-01                  1.053087e+00 
##                  INDFMPIR2.19    INDFMPIR2.2000000000000002 
##                  4.728774e+07                  4.786282e+07 
##                  INDFMPIR2.21    INDFMPIR2.2200000000000002 
##                  4.116499e+00                  4.748352e+07 
##                  INDFMPIR2.23    INDFMPIR2.2400000000000002 
##                  3.948317e+07                  4.514169e+07 
##                  INDFMPIR2.25    INDFMPIR2.2599999999999998 
##                  4.397097e+07                  4.640347e+07 
##                  INDFMPIR2.27    INDFMPIR2.2799999999999998 
##                  4.087062e+07                  4.456539e-01 
##                  INDFMPIR2.29    INDFMPIR2.2999999999999998 
##                  4.597776e+07                  4.693100e+07 
##                  INDFMPIR2.31    INDFMPIR2.3199999999999998 
##                  1.893297e+00                  4.732166e-01 
##                  INDFMPIR2.33                  INDFMPIR2.34 
##                  1.518347e+00                  4.531473e+07 
##                  INDFMPIR2.35                  INDFMPIR2.36 
##                  2.615630e-01                  6.712318e-01 
##                  INDFMPIR2.37                  INDFMPIR2.38 
##                  4.022215e+07                  4.146222e+07 
##                  INDFMPIR2.39                   INDFMPIR2.4 
##                  9.516179e-01                  2.321982e+00 
##                  INDFMPIR2.41                  INDFMPIR2.42 
##                  4.580423e+07                  4.655776e+07 
##    INDFMPIR2.4300000000000002                  INDFMPIR2.44 
##                  2.015926e+00                  4.293800e+07 
##    INDFMPIR2.4500000000000002                  INDFMPIR2.46 
##                  1.402153e-01                  4.353435e+07 
##    INDFMPIR2.4700000000000002                  INDFMPIR2.48 
##                  1.034279e+00                  6.419161e-01 
##    INDFMPIR2.4900000000000002                   INDFMPIR2.5 
##                  7.383300e-01                  4.513635e+07 
##    INDFMPIR2.5099999999999998                  INDFMPIR2.52 
##                  5.464843e-01                  4.552477e+07 
##    INDFMPIR2.5299999999999998                  INDFMPIR2.54 
##                  4.351252e+07                  4.473501e+07 
##    INDFMPIR2.5499999999999998                  INDFMPIR2.56 
##                  4.697352e+07                  3.495438e-01 
##                  INDFMPIR2.57                  INDFMPIR2.58 
##                  1.343376e-01                  7.887983e-01 
##                  INDFMPIR2.59                  INDFMPIR2.61 
##                  4.252363e+07                  1.981740e+00 
##                  INDFMPIR2.62                  INDFMPIR2.63 
##                  1.421842e+00                  4.272213e+07 
##                  INDFMPIR2.64                  INDFMPIR2.65 
##                  4.838392e+07                  4.078426e+07 
##                  INDFMPIR2.66                  INDFMPIR2.67 
##                  4.086626e+07                  4.311695e+07 
##                  INDFMPIR2.68                  INDFMPIR2.69 
##                  5.132589e+07                  4.530937e+07 
##                   INDFMPIR2.7                  INDFMPIR2.71 
##                  4.522562e+07                  4.006871e-01 
##                  INDFMPIR2.72                  INDFMPIR2.73 
##                  4.897466e+07                  1.930432e+00 
##                  INDFMPIR2.74                  INDFMPIR2.75 
##                  1.636896e+00                  4.043038e+07 
##                  INDFMPIR2.76                  INDFMPIR2.77 
##                  2.526831e-01                  4.685956e+07 
##                  INDFMPIR2.78                  INDFMPIR2.79 
##                  4.430187e+07                  1.642648e+00 
##                   INDFMPIR2.8                  INDFMPIR2.81 
##                  9.871138e-01                  4.187135e+07 
##                  INDFMPIR2.82                  INDFMPIR2.83 
##                  4.482644e+07                  3.258024e-01 
##                  INDFMPIR2.84                  INDFMPIR2.85 
##                  4.098233e+07                  4.657186e+07 
##                  INDFMPIR2.86                  INDFMPIR2.87 
##                  4.294838e+07                  8.431920e-01 
##                  INDFMPIR2.88                  INDFMPIR2.89 
##                  4.271753e-01                  4.198953e+07 
##                   INDFMPIR2.9                  INDFMPIR2.91 
##                  4.498827e-10                  4.350782e+07 
##                  INDFMPIR2.92                  INDFMPIR2.93 
##                  2.346151e+00                  4.215804e+07 
##                  INDFMPIR2.94                  INDFMPIR2.95 
##                  2.858561e+00                  1.009524e+00 
##                  INDFMPIR2.96                  INDFMPIR2.98 
##                  4.306463e-01                  4.670439e+07 
##                     INDFMPIR3                  INDFMPIR3.02 
##                  1.220258e+00                  2.122968e+00 
##                  INDFMPIR3.03                  INDFMPIR3.04 
##                  4.764318e+07                  3.543911e+00 
##                  INDFMPIR3.06                  INDFMPIR3.07 
##                  1.239188e+00                  4.370101e+07 
##                  INDFMPIR3.08                  INDFMPIR3.09 
##                  4.385600e+07                  2.743114e+00 
##                   INDFMPIR3.1                  INDFMPIR3.11 
##                  5.004828e+07                  1.193574e+00 
##                  INDFMPIR3.12                  INDFMPIR3.13 
##                  2.637789e-01                  3.955022e-01 
##                  INDFMPIR3.14                  INDFMPIR3.15 
##                  7.875048e-01                  2.864919e-01 
##                  INDFMPIR3.16                  INDFMPIR3.17 
##                  4.342513e+07                  4.265193e+07 
##                  INDFMPIR3.18                  INDFMPIR3.19 
##                  4.881977e+07                  4.815997e+07 
##                  INDFMPIR3.21                  INDFMPIR3.22 
##                  5.453810e+07                  1.804578e+00 
##                  INDFMPIR3.23                  INDFMPIR3.24 
##                  4.407279e+07                  7.522680e-01 
##                  INDFMPIR3.25                  INDFMPIR3.26 
##                  4.786003e+07                  4.385301e+07 
##                  INDFMPIR3.27                  INDFMPIR3.28 
##                  4.563412e+07                  1.508985e+00 
##                  INDFMPIR3.29                   INDFMPIR3.3 
##                  4.227409e+07                  1.320419e+00 
##                  INDFMPIR3.31                  INDFMPIR3.32 
##                  4.246454e+07                  4.547880e+07 
##                  INDFMPIR3.33                  INDFMPIR3.34 
##                  1.008329e+00                  4.351523e+07 
##                  INDFMPIR3.35                  INDFMPIR3.36 
##                  4.032074e+07                  4.862061e+07 
##                  INDFMPIR3.37                  INDFMPIR3.38 
##                  4.197167e+07                  4.059045e-01 
##                  INDFMPIR3.39                   INDFMPIR3.4 
##                  3.989386e-01                  4.376836e+07 
##                  INDFMPIR3.41                  INDFMPIR3.42 
##                  4.754377e+07                  1.703760e+00 
##                  INDFMPIR3.43                  INDFMPIR3.44 
##                  2.709977e+00                  4.157900e+07 
##                  INDFMPIR3.45                  INDFMPIR3.46 
##                  4.789247e+07                  4.355748e+07 
##                  INDFMPIR3.47                  INDFMPIR3.49 
##                  9.973770e-01                  4.369567e+07 
##                   INDFMPIR3.5                  INDFMPIR3.52 
##                  4.611256e+07                  5.103140e+07 
##                  INDFMPIR3.53                  INDFMPIR3.54 
##                  4.134920e+07                  3.828639e+07 
##                  INDFMPIR3.55                  INDFMPIR3.56 
##                  5.265949e-01                  4.234524e+07 
##                  INDFMPIR3.57                  INDFMPIR3.58 
##                  4.373350e+07                  4.437310e+07 
##                   INDFMPIR3.6                  INDFMPIR3.61 
##                  2.960396e+00                  3.674778e+07 
##                  INDFMPIR3.62                  INDFMPIR3.64 
##                  4.618906e+07                  4.311165e+07 
##                  INDFMPIR3.65                  INDFMPIR3.66 
##                  2.677091e-01                  4.046282e+07 
##                  INDFMPIR3.67                  INDFMPIR3.68 
##                  4.528656e+07                  2.212368e+00 
##                  INDFMPIR3.69                   INDFMPIR3.7 
##                  4.568398e+07                  8.111827e-01 
##                  INDFMPIR3.71                  INDFMPIR3.72 
##                  1.362349e-01                  4.053638e+07 
##                  INDFMPIR3.73                  INDFMPIR3.74 
##                  4.301742e+07                  4.991334e+07 
##                  INDFMPIR3.75                  INDFMPIR3.76 
##                  4.515650e+07                  6.659482e-01 
##                  INDFMPIR3.77                  INDFMPIR3.78 
##                  4.301138e+07                  4.520229e+07 
##                   INDFMPIR3.8                  INDFMPIR3.82 
##                  4.070629e+07                  4.187250e+07 
##                  INDFMPIR3.83                  INDFMPIR3.84 
##                  3.603761e-01                  4.894201e+07 
##                  INDFMPIR3.85                  INDFMPIR3.86 
##                  4.860395e+07                  4.455630e+07 
##                  INDFMPIR3.87                  INDFMPIR3.88 
##                  4.450630e+07                  4.362107e+07 
##                  INDFMPIR3.89                   INDFMPIR3.9 
##                  5.125800e+07                  8.144911e-01 
##                  INDFMPIR3.91                  INDFMPIR3.92 
##                  4.197437e+07                  4.246723e-01 
##                  INDFMPIR3.93                  INDFMPIR3.94 
##                  2.737227e-01                  4.885276e+07 
##                  INDFMPIR3.96                  INDFMPIR3.97 
##                  1.786878e+00                  4.563246e+07 
##                  INDFMPIR3.98                  INDFMPIR3.99 
##                  4.310238e+07                  3.985266e+07 
##                     INDFMPIR4                  INDFMPIR4.01 
##                  6.301086e-01                  4.016786e+07 
##    INDFMPIR4.0199999999999996                  INDFMPIR4.03 
##                  4.328514e+07                  1.648680e-01 
##                  INDFMPIR4.04                  INDFMPIR4.05 
##                  4.462736e+07                  4.170074e+07 
##    INDFMPIR4.0599999999999996                  INDFMPIR4.08 
##                  2.172180e+00                  4.732892e+07 
##    INDFMPIR4.0999999999999996    INDFMPIR4.1100000000000003 
##                  4.487881e+07                  4.310238e+07 
##                  INDFMPIR4.12                  INDFMPIR4.13 
##                  4.463726e+07                  4.443893e+07 
##    INDFMPIR4.1399999999999997    INDFMPIR4.1500000000000004 
##                  4.938229e+07                  2.699163e-01 
##                  INDFMPIR4.16                  INDFMPIR4.17 
##                  5.217450e+07                  4.488042e+07 
##                  INDFMPIR4.18    INDFMPIR4.1900000000000004 
##                  4.097166e+07                  4.641786e+07 
##                  INDFMPIR4.21                  INDFMPIR4.22 
##                  4.272535e+07                  7.146516e-01 
##    INDFMPIR4.2300000000000004                  INDFMPIR4.25 
##                  4.083144e+07                  4.687695e+07 
##                  INDFMPIR4.26    INDFMPIR4.2699999999999996 
##                  4.008408e+07                  4.440273e+07 
##                  INDFMPIR4.29                   INDFMPIR4.3 
##                  4.285973e+07                  4.565785e+07 
##    INDFMPIR4.3099999999999996                  INDFMPIR4.32 
##                  4.413637e+07                  4.585201e+07 
##                  INDFMPIR4.33                  INDFMPIR4.34 
##                  1.038907e+00                  1.033419e+00 
##    INDFMPIR4.3600000000000003                  INDFMPIR4.37 
##                  1.294674e-01                  3.480812e+00 
##    INDFMPIR4.4000000000000004                  INDFMPIR4.41 
##                  4.726381e+07                  4.307099e+07 
##                  INDFMPIR4.42                  INDFMPIR4.43 
##                  3.094151e+00                  4.666695e+07 
##    INDFMPIR4.4400000000000004                  INDFMPIR4.45 
##                  4.572308e+07                  4.692598e+07 
##                  INDFMPIR4.46    INDFMPIR4.4800000000000004 
##                  4.285045e+07                  4.025264e+07 
##                  INDFMPIR4.49                   INDFMPIR4.5 
##                  5.058120e+07                  4.969302e+07 
##                  INDFMPIR4.51                  INDFMPIR4.53 
##                  3.878960e+07                  4.747577e+07 
##                  INDFMPIR4.54                  INDFMPIR4.55 
##                  4.516342e+07                  4.452026e+07 
##    INDFMPIR4.5599999999999996                  INDFMPIR4.57 
##                  3.133422e+00                  4.507759e+07 
##                  INDFMPIR4.59    INDFMPIR4.5999999999999996 
##                  4.273507e+07                  3.982242e+07 
##    INDFMPIR4.6100000000000003                  INDFMPIR4.62 
##                  4.073253e+07                  2.678288e-01 
##                  INDFMPIR4.63    INDFMPIR4.6399999999999997 
##                  4.363333e+07                  4.255365e+07 
##                  INDFMPIR4.66                  INDFMPIR4.67 
##                  4.028948e+07                  1.236948e+00 
##                  INDFMPIR4.68    INDFMPIR4.6900000000000004 
##                  4.547371e+07                  4.076333e+07 
##                  INDFMPIR4.71                  INDFMPIR4.72 
##                  1.246511e-01                  3.743159e-01 
##    INDFMPIR4.7300000000000004                  INDFMPIR4.75 
##                  4.162226e+07                  3.962251e+07 
##                  INDFMPIR4.78                   INDFMPIR4.8 
##                  4.381843e+07                  4.141644e+07 
##    INDFMPIR4.8099999999999996                  INDFMPIR4.82 
##                  4.527775e+07                  4.365289e+07 
##                  INDFMPIR4.83    INDFMPIR4.8600000000000003 
##                  4.542169e+07                  4.657411e+07 
##                  INDFMPIR4.87                  INDFMPIR4.88 
##                  4.446010e+07                  7.277901e-01 
##    INDFMPIR4.8899999999999997    INDFMPIR4.9000000000000004 
##                  4.497852e+07                  4.160140e+07 
##                  INDFMPIR4.92                  INDFMPIR4.93 
##                  2.595307e+00                  5.764556e-01 
##    INDFMPIR4.9400000000000004                  INDFMPIR4.95 
##                  7.192768e-01                  4.428575e+07 
##                  INDFMPIR4.97                  INDFMPIR4.99 
##                  4.281619e+07                  4.969268e+07 
##                     INDFMPIR5 INDFMPIR7.0000000000000007E-2 
##                  2.637055e+00                  2.983145e-01 
##                    INDFMPIRNA 
##                  1.240672e+00
# Plot Predicted Probabilities
data$predicted <- predict(model3, type = "response")

ggplot(data, aes(x = RIDAGEYR, y = predicted, color = RIAGENDR)) +
  geom_point(alpha = 0.5) +
  geom_smooth(method = "glm", method.args = list(family = "binomial"), se = FALSE) +
  labs(title = "Predicted Probability of Having Ever Consumed Alcohol",
       x = "Age", y = "Predicted Probability") +
  theme_minimal()
## `geom_smooth()` using formula = 'y ~ x'
## Warning in eval(family$initialize): non-integer #successes in a binomial glm!
## Warning in eval(family$initialize): non-integer #successes in a binomial glm!

My R script performs a logistic regression analysis to predict whether an individual has ever consumed alcohol, based on demographic and income variables from the NHANES dataset. I begin by loading the necessary libraries (dplyr, ggplot2, car, MASS, lmtest, readxl), which are essential for data manipulation, visualization, multicollinearity checks, and model comparison. The three datasets—Income, Alcohol Use, and Demography are read into R and assigned to the variables Income, Alcohol, and Demo for easier reference. I merge these datasets using the SEQN (Respondent ID) column to ensure that all participant data aligns correctly. To prevent errors later in the script, I print column names (print(colnames(data))) to confirm the presence of key variables before proceeding. Additionally, I implement a column existence check (setdiff()) to verify that the required variables (ALQ111, RIAGENDR, RIDAGEYR, INDFMPIR) exist in the dataset. If any of these variables are missing, the script automatically stops execution and displays an error message to prompt correction.

I then prepare the dataset for logistic regression by recoding and selecting relevant variables. The ALQ111 variable, which indicates whether a participant has ever consumed alcohol, is recoded to a binary format (1 = Yes, 0 = No), ensuring compatibility with the logistic regression model. To maintain only the most relevant predictors, I manually select RIAGENDR (gender), RIDAGEYR (age), and INDFMPIR (income-to-poverty ratio) while removing missing values (na.omit()) to ensure a clean dataset. Since RIAGENDR is categorical, I convert it into a factor variable to allow proper interpretation in the model. I then construct three logistic regression models with increasing complexity: Model 1 includes only gender as a predictor, Model 2 adds age, and Model 3 (the full model) further incorporates income. This stepwise modeling approach allows me to assess how additional variables improve the model’s ability to predict alcohol consumption.

To evaluate model performance, I apply several statistical tests and model selection criteria. Likelihood Ratio Tests (LRT) compare nested models (model1 vs. model2, model2 vs. model3) to determine whether adding predictors significantly improves model fit. Additionally, I calculate Akaike Information Criterion (AIC) and Bayesian Information Criterion (BIC) values for each model, selecting the model with the lowest values as the best fit. Since multicollinearity can distort regression results, I check for it using the Variance Inflation Factor (VIF) to ensure that independent variables are not highly correlated. Finally, I compute odds ratios (exp(coef(model3))) to translate log-odds into more interpretable probability ratios. To visually represent the model’s predictions, I create a ggplot2 visualization of the predicted probability of alcohol consumption across different age groups and genders. This combination of statistical tests, model selection criteria, and graphical interpretation ensures that my analysis is both rigorous and easy to interpret.

Based on the LRT results, AIC/BIC values, and VIF checks, I determine the best model for predicting alcohol consumption. Model 3 (ALQ111 ~ RIAGENDR + RIDAGEYR + INDFMPIR) is selected as the best model because it has the lowest AIC and BIC values, meaning it balances predictive accuracy with model complexity. Additionally, the LRT confirms that adding age and income significantly improves model performance, meaning these variables provide valuable predictive power. Finally, VIF values are below 5, indicating that multicollinearity is not a concern, and each predictor contributes meaningful and independent information. Therefore, Model 3 is the most reliable and interpretable choice for predicting whether an individual has ever consumed alcohol, highlighting how gender, age, and income levels influence alcohol consumption trends.

Programming Assignment

Github Repository Link: https://github.com/mdfardin1/Data-712---Homework-4

Github: https://github.com/mdfardin1