Filters

# filter1 (doesn't include softener)
quest <- quest %>%
  mutate(filter1 = case_when(filter == "Όχι" | filter_type == "Αποσκληρυντικό νερού" ~ "No Filter",
                            filter == "Ναι" ~ "Filter",
                            TRUE ~ NA))
# filter2 (includes softener)
quest <- quest %>%
  mutate(filter2 = case_when(filter == "Ναι" ~ "Filter",
                            filter == "Όχι" ~ "No Filter",
                            TRUE ~ NA))

table(quest$filter1)
## 
##    Filter No Filter 
##        79       134
table(quest$filter2)
## 
##    Filter No Filter 
##       101       112

Abnormal Samples

table(all$abnormal_22, all$abnormal_37)
##           
##            Normal Abnormal
##   Normal      157        3
##   Abnormal     15       40

157 participants have both Normal OMX_22 and OMX_37 samples. 58 participants have at least one abnormal sample: 40 participants have both abnormal sample, 18 participants have 1 abnormal sample.

OMX_22c

# Chi-square loop of all questionnaire variables on abnormal vs normal samples

# List of variables in quest to analyze
variables_to_analyze <- c("filter1", "filter2", "filter_type", "clean_tap",
                          "tap_running", "reduce_flow")

# Create an empty list to store significant variables
significant_variables <- c()

# Loop over each variable
for (variable in variables_to_analyze) {
  # Create a contingency table
  contingency_table <- table(all[[variable]], all$abnormal_22)
  
  # Perform chi-square test
  chi_sq_result <- chisq.test(contingency_table)
  
  # Print the variable name
  cat("Variable:", variable, "\n")
  
  # Check if p-value is less than 0.05
  if (chi_sq_result$p.value < 0.05) {
    significant_variables <- c(significant_variables, variable)
    cat("Significant\n")
  } else {
    cat("Not Significant\n")
  }
  
  cat("\n")
}
## Variable: filter1 
## Significant
## 
## Variable: filter2 
## Significant
## 
## Variable: filter_type 
## Not Significant
## 
## Variable: clean_tap 
## Not Significant
## 
## Variable: tap_running 
## Not Significant
## 
## Variable: reduce_flow 
## Not Significant
# Print significant variables
cat("Significant Variables:", paste(significant_variables, collapse = ", "), "\n")
## Significant Variables: filter1, filter2

Given a p-value of <0.05, there is sufficient evidence to reject the null hypothesis and conclude that there is an association between the variables “abnormal_22” and filter, with (2) and without (1) including softener.

# Filter is signficant

# Fit logistic regression model for abnormal_22 and filter1 (doesn't include softener)
model1 <- glm(abnormal_22 ~ filter1, data = all, family = binomial)

summary(model1)
## 
## Call:
## glm(formula = abnormal_22 ~ filter1, family = binomial, data = all)
## 
## Coefficients:
##                  Estimate Std. Error z value Pr(>|z|)   
## (Intercept)       -0.4906     0.2318  -2.116  0.03431 * 
## filter1No Filter  -0.9818     0.3208  -3.061  0.00221 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 243.32  on 212  degrees of freedom
## Residual deviance: 233.87  on 211  degrees of freedom
##   (2 observations deleted due to missingness)
## AIC: 237.87
## 
## Number of Fisher Scoring iterations: 4
# Fit logistic regression model for abnormal_22 and filter2 (includes softener)
model2 <- glm(abnormal_22 ~ filter2, data = all, family = binomial)

summary(model2)
## 
## Call:
## glm(formula = abnormal_22 ~ filter2, family = binomial, data = all)
## 
## Coefficients:
##                  Estimate Std. Error z value Pr(>|z|)    
## (Intercept)       -0.4636     0.2044  -2.268   0.0233 *  
## filter2No Filter  -1.3282     0.3387  -3.922 8.78e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 243.32  on 212  degrees of freedom
## Residual deviance: 226.60  on 211  degrees of freedom
##   (2 observations deleted due to missingness)
## AIC: 230.6
## 
## Number of Fisher Scoring iterations: 4

The model suggests that filter significantly affects the odds of the outcome (both including and excluding softener as a filter):

Not having a filter (“No Filter”) is associated with lower odds of having a normal OMX_22 sample; having a filter is associated with higher odds of having a normal OMX_22 sample.

OMX_37c

# Chi-square loop of all questionnaire variables on abnormal vs normal samples

# List of variables in quest to analyze
variables_to_analyze <- c("filter1", "filter2", "filter_type", "clean_tap",
                          "tap_running", "reduce_flow")

# Create an empty list to store significant variables
significant_variables <- c()

# Loop over each variable
for (variable in variables_to_analyze) {
  # Create a contingency table
  contingency_table <- table(all[[variable]], all$abnormal_37)
  
  # Perform chi-square test
  chi_sq_result <- chisq.test(contingency_table)
  
  # Print the variable name
  cat("Variable:", variable, "\n")
  
  # Check if p-value is less than 0.05
  if (chi_sq_result$p.value < 0.05) {
    significant_variables <- c(significant_variables, variable)
    cat("Significant\n")
  } else {
    cat("Not Significant\n")
  }
  
  cat("\n")
}
## Variable: filter1 
## Not Significant
## 
## Variable: filter2 
## Significant
## 
## Variable: filter_type 
## Not Significant
## 
## Variable: clean_tap 
## Not Significant
## 
## Variable: tap_running 
## Not Significant
## 
## Variable: reduce_flow 
## Not Significant
# Print significant variables
cat("Significant Variables:", paste(significant_variables, collapse = ", "), "\n")
## Significant Variables: filter2

Given that there were no p-values <0.05, there is not enough sufficient evidence to reject the null hypothesis; none of the variables have a significant association with the OMX_37 samples.

# Fit logistic regression model for abnormal_37 and filter
model <- glm(abnormal_37 ~ filter2, data = all, family = binomial)

summary(model)
## 
## Call:
## glm(formula = abnormal_37 ~ filter2, family = binomial, data = all)
## 
## Coefficients:
##                  Estimate Std. Error z value Pr(>|z|)    
## (Intercept)       -0.9583     0.2223  -4.311 1.63e-05 ***
## filter2No Filter  -0.9084     0.3555  -2.555   0.0106 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 214.28  on 212  degrees of freedom
## Residual deviance: 207.45  on 211  degrees of freedom
##   (2 observations deleted due to missingness)
## AIC: 211.45
## 
## Number of Fisher Scoring iterations: 4

The model suggests that filter does not have a significant effect the odds of the outcome (Abnormal/Normal OMX_37 sample).