Last updated: 2025-03-05

Checks: 6 1

Knit directory: QUAIL-Mex/

This reproducible R Markdown analysis was created with workflowr (version 1.7.1). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


The R Markdown file has unstaged changes. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20241009) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version eed8107. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .DS_Store
    Ignored:    .RData
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    analysis/.DS_Store
    Ignored:    analysis/.RData
    Ignored:    analysis/.Rhistory
    Ignored:    code/.DS_Store
    Ignored:    data/.DS_Store

Unstaged changes:
    Modified:   Filtered_Screening.csv
    Modified:   analysis/Filtered_Screening.csv
    Modified:   analysis/HBA2025_cleaning.Rmd
    Modified:   analysis/Regression-Analysis_PC.Rmd
    Modified:   data/00.SCREENING_V2.csv
    Modified:   data/01.SCREENING.csv
    Modified:   data/Cleaned_Dataset_Screening_HWISE_PSS.csv
    Modified:   data/Cleaned_Dataset_Screening_HWISE_PSS_V2.csv

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/Regression-Analysis_PC.Rmd) and HTML (docs/Regression-Analysis_PC.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 4a934f3 Paloma 2025-03-04 incl research qs
html 4a934f3 Paloma 2025-03-04 incl research qs
Rmd 6738718 Paloma 2025-03-04 new regressions
html 6738718 Paloma 2025-03-04 new regressions
Rmd f0811f0 Paloma 2025-03-04 reduced NAs


Attaching package: 'mice'
The following object is masked from 'package:stats':

    filter
The following objects are masked from 'package:base':

    cbind, rbind
Loading required package: Matrix
Loaded glmnet 4.1-8

1 Introduction

Our research questions are:

  1. What variables measured using Paloma’s questionnaires are good predictors of HWISE total scores?

  2. What HWISE questions are good predictors of alternative water insecurity measurements, such as hours of water supply (HRS_WEEK), or type of supply (continuous or intermittent, W_WC_WI)?

  3. Does water insecurity has any association with Perceived stress scores (PSS)? If so, what variables/aspects of water insecurity are driving this stress levels?

Here I repeat the analyses conducted by Junhui He, but adding and removing a few variables that could make more sense as predictors of the Total HWISE score or Total PSS score. These are the two linear regression models we run earlier:

  1. HW_TOTAL ~ D_AGE + D_HH_SIZE + D_CHLD + HLTH_SMK + HLTH_CPAIN_CAT + HLTH_CDIS_CAT + SES_SC_Total

  2. PSS_TOTAL ~ D_AGE + D_HH_SIZE + D_CHLD + HLTH_SMK + HLTH_CPAIN_CAT + HLTH_CDIS_CAT + SES_SC_Total

The two new linear regression models are different from the previous ones:

  1. Removed HLTH_SMK, HLTH_CPAIN_CAT, and HLTH_CDIS_CAT

  2. Added D_LOC_TIME, SEASON, W_WS_LOC, W_WC_WI, HRS_WEEK

  3. Added HWISE_TOTAL as potential predictor of PSS

1.b Variable descriptions for quick reference

  • D_AGE: Participants’ age (18:49)
  • D_CHLD: Number of children participant has birthed (0:8)
  • D_HH_SIZE: Household size (2:40)
  • D_LOC_TIME: For how long have you lived in this neighborhood? (1:46 years)
  • HLTH_CDIS_CAT: Presence of chronic disease (1= yes, 0 = no)
  • HLTH_CPAIN_CAT: Presence of chronic pain (1= yes, 0 = no)
  • HLTH_SMK: Tabacco smoker (1= yes, 0 = no)
  • HRS_WEEK: Hours of water supply in the household per week (0:168)
  • HW_TOTAL: Sum of all 12-items in HWISE questionnaire (0:27)
  • PSS_TOTAL: Total Perceived Stress Score (-19:19)
  • SEASON: Fall or Spring (when data collection happened) (Fall= 1, Spring = 0)
  • SES_SC_Total: Socioeconomic status score (25:263)
  • W_WS_LOC: Classification of neighborhoods as water secure or insecure, according to reports from Mexico City water system (1= water insecure, 0= water secure)
  • W_WC_WI: Classification of water supply as continuous or intermittent, according to participants (1= intermittent, 0 = continuous)

2 Data preparation

  1. We remove rows with missing data.

  2. HW_TOTAL is calculated by adding up all the HWISE scores; PSS_TOTAL is calculated by adding up PSS 1,2,3, 8, 11, 12, 14, and substracting 4,5,6,7,9,10, and 13.

[1] 402  12
[1] 262  12
 [1] "ID"           "D_LOC_TIME"   "D_AGE"        "D_HH_SIZE"    "D_CHLD"      
 [6] "SES_SC_Total" "SEASON"       "W_WS_LOC"     "HW_TOTAL"     "W_WC_WI"     
[11] "HRS_WEEK"     "PSS_TOTAL"   

3 Results

3.1 HWISE scores, variable set 1

The regression results for HW is summarized as follows.


Call:
lm(formula = HW_TOTAL ~ D_AGE + D_HH_SIZE + D_CHLD + SES_SC_Total, 
    data = reg_dataset)

Residuals:
    Min      1Q  Median      3Q     Max 
-9.2625 -4.7048 -0.9282  4.2555 17.6891 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept)  13.600647   2.159219   6.299 1.29e-09 ***
D_AGE        -0.076564   0.057009  -1.343    0.180    
D_HH_SIZE    -0.084970   0.107605  -0.790    0.430    
D_CHLD        0.046960   0.352601   0.133    0.894    
SES_SC_Total -0.018117   0.008953  -2.024    0.044 *  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 6.124 on 257 degrees of freedom
Multiple R-squared:  0.02832,   Adjusted R-squared:  0.0132 
F-statistic: 1.873 on 4 and 257 DF,  p-value: 0.1156

The goodness-of-fit for HW regression is given as follow.

Version Author Date
6738718 Paloma 2025-03-04

3.2 HWISE scores, variable set 2


Call:
lm(formula = HW_TOTAL ~ D_LOC_TIME + SEASON + W_WS_LOC + W_WC_WI + 
    HRS_WEEK + D_AGE + D_HH_SIZE + D_CHLD + SES_SC_Total, data = reg_dataset)

Residuals:
    Min      1Q  Median      3Q     Max 
-9.8823 -4.4929 -0.7663  4.0314 17.5559 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept)  15.946426   2.491707   6.400 7.54e-10 ***
D_LOC_TIME   -0.030220   0.033409  -0.905  0.36657    
SEASON       -1.885870   0.774229  -2.436  0.01555 *  
W_WS_LOC     -3.000324   1.027754  -2.919  0.00383 ** 
W_WC_WI       1.035090   1.102460   0.939  0.34869    
HRS_WEEK     -0.040097   0.008754  -4.581 7.29e-06 ***
D_AGE         0.011383   0.057627   0.198  0.84357    
D_HH_SIZE    -0.007035   0.104872  -0.067  0.94657    
D_CHLD       -0.214297   0.325448  -0.658  0.51084    
SES_SC_Total -0.011439   0.008343  -1.371  0.17154    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 5.606 on 252 degrees of freedom
Multiple R-squared:  0.2018,    Adjusted R-squared:  0.1733 
F-statistic:  7.08 on 9 and 252 DF,  p-value: 3.92e-09

The goodness-of-fit for HW regression is given as follow.

Version Author Date
6738718 Paloma 2025-03-04

3.2 HWISE scores, variable set 3


Call:
lm(formula = HW_TOTAL ~ SEASON + W_WS_LOC + W_WC_WI + HRS_WEEK + 
    D_AGE + D_HH_SIZE + D_CHLD + SES_SC_Total, data = reg_dataset)

Residuals:
   Min     1Q Median     3Q    Max 
-9.717 -4.308 -0.771  4.064 17.245 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept)  15.985393   2.490439   6.419 6.74e-10 ***
SEASON       -1.797281   0.767734  -2.341  0.02001 *  
W_WS_LOC     -3.077229   1.023863  -3.006  0.00292 ** 
W_WC_WI       1.053522   1.101875   0.956  0.33993    
HRS_WEEK     -0.040644   0.008730  -4.656 5.21e-06 ***
D_AGE        -0.005812   0.054382  -0.107  0.91497    
D_HH_SIZE    -0.010636   0.104758  -0.102  0.91921    
D_CHLD       -0.211853   0.325320  -0.651  0.51550    
SES_SC_Total -0.012339   0.008280  -1.490  0.13741    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 5.604 on 253 degrees of freedom
Multiple R-squared:  0.1992,    Adjusted R-squared:  0.1739 
F-statistic: 7.868 on 8 and 253 DF,  p-value: 1.916e-09

The goodness-of-fit for HW regression is given as follow.

3.2 HWISE scores, variable set 4


Call:
lm(formula = HW_TOTAL ~ SEASON + W_WS_LOC + W_WC_WI + HRS_WEEK + 
    D_CHLD + SES_SC_Total, data = reg_dataset)

Residuals:
    Min      1Q  Median      3Q     Max 
-9.7743 -4.3379 -0.7549  4.0482 17.3124 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept)  15.813882   2.026777   7.802 1.56e-13 ***
SEASON       -1.836270   0.705752  -2.602  0.00981 ** 
W_WS_LOC     -3.070875   1.015816  -3.023  0.00276 ** 
W_WC_WI       1.053914   1.097471   0.960  0.33781    
HRS_WEEK     -0.040636   0.008671  -4.686 4.53e-06 ***
D_CHLD       -0.230475   0.286177  -0.805  0.42136    
SES_SC_Total -0.012503   0.008075  -1.548  0.12279    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 5.582 on 255 degrees of freedom
Multiple R-squared:  0.1992,    Adjusted R-squared:  0.1803 
F-statistic: 10.57 on 6 and 255 DF,  p-value: 1.767e-10

The goodness-of-fit for HW regression is given as follow.

3.3 PSS

The regression results for PSS is summarized as follows.


Call:
lm(formula = PSS_TOTAL ~ D_LOC_TIME + SEASON + W_WS_LOC + W_WC_WI + 
    HRS_WEEK + D_AGE + D_HH_SIZE + D_CHLD + SES_SC_Total + HW_TOTAL, 
    data = reg_dataset)

Residuals:
     Min       1Q   Median       3Q      Max 
-19.0550  -4.8291  -0.1743   5.3913  20.0950 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)  
(Intercept)  -1.66599    3.47779  -0.479   0.6323  
D_LOC_TIME   -0.04002    0.04332  -0.924   0.3565  
SEASON        0.51838    1.01398   0.511   0.6096  
W_WS_LOC      0.54594    1.35275   0.404   0.6869  
W_WC_WI       1.22134    1.42964   0.854   0.3938  
HRS_WEEK      0.01046    0.01179   0.887   0.3758  
D_AGE        -0.10024    0.07460  -1.344   0.1803  
D_HH_SIZE    -0.15080    0.13576  -1.111   0.2677  
D_CHLD        0.81839    0.42166   1.941   0.0534 .
SES_SC_Total  0.00282    0.01084   0.260   0.7950  
HW_TOTAL      0.20595    0.08155   2.526   0.0122 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 7.256 on 251 degrees of freedom
Multiple R-squared:  0.05836,   Adjusted R-squared:  0.02085 
F-statistic: 1.556 on 10 and 251 DF,  p-value: 0.1204

The goodness-of-fit for PSS regression is given as follow.

Version Author Date
6738718 Paloma 2025-03-04

3.4 Predictors for hours of water supply

WORK IN PROGRESS I intend to add each HWISE question in these models


Call:
lm(formula = HRS_WEEK ~ D_LOC_TIME + SEASON + W_WS_LOC + W_WC_WI + 
    HW_TOTAL + D_AGE + D_HH_SIZE + D_CHLD + SES_SC_Total, data = reg_dataset)

Residuals:
     Min       1Q   Median       3Q      Max 
-119.632  -16.653   -4.512   10.673  140.898 

Coefficients:
               Estimate Std. Error t value Pr(>|t|)    
(Intercept)  172.365095  15.071513  11.436  < 2e-16 ***
D_LOC_TIME     0.185421   0.231072   0.802    0.423    
SEASON         5.074447   5.406358   0.939    0.349    
W_WS_LOC     -64.933048   5.955871 -10.902  < 2e-16 ***
W_WC_WI      -61.087640   6.595358  -9.262  < 2e-16 ***
HW_TOTAL      -1.916881   0.418478  -4.581 7.29e-06 ***
D_AGE          0.108630   0.398415   0.273    0.785    
D_HH_SIZE     -0.640578   0.723983  -0.885    0.377    
D_CHLD        -0.947912   2.251343  -0.421    0.674    
SES_SC_Total   0.002586   0.057898   0.045    0.964    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 38.76 on 252 degrees of freedom
Multiple R-squared:  0.7043,    Adjusted R-squared:  0.6938 
F-statistic:  66.7 on 9 and 252 DF,  p-value: < 2.2e-16

The goodness-of-fit for HW regression is given as follow.

8 x 1 sparse Matrix of class "dgCMatrix"
                    s0
(Intercept)  0.2513164
D_AGE        .        
D_HH_SIZE    .        
D_CHLD       .        
SES_SC_Total .        
SEASON       .        
W_WS_LOC     .        
HW_TOTAL     0.9700569
8 x 1 sparse Matrix of class "dgCMatrix"
                      s0
(Intercept)  -1.53597039
D_AGE         .         
D_HH_SIZE     .         
D_CHLD        0.01132684
SES_SC_Total  .         
SEASON        .         
W_WS_LOC      .         
HW_TOTAL      0.10045842

4 Discussion

4.1 Comments on results

  1. Unfortunately, the coefficient estimates are not significant except for a few predictors. This indicates the linear dependency between the response (HW_TOTAL or PSS_TOTAL) and the predictors are not significant.

  2. Based on the goodness-of-fit figures, the predictive performance is really bad, which is consistent with the last comment.

4.2 Questions

  1. Is it reasonable to use HW_TOTAL or PSS_TOTAL as response variables and other aforementioned variables as predictors? If not, how should I choose response variables and predictors?

  2. Previously, I mentioned feature selection, a method used to identify the most influential variables among a set of predictors. Here, “the most influential variable” refers to one that has a significant impact on the response. However, since your cleaned dataset contains only eight predictors, I believe feature selection is unnecessary. Moreover, feature selection is typically employed to prevent overfitting, whereas our primary problem is underfitting.


R version 4.4.2 (2024-10-31)
Platform: aarch64-apple-darwin20
Running under: macOS Sequoia 15.3.1

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/Detroit
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] glmnet_4.1-8  Matrix_1.7-1  naniar_1.1.0  ggplot2_3.5.1 mice_3.17.0  

loaded via a namespace (and not attached):
 [1] gtable_0.3.6      shape_1.4.6.1     xfun_0.49         bslib_0.8.0      
 [5] visdat_0.6.0      lattice_0.22-6    vctrs_0.6.5       tools_4.4.2      
 [9] Rdpack_2.6.2      generics_0.1.3    tibble_3.2.1      fansi_1.0.6      
[13] pan_1.9           pkgconfig_2.0.3   jomo_2.7-6        lifecycle_1.0.4  
[17] farver_2.1.2      compiler_4.4.2    stringr_1.5.1     git2r_0.35.0     
[21] munsell_0.5.1     codetools_0.2-20  httpuv_1.6.15     htmltools_0.5.8.1
[25] sass_0.4.9        yaml_2.3.10       later_1.3.2       pillar_1.9.0     
[29] nloptr_2.1.1      jquerylib_0.1.4   whisker_0.4.1     tidyr_1.3.1      
[33] MASS_7.3-61       cachem_1.1.0      reformulas_0.4.0  iterators_1.0.14 
[37] rpart_4.1.23      boot_1.3-31       foreach_1.5.2     mitml_0.4-5      
[41] nlme_3.1-166      tidyselect_1.2.1  digest_0.6.37     stringi_1.8.4    
[45] dplyr_1.1.4       purrr_1.0.2       labeling_0.4.3    splines_4.4.2    
[49] rprojroot_2.0.4   fastmap_1.2.0     grid_4.4.2        colorspace_2.1-1 
[53] cli_3.6.3         magrittr_2.0.3    survival_3.7-0    utf8_1.2.4       
[57] broom_1.0.7       withr_3.0.2       scales_1.3.0      promises_1.3.0   
[61] backports_1.5.0   rmarkdown_2.29    nnet_7.3-19       lme4_1.1-36      
[65] workflowr_1.7.1   evaluate_1.0.1    knitr_1.49        rbibutils_2.3    
[69] rlang_1.1.4       Rcpp_1.0.13-1     glue_1.8.0        rstudioapi_0.17.1
[73] minqa_1.2.8       jsonlite_1.8.9    R6_2.5.1          fs_1.6.5