##Opening database library(readxl) Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) # Load the necessary packages library(knitr) # For formatted table printing library(epitools) # For odds ratio and confidence interval calculations # Install and load the knitr package if not already installed install.packages("knitr") # Install the 'epitools' package if not already installed install.packages("epitools") ################################################ Univariate analysis ############################################################# ############################################### Comparisons by Gender (Woman vs men) ############################################# --------------------------------------------------------------------------------------------------------------- ##CUSIN1 (I wash my hands before cooking (No= 9.4%)) # Ensure that the dataframe name is consistent df_filtered <- Database_simplified[Database_simplified$CUSIN1 %in% c(0, 1) & Database_simplified$GENRE %in% c(0, 1), ] # Create the contingency table table <- table(df_filtered$CUSIN1, df_filtered$GENRE) # Add descriptive labels to rows and columns rownames(table) <- c("CUSIN1 (Yes)", "CUSIN1 (No)") colnames(table) <- c("Female Gender", "Male Gender") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Gender vs. Hand Washing") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------- ##CUSIN2 (After handling raw food (meat and vegetables), I wash my hands with soap (No= 15.1%) # Ensure that the dataframe name is consistent df_filtered <- Database_simplified[Database_simplified$CUSIN2 %in% c(0, 1) & Database_simplified$GENRE %in% c(0, 1), ] # Create the contingency table table <- table(df_filtered$CUSIN2, df_filtered$GENRE) # Add descriptive labels to rows and columns rownames(table) <- c("CUSIN2 (Yes)", "CUSIN2 (No)") colnames(table) <- c("Female Gender", "Male Gender") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Gender vs. After handling raw food (meat and vegetables), I wash my hands with soap") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------ ##CUSIN3 (I use the same kitchen utensils for handling raw and ready-to-eat foods (Yes=25.8%)) # Ensure that the dataframe name is consistent df_filtered <- Database_simplified[Database_simplified$CUSIN3 %in% c(0, 1) & Database_simplified$GENRE %in% c(0, 1), ] # Create the contingency table table <- table(df_filtered$CUSIN3, df_filtered$GENRE) # Add descriptive labels to rows and columns rownames(table) <- c("CUSIN3 (Yes)", "CUSIN3 (No)") colnames(table) <- c("Female Gender", "Male Gender") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Gender vs. I use the same kitchen utensils for handling raw and ready-to-eat foods") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------- ##CUSIN4 (I wash kitchen utensils that have been used for raw food before using them to prepare other foods (No=16.8%)) # Ensure that the dataframe name is consistent df_filtered <- Database_simplified[Database_simplified$CUSIN4 %in% c(0, 1) & Database_simplified$GENRE %in% c(0, 1), ] # Create the contingency table table <- table(df_filtered$CUSIN4, df_filtered$GENRE) # Add descriptive labels to rows and columns rownames(table) <- c("CUSIN4 (Yes)", "CUSIN4 (No)") colnames(table) <- c("Female Gender", "Male Gender") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Gender vs. I wash kitchen utensils that have been used for raw food before using them to prepare other foods") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------- ##CUSIN5 (I wash fruits and vegetables before eating them (No=20.7%)) # Ensure that the dataframe name is consistent df_filtered <- Database_simplified[Database_simplified$CUSIN5 %in% c(0, 1) & Database_simplified$GENRE %in% c(0, 1), ] # Create the contingency table table <- table(df_filtered$CUSIN5, df_filtered$GENRE) # Add descriptive labels to rows and columns rownames(table) <- c("CUSIN5 (Yes)", "CUSIN5 (No)") colnames(table) <- c("Female Gender", "Male Gender") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Gender vs. I wash fruits and vegetables before eating them") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------- ##CUSIN6 (I wash my hands before eating (No=21.5)) # Ensure that the dataframe name is consistent df_filtered <- Database_simplified[Database_simplified$CUSIN6 %in% c(0, 1) & Database_simplified$GENRE %in% c(0, 1), ] # Create the contingency table table <- table(df_filtered$CUSIN6, df_filtered$GENRE) # Add descriptive labels to rows and columns rownames(table) <- c("CUSIN6 (Yes)", "CUSIN6 (No)") colnames(table) <- c("Female Gender", "Male Gender") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Gender vs. I wash my hands before eating") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) --------------------------------------------------------------------------------------------------------------------- ##PRESCATB1 When you get a prescription for antibiotics, do you follow the recommended ##length of treatment and daily dosage? (No=4.2%) (Sometimes=9.6%) (No+Sometimes=13.8%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) ############### 1st scenario= No # Make sure 'Database_simplified' is the correct name of your dataframe df <- Database_simplified # Filter only 'Yes' and 'No' responses for PRESCATB1 and genders 'Female' and 'Male' df_filtered_prescatb1 <- df[df$PRESCATB1 %in% c(0, 1) & df$GENRE %in% c(0, 1), ] # Create the contingency table table_prescatb1 <- table(df_filtered_prescatb1$PRESCATB1, df_filtered_prescatb1$GENRE) # Add descriptive labels to the rows and columns rownames(table_prescatb1) <- c("Yes", "No") colnames(table_prescatb1) <- c("Female", "Male") # Perform the Chi-Squared test chi_result_prescatb1 <- chisq.test(table_prescatb1) # Calculate the odds ratio and confidence interval odds_ratio_prescatb1 <- oddsratio(table_prescatb1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_prescatb1, caption = "Contingency Table: Gender vs. Following Prescription for Antibiotics")) # Print the results of the Chi-Squared test print(chi_result_prescatb1) # Print the odds ratio and confidence interval print(odds_ratio_prescatb1) ################## 2nd scenario= Sometimes # Filter for 'Yes' and 'Sometimes' responses for PRESCATB1 and genders 'Female' and 'Male' df_filtered_prescatb1_sometimes <- df[df$PRESCATB1 %in% c(0, 3) & df$GENRE %in% c(0, 1), ] # Create the contingency table for 'Yes' vs 'Sometimes' table_prescatb1_sometimes <- table(df_filtered_prescatb1_sometimes$PRESCATB1, df_filtered_prescatb1_sometimes$GENRE) # Adjust the table to have 'Yes' and 'Sometimes' as row names # This step assumes that both 'Yes' and 'Sometimes' responses are present in the filtered data if (all(c(0, 3) %in% df_filtered_prescatb1_sometimes$PRESCATB1)) { rownames(table_prescatb1_sometimes) <- c("Yes", "Sometimes") } else { stop("Not all expected PRESCATB1 responses (Yes and Sometimes) are present in the filtered data.") } # Perform the Chi-Squared test chi_result_prescatb1_sometimes <- chisq.test(table_prescatb1_sometimes) # Calculate the odds ratio and confidence interval odds_ratio_prescatb1_sometimes <- oddsratio(table_prescatb1_sometimes, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_prescatb1_sometimes, caption = "Contingency Table: Gender vs. Following Prescription for Antibiotics Sometimes")) # Print the results of the Chi-Squared test print(chi_result_prescatb1_sometimes) # Print the odds ratio and confidence interval print(odds_ratio_prescatb1_sometimes) ################## 3rd scenario= No+Sometimes # Filter for 'Yes', 'No', and 'Sometimes' responses for PRESCATB1 and genders 'Female' and 'Male' df_filtered_prescatb1_combined <- df[df$PRESCATB1 %in% c(0, 1, 3) & df$GENRE %in% c(0, 1), ] # Create a new variable for the combined 'No' and 'Sometimes' condition df_filtered_prescatb1_combined$No_Sometimes <- df_filtered_prescatb1_combined$PRESCATB1 %in% c(1, 3) # Create the contingency table for 'Yes' vs 'No+Sometimes' table_prescatb1_combined <- table(df_filtered_prescatb1_combined$No_Sometimes, df_filtered_prescatb1_combined$GENRE) # Adjust the table to have 'Yes' and 'No+Sometimes' as row names rownames(table_prescatb1_combined) <- c("Yes", "No_Sometimes") # Perform the Chi-Squared test chi_result_prescatb1_combined <- chisq.test(table_prescatb1_combined) # Calculate the odds ratio and confidence interval odds_ratio_prescatb1_combined <- oddsratio(table_prescatb1_combined, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_prescatb1_combined, caption = "Contingency Table: Gender vs. Following Prescription for Antibiotics (Yes vs. No+Sometimes)")) # Print the results of the Chi-Squared test print(chi_result_prescatb1_combined) # Print the odds ratio and confidence interval print(odds_ratio_prescatb1_combined) --------------------------------------------------------------------------------------------------------------------- ##ARRETATB Do you stop taking antibiotics when symptoms start to disappear? ##(Always=7.3%) (Sometimes=20.4%) (Always+Sometimes=27.7%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) ############### 1st scenario= Always # Filter for 'Always' and 'Never' responses for ARRETATB and genders 'Female' and 'Male' df_filtered_arretatb <- df[df$ARRETATB %in% c(0, 1) & df$GENRE %in% c(0, 1), ] # Create the contingency table for 'Always' vs 'Never' table_arretatb <- table(df_filtered_arretatb$ARRETATB, df_filtered_arretatb$GENRE) # Add descriptive labels to the rows and columns rownames(table_arretatb) <- c("Always", "Never") colnames(table_arretatb) <- c("Female", "Male") # Perform the Chi-Squared test chi_result_arretatb <- chisq.test(table_arretatb) # Calculate the odds ratio and confidence interval odds_ratio_arretatb <- oddsratio(table_arretatb, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_arretatb, caption = "Contingency Table: Gender vs. Stopping Antibiotics Always vs. Never")) # Print the results of the Chi-Squared test print(chi_result_arretatb) # Print the odds ratio and confidence interval print(odds_ratio_arretatb) ################# 2nd Cenario: Sometimes # Filter for 'Sometimes' and 'Never' responses for ARRETATB and genders 'Female' and 'Male' df_filtered_arretatb_sometimes <- df[df$ARRETATB %in% c(1, 2) & df$GENRE %in% c(0, 1), ] # Create the contingency table for 'Sometimes' vs 'Never' table_arretatb_sometimes <- table(df_filtered_arretatb_sometimes$ARRETATB == 2, df_filtered_arretatb_sometimes$GENRE) # Add descriptive labels to the rows and columns rownames(table_arretatb_sometimes) <- c("Never", "Sometimes") colnames(table_arretatb_sometimes) <- c("Female", "Male") # Perform the Chi-Squared test chi_result_arretatb_sometimes <- chisq.test(table_arretatb_sometimes) # Calculate the odds ratio and confidence interval odds_ratio_arretatb_sometimes <- oddsratio(table_arretatb_sometimes, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_arretatb_sometimes, caption = "Contingency Table: Gender vs. Stopping Antibiotics Sometimes vs. Never")) # Print the results of the Chi-Squared test print(chi_result_arretatb_sometimes) # Print the odds ratio and confidence interval print(odds_ratio_arretatb_sometimes) ############### #3rd scenario= Sometimes+Always # Filter for 'Always', 'Never', and 'Sometimes' responses for ARRETATB and genders 'Female' and 'Male' df_filtered_arretatb_combined <- df[df$ARRETATB %in% c(0, 1, 2) & df$GENRE %in% c(0, 1), ] # Create a new variable for the combined 'Sometimes' and 'Always' condition df_filtered_arretatb_combined$Sometimes_Always <- df_filtered_arretatb_combined$ARRETATB %in% c(0, 2) # Create the contingency table for 'Sometimes+Always' vs 'Never' table_arretatb_combined <- table(df_filtered_arretatb_combined$Sometimes_Always, df_filtered_arretatb_combined$GENRE) # Add descriptive labels to the rows and columns rownames(table_arretatb_combined) <- c("Never", "Sometimes_Always") colnames(table_arretatb_combined) <- c("Female", "Male") # Perform the Chi-Squared test chi_result_arretatb_combined <- chisq.test(table_arretatb_combined) # Calculate the odds ratio and confidence interval odds_ratio_arretatb_combined <- oddsratio(table_arretatb_combined, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_arretatb_combined, caption = "Contingency Table: Gender vs. Stopping Antibiotics (Sometimes+Always vs. Never)")) # Print the results of the Chi-Squared test print(chi_result_arretatb_combined) # Print the odds ratio and confidence interval print(odds_ratio_arretatb_combined) --------------------------------------------------------------------------------------------------------------------- ##ATBORAL1 Have you ever taken an oral antibiotic treatment (by mouth) without a medical prescription? (Yes=12.3%) # Make sure 'Database_simplified' is the correct name of your dataframe df <- Database_simplified # Filter for 'Yes' and 'No' responses for ATBORAL and genders 'Female' and 'Male' df_filtered_atboral <- df[df$ATBORAL1 %in% c(0, 1) & df$GENRE %in% c(0, 1), ] # Create the contingency table for 'Yes' vs 'No' table_atboral <- table(df_filtered_atboral$ATBORAL1, df_filtered_atboral$GENRE) # Add descriptive labels to the rows and columns rownames(table_atboral) <- c("Yes", "No") colnames(table_atboral) <- c("Female", "Male") # Perform the Chi-Squared test chi_result_atboral <- chisq.test(table_atboral) # Calculate the odds ratio and confidence interval odds_ratio_atboral <- oddsratio(table_atboral, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atboral, caption = "Contingency Table: Gender vs. Taking Oral Antibiotics Without Prescription (Yes vs. No)")) # Print the results of the Chi-Squared test print(chi_result_atboral) # Print the odds ratio and confidence interval print(odds_ratio_atboral) -------------------------------------------------------------------------------------------------------- ### ATBANI1 I can exchange resistant bacteria with my pet (False=23.2%) # Make sure 'Database_simplified' is the correct name of your dataframe df <- Database_simplified # Filter for 'True' and 'False' responses for ATBANI1 and genders 'Female' and 'Male' df_filtered_atbani1 <- df[df$ATBANI1 %in% c(0, 1) & df$GENRE %in% c(0, 1), ] # Create the contingency table for 'True' vs 'False' table_atbani1 <- table(df_filtered_atbani1$ATBANI1, df_filtered_atbani1$GENRE) # Add descriptive labels to the rows and columns rownames(table_atbani1) <- c("True", "False") colnames(table_atbani1) <- c("Female", "Male") # Perform the Chi-Squared test chi_result_atbani1 <- chisq.test(table_atbani1) # Calculate the odds ratio and confidence interval odds_ratio_atbani1 <- oddsratio(table_atbani1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani1, caption = "Contingency Table: Gender vs. Exchanging Resistant Bacteria with Pets (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani1) # Print the odds ratio and confidence interval print(odds_ratio_atbani1) --------------------------------------------------------------------------------------------------------------------- ### ATBANI2=The use of antibiotics in livestock and crops can increase the #presence of resistant bacteria in the environment (False=14.7%) # Ensure 'Database_simplified' is the correct name of your dataframe df <- Database_simplified # Filter for 'True' and 'False' responses for ATBANI2 and genders 'Female' and 'Male' df_filtered_atbani2 <- df[df$ATBANI2 %in% c(0, 1) & df$GENRE %in% c(0, 1), ] # Create the contingency table for 'True' vs 'False' table_atbani2 <- table(df_filtered_atbani2$ATBANI2, df_filtered_atbani2$GENRE) # Add descriptive labels to the rows and columns rownames(table_atbani2) <- c("True", "False") colnames(table_atbani2) <- c("Female", "Male") # Perform the Chi-Squared test chi_result_atbani2 <- chisq.test(table_atbani2) # Calculate the odds ratio and confidence interval odds_ratio_atbani2 <- oddsratio(table_atbani2, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani2, caption = "Contingency Table: Gender vs. Antibiotics in Livestock and Crops Affecting Environment (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani2) # Print the odds ratio and confidence interval print(odds_ratio_atbani2) -------------------------------------------------------------------------------------------------------------------- ##### ATBANI3 The use of antibiotics in livestock and crops can affect me directly ##(I can get resistant bacteria in my body) (False=26.3%) # Ensure 'Database_simplified' is the correct name of your dataframe df <- Database_simplified # Filter for 'True' and 'False' responses for ATBANI3 and genders 'Female' and 'Male' df_filtered_atbani3 <- df[df$ATBANI3 %in% c(0, 1) & df$GENRE %in% c(0, 1), ] # Create the contingency table for 'True' vs 'False' table_atbani3 <- table(df_filtered_atbani3$ATBANI3, df_filtered_atbani3$GENRE) # Add descriptive labels to the rows and columns rownames(table_atbani3) <- c("True", "False") colnames(table_atbani3) <- c("Female", "Male") # Perform the Chi-Squared test chi_result_atbani3 <- chisq.test(table_atbani3) # Calculate the odds ratio and confidence interval odds_ratio_atbani3 <- oddsratio(table_atbani3, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani3, caption = "Contingency Table: Gender vs. Antibiotics in Livestock and Crops Affecting Humans Directly (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani3) # Print the odds ratio and confidence interval print(odds_ratio_atbani3) ------------------------------------------------------------------------------------------------------------------- ##### ATBANI4 Resistant bacteria are only found in hospitals (True=10.8%) # Ensure 'Database_simplified' is the correct name of your dataframe df <- Database_simplified # Filter for 'True' and 'False' responses for ATBANI4 and genders 'Female' and 'Male' df_filtered_atbani4 <- df[df$ATBANI4 %in% c(0, 1) & df$GENRE %in% c(0, 1), ] # Create the contingency table for 'True' vs 'False' table_atbani4 <- table(df_filtered_atbani4$ATBANI4, df_filtered_atbani4$GENRE) # Add descriptive labels to the rows and columns rownames(table_atbani4) <- c("True", "False") colnames(table_atbani4) <- c("Female", "Male") # Perform the Chi-Squared test chi_result_atbani4 <- chisq.test(table_atbani4) # Calculate the odds ratio and confidence interval odds_ratio_atbani4 <- oddsratio(table_atbani4, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani4, caption = "Contingency Table: Gender vs. Resistant Bacteria Found Only in Hospitals (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani4) # Print the odds ratio and confidence interval print(odds_ratio_atbani4) ---------------------------------------------------------------------------------------------------------------------- #####RESATB1 Antibiotic resistance occurs when your body becomes resistant to antibiotics and they ##no longer work as well (True=58.3%) # Load the database df <- Database_simplified # Filter for 'True' and 'False' responses for RESATB1 and genders 'Female' and 'Male' df_filtered_resatb1 <- df[df$RESATB1 %in% c(0, 1) & df$GENRE %in% c(0, 1), ] # Create the contingency table for 'True' vs 'False' table_resatb1 <- table(df_filtered_resatb1$RESATB1, df_filtered_resatb1$GENRE) # Add descriptive labels to rows and columns rownames(table_resatb1) <- c("True", "False") colnames(table_resatb1) <- c("Female", "Male") # Perform the Chi-Squared test chi_result_resatb1 <- chisq.test(table_resatb1) # Calculate the odds ratio and confidence interval odds_ratio_resatb1 <- oddsratio(table_resatb1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb1, caption = "Contingency Table: Gender vs. Understanding of Antibiotic Resistance (RESATB1: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb1) print(odds_ratio_resatb1) ------------------------------------------------------------------------------------------------------------------- #####RESATB2 Many infections are becoming increasingly resistant to antibiotic treatment (False=12.5%) # Load the database df <- Database_simplified # Filter for 'True' and 'False' responses for RESATB2 and genders 'Female' and 'Male' df_filtered_resatb2 <- df[df$RESATB2 %in% c(0, 1) & df$GENRE %in% c(0, 1), ] # Create the contingency table for 'True' vs 'False' table_resatb2 <- table(df_filtered_resatb2$RESATB2, df_filtered_resatb2$GENRE) # Add descriptive labels to rows and columns rownames(table_resatb2) <- c("True", "False") colnames(table_resatb2) <- c("Female", "Male") # Perform the Chi-Squared test chi_result_resatb2 <- chisq.test(table_resatb2) # Calculate the odds ratio and confidence interval odds_ratio_resatb2 <- oddsratio(table_resatb2, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb2, caption = "Contingency Table: Gender vs. Perception of Increasing Infection Resistance (RESATB2: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb2) print(odds_ratio_resatb2) --------------------------------------------------------------------------------------------------------------------- #####RESATB3 If bacteria are resistant to antibiotics, it can be very difficult or impossible to treat the infections they cause (False=16.7%) # Load the database df <- Database_simplified # Filter for 'True' and 'False' responses for RESATB3 and genders 'Female' and 'Male' df_filtered_resatb3 <- df[df$RESATB3 %in% c(0, 1) & df$GENRE %in% c(0, 1), ] # Create the contingency table for 'True' vs 'False' table_resatb3 <- table(df_filtered_resatb3$RESATB3, df_filtered_resatb3$GENRE) # Add descriptive labels to rows and columns rownames(table_resatb3) <- c("True", "False") colnames(table_resatb3) <- c("Female", "Male") # Perform the Chi-Squared test chi_result_resatb3 <- chisq.test(table_resatb3) # Calculate the odds ratio and confidence interval odds_ratio_resatb3 <- oddsratio(table_resatb3, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb3, caption = "Contingency Table: Gender vs. Perception of Difficulty Treating Infections (RESATB3: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb3) print(odds_ratio_resatb3) ---------------------------------------------------------------------------------------------------------------------- #####RESATB4 Antibiotic resistance is an issue that could affect me or my family (False=11.8%) # Load the database df <- Database_simplified # Filter for 'True' and 'False' responses for RESATB4 and genders 'Female' and 'Male' df_filtered_resatb4 <- df[df$RESATB4 %in% c(0, 1) & df$GENRE %in% c(0, 1), ] # Create the contingency table for 'True' vs 'False' table_resatb4 <- table(df_filtered_resatb4$RESATB4, df_filtered_resatb4$GENRE) # Add descriptive labels to rows and columns rownames(table_resatb4) <- c("True", "False") colnames(table_resatb4) <- c("Female", "Male") # Perform the Chi-Squared test chi_result_resatb4 <- chisq.test(table_resatb4) # Calculate the odds ratio and confidence interval odds_ratio_resatb4 <- oddsratio(table_resatb4, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb4, caption = "Contingency Table: Gender vs. Perception of Antibiotic Resistance Affecting One's Family (RESATB4: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb4) print(odds_ratio_resatb4) --------------------------------------------------------------------------------------------------------------------- #####RESATB5 Antibiotic resistance is an issue in other countries but not here (True=9.9%) # Load the database df <- Database_simplified # Filter for 'True' and 'False' responses for RESATB5 and genders 'Female' and 'Male' df_filtered_resatb5 <- df[df$RESATB5 %in% c(0, 1) & df$GENRE %in% c(0, 1), ] # Create the contingency table for 'True' vs 'False' table_resatb5 <- table(df_filtered_resatb5$RESATB5, df_filtered_resatb5$GENRE) # Add descriptive labels to rows and columns rownames(table_resatb5) <- c("True", "False") colnames(table_resatb5) <- c("Female", "Male") # Perform the Chi-Squared test chi_result_resatb5 <- chisq.test(table_resatb5) # Calculate the odds ratio and confidence interval odds_ratio_resatb5 <- oddsratio(table_resatb5, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb5, caption = "Contingency Table: Gender vs. Perception of Antibiotic Resistance as an Issue Only in Other Countries (RESATB5: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb5) print(odds_ratio_resatb5) --------------------------------------------------------------------------------------------------------------------- #####RESATB6 Antibiotic resistance is only a problem for people who take antibiotics regularly (True=17.5%) # Load the database df <- Database_simplified # Filter for 'True' and 'False' responses for RESATB6 and genders 'Female' and 'Male' df_filtered_resatb6 <- df[df$RESATB6 %in% c(0, 1) & df$GENRE %in% c(0, 1), ] # Create the contingency table for 'True' vs 'False' table_resatb6 <- table(df_filtered_resatb6$RESATB6, df_filtered_resatb6$GENRE) # Add descriptive labels to rows and columns rownames(table_resatb6) <- c("True", "False") colnames(table_resatb6) <- c("Female", "Male") # Perform the Chi-Squared test chi_result_resatb6 <- chisq.test(table_resatb6) # Calculate the odds ratio and confidence interval odds_ratio_resatb6 <- oddsratio(table_resatb6, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb6, caption = "Contingency Table: Gender vs. Perception of Antibiotic Resistance as a Problem Only for Regular Antibiotic Users (RESATB6: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb6) print(odds_ratio_resatb6) --------------------------------------------------------------------------------------------------------------------- #####RESATB7 Bacteria that are resistant to antibiotics can be spread from person to person (False=20.2%) # Load the database df <- Database_simplified # Filter for 'True' and 'False' responses for RESATB7 and genders 'Female' and 'Male' df_filtered_resatb7 <- df[df$RESATB7 %in% c(0, 1) & df$GENRE %in% c(0, 1), ] # Create the contingency table for 'True' vs 'False' table_resatb7 <- table(df_filtered_resatb7$RESATB7, df_filtered_resatb7$GENRE) # Add descriptive labels to rows and columns rownames(table_resatb7) <- c("True", "False") colnames(table_resatb7) <- c("Female", "Male") # Perform the Chi-Squared test chi_result_resatb7 <- chisq.test(table_resatb7) # Calculate the odds ratio and confidence interval odds_ratio_resatb7 <- oddsratio(table_resatb7, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb7, caption = "Contingency Table: Gender vs. Perception of Bacteria Transmission Person to Person (RESATB7: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb7) print(odds_ratio_resatb7) -------------------------------------------------------------------------------------------------------------------- #####RESATB8 Antibiotic-resistant infections could make medical procedures like surgery, organ transplants, ##and cancer treatment much more dangerous (False=12.0%) # Load the database df <- Database_simplified # Filter for 'True' and 'False' responses for RESATB8 and genders 'Female' and 'Male' df_filtered_resatb8 <- df[df$RESATB8 %in% c(0, 1) & df$GENRE %in% c(0, 1), ] # Create the contingency table for 'True' vs 'False' table_resatb8 <- table(df_filtered_resatb8$RESATB8, df_filtered_resatb8$GENRE) # Add descriptive labels to rows and columns rownames(table_resatb8) <- c("True", "False") colnames(table_resatb8) <- c("Female", "Male") # Perform the Chi-Squared test chi_result_resatb8 <- chisq.test(table_resatb8) # Calculate the odds ratio and confidence interval odds_ratio_resatb8 <- oddsratio(table_resatb8, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb8, caption = "Contingency Table: Gender vs. Perception of Antibiotic-Resistant Infections and Medical Procedures (RESATB8: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb8) print(odds_ratio_resatb8) -------------------------------------------------------------------------------------------------------------------- # ATBRGL1 Farmers should give fewer antibiotics to food-producing animals ##################### 1st scenario (Strongly desagree=8.68%) vs. Strongly Agree Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) # Load dataframe df <- Database_simplified # Filter for 'Strongly Agree' (3) and 'Strongly Disagree' (1) responses for ATBRGL1 and genders 'Female' (0) and 'Male' (1) df_filtered_atbrgl1_scenario1 <- df[df$ATBRGL1 %in% c(1, 3) & df$GENRE %in% c(0, 1), ] # Create the contingency table for 'Strongly Agree' vs 'Strongly Disagree' table_atbrgl1_scenario1 <- table(df_filtered_atbrgl1_scenario1$ATBRGL1, df_filtered_atbrgl1_scenario1$GENRE) # Add descriptive labels to rows and columns rownames(table_atbrgl1_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl1_scenario1) <- c("Female", "Male") # Perform the Chi-Squared test chi_result_atbrgl1_scenario1 <- chisq.test(table_atbrgl1_scenario1) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl1_scenario1 <- oddsratio(table_atbrgl1_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl1_scenario1, caption = "Contingency Table: Gender vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Strongly Disagree)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_atbrgl1_scenario1) print(odds_ratio_atbrgl1_scenario1) ############################# 2nd scenario Farmers should give fewer antibiotics to ##food-producing animals (Neither agree nor desagree=22.6%) vs. Strongly Agree # Load dataframe df <- Database_simplified # Filter for 'Strongly Agree' (3) and 'Neither Agree Nor Disagree' (2) responses for ATBRGL1 and genders 'Female' (0) and 'Male' (1) df_filtered_atbrgl1_scenario2 <- df[df$ATBRGL1 %in% c(2, 3) & df$GENRE %in% c(0, 1), ] # Create the contingency table for 'Strongly Agree' vs 'Neither Agree Nor Disagree' table_atbrgl1_scenario2 <- table(df_filtered_atbrgl1_scenario2$ATBRGL1, df_filtered_atbrgl1_scenario2$GENRE) # Add descriptive labels to rows and columns rownames(table_atbrgl1_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl1_scenario2) <- c("Female", "Male") # Perform the Chi-Squared test chi_result_atbrgl1_scenario2 <- chisq.test(table_atbrgl1_scenario2) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl1_scenario2 <- oddsratio(table_atbrgl1_scenario2, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl1_scenario2, caption = "Contingency Table: Gender vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Neither Agree Nor Disagree)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_atbrgl1_scenario2) print(odds_ratio_atbrgl1_scenario2) ############################# 3rd scenario (Strongly desagree + Neither agree nor desagree=31.28%) vs. Strongly Agree # Load dataframe df <- Database_simplified # Filter for 'Strongly Agree' (3), 'Strongly Disagree' (1) and 'Neither Agree Nor Disagree' (2) responses for ATBRGL1 and genders 'Female' (0) and 'Male' (1) df_filtered_atbrgl1_scenario3 <- df[df$ATBRGL1 %in% c(1, 2, 3) & df$GENRE %in% c(0, 1), ] # Create a new variable for the combined 'Strongly Disagree' and 'Neither Agree Nor Disagree' condition df_filtered_atbrgl1_scenario3$Disagree_Neither <- df_filtered_atbrgl1_scenario3$ATBRGL1 %in% c(1, 2) # Create the contingency table for 'Strongly Agree' vs 'Strongly Disagree + Neither Agree Nor Disagree' table_atbrgl1_scenario3 <- table(df_filtered_atbrgl1_scenario3$Disagree_Neither, df_filtered_atbrgl1_scenario3$GENRE) # Add descriptive labels to rows and columns rownames(table_atbrgl1_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl1_scenario3) <- c("Female", "Male") # Perform the Chi-Squared test chi_result_atbrgl1_scenario3 <- chisq.test(table_atbrgl1_scenario3) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl1_scenario3 <- oddsratio(table_atbrgl1_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl1_scenario3, caption = "Contingency Table: Gender vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Strongly Disagree + Neither)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_atbrgl1_scenario3) print(odds_ratio_atbrgl1_scenario3) -------------------------------------------------------------------------------------------------------------------- # ATBRGL2 People should not keep antibiotics and use them later for other illnesses ############################# 1st scenario Strongly desagree vs. Strongly Agree Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) # Load the database df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree # Filter for 'Strongly Agree' (3) and 'Strongly Disagree' (1) responses for ATBRGL2 and genders 'Female' (0) and 'Male' (1) df_filtered_atbrgl2_scenario1 <- df[df$ATBRGL2 %in% c(1, 3) & df$GENRE %in% c(0, 1), ] # Create contingency table for 'Strongly Agree' vs 'Strongly Disagree' table_atbrgl2_scenario1 <- table(df_filtered_atbrgl2_scenario1$ATBRGL2, df_filtered_atbrgl2_scenario1$GENRE) # Add descriptive labels to rows and columns rownames(table_atbrgl2_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl2_scenario1) <- c("Female", "Male") # Perform Chi-Squared test chi_result_atbrgl2_scenario1 <- chisq.test(table_atbrgl2_scenario1) # Calculate odds ratio and confidence interval odds_ratio_atbrgl2_scenario1 <- oddsratio(table_atbrgl2_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl2_scenario1, caption = "Contingency Table: Gender vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl2_scenario1) print(odds_ratio_atbrgl2_scenario1) ############################# 2nd scenario Neither agree nor desagree vs. Strongly Agree # Filter for 'Strongly Agree' (3) and 'Neither Agree Nor Disagree' (2) responses for ATBRGL2 df_filtered_atbrgl2_scenario2 <- df[df$ATBRGL2 %in% c(2, 3) & df$GENRE %in% c(0, 1), ] # Create contingency table for 'Strongly Agree' vs 'Neither Agree Nor Disagree' table_atbrgl2_scenario2 <- table(df_filtered_atbrgl2_scenario2$ATBRGL2, df_filtered_atbrgl2_scenario2$GENRE) # Add descriptive labels rownames(table_atbrgl2_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl2_scenario2) <- c("Female", "Male") # Perform Chi-Squared test chi_result_atbrgl2_scenario2 <- chisq.test(table_atbrgl2_scenario2) # Calculate odds ratio and confidence interval odds_ratio_atbrgl2_scenario2 <- oddsratio(table_atbrgl2_scenario2, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl2_scenario2, caption = "Contingency Table: Gender vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl2_scenario2) print(odds_ratio_atbrgl2_scenario2) ############################# 3rd scenario Neither agree nor desagree + Stringly Disagree vs. Strongly Agree # Filter for 'Strongly Agree' (3), 'Strongly Disagree' (1) and 'Neither Agree Nor Disagree' (2) responses for ATBRGL2 df_filtered_atbrgl2_scenario3 <- df[df$ATBRGL2 %in% c(1, 2, 3) & df$GENRE %in% c(0, 1), ] # Create a new variable for the combined 'Strongly Disagree' and 'Neither Agree Nor Disagree' condition df_filtered_atbrgl2_scenario3$Disagree_Neither <- df_filtered_atbrgl2_scenario3$ATBRGL2 %in% c(1, 2) # Create contingency table for 'Strongly Agree' vs 'Strongly Disagree + Neither Agree Nor Disagree' table_atbrgl2_scenario3 <- table(df_filtered_atbrgl2_scenario3$Disagree_Neither, df_filtered_atbrgl2_scenario3$GENRE) # Add descriptive labels rownames(table_atbrgl2_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl2_scenario3) <- c("Female", "Male") # Perform the Chi-Squared test chi_result_atbrgl2_scenario3 <- chisq.test(table_atbrgl2_scenario3) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl2_scenario3 <- oddsratio(table_atbrgl2_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl2_scenario3, caption = "Contingency Table: Gender vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl2_scenario3) print(odds_ratio_atbrgl2_scenario3) -------------------------------------------------------------------------------------------------------------------- # ATBRGL3 Parents should make sure all of their children’s vaccinations are up-to-date Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) ####1st scenario # Load dataframe df <- Database_simplified # Filter for 'Strongly Agree' (3) and 'Strongly Disagree' (1) responses for ATBRGL3 and genders 'Female' (0) and 'Male' (1) df_filtered_atbrgl3_scenario1 <- df[df$ATBRGL3 %in% c(1, 3) & df$GENRE %in% c(0, 1), ] # Create the contingency table for 'Strongly Agree' vs 'Strongly Disagree' table_atbrgl3_scenario1 <- table(df_filtered_atbrgl3_scenario1$ATBRGL3, df_filtered_atbrgl3_scenario1$GENRE) # Add descriptive labels to rows and columns rownames(table_atbrgl3_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl3_scenario1) <- c("Female", "Male") # Perform Chi-Squared test chi_result_atbrgl3_scenario1 <- chisq.test(table_atbrgl3_scenario1) # Calculate odds ratio and confidence interval odds_ratio_atbrgl3_scenario1 <- oddsratio(table_atbrgl3_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl3_scenario1, caption = "Contingency Table: Gender vs. Opinion on Children's Vaccinations (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl3_scenario1) print(odds_ratio_atbrgl3_scenario1) ### 2nd Scenario # Filter for 'Strongly Agree' (3) and 'Neither Agree Nor Disagree' (2) responses for ATBRGL3 df_filtered_atbrgl3_scenario2 <- df[df$ATBRGL3 %in% c(2, 3) & df$GENRE %in% c(0, 1), ] # Create contingency table for 'Strongly Agree' vs 'Neither Agree Nor Disagree' table_atbrgl3_scenario2 <- table(df_filtered_atbrgl3_scenario2$ATBRGL3, df_filtered_atbrgl3_scenario2$GENRE) # Add descriptive labels rownames(table_atbrgl3_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl3_scenario2) <- c("Female", "Male") # Perform Chi-Squared test chi_result_atbrgl3_scenario2 <- chisq.test(table_atbrgl3_scenario2) # Calculate odds ratio and confidence interval odds_ratio_atbrgl3_scenario2 <- oddsratio(table_atbrgl3_scenario2, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl3_scenario2, caption = "Contingency Table: Gender vs. Opinion on Children's Vaccinations (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl3_scenario2) print(odds_ratio_atbrgl3_scenario2) ## 3rd scenario # Filter for 'Strongly Agree' (3), 'Strongly Disagree' (1) and 'Neither Agree Nor Disagree' (2) responses for ATBRGL3 df_filtered_atbrgl3_scenario3 <- df[df$ATBRGL3 %in% c(1, 2, 3) & df$GENRE %in% c(0, 1), ] # Create a new variable for the combined 'Strongly Disagree' and 'Neither Agree Nor Disagree' condition df_filtered_atbrgl3_scenario3$Disagree_Neither <- df_filtered_atbrgl3_scenario3$ATBRGL3 %in% c(1, 2) # Create contingency table for 'Strongly Agree' vs 'Strongly Disagree + Neither Agree Nor Disagree' table_atbrgl3_scenario3 <- table(df_filtered_atbrgl3_scenario3$Disagree_Neither, df_filtered_atbrgl3_scenario3$GENRE) # Add descriptive labels rownames(table_atbrgl3_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl3_scenario3) <- c("Female", "Male") # Perform the Chi-Squared test chi_result_atbrgl3_scenario3 <- chisq.test(table_atbrgl3_scenario3) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl3_scenario3 <- oddsratio(table_atbrgl3_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl3_scenario3, caption = "Contingency Table: Gender vs. Opinion on Children's Vaccinations (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl3_scenario3) print(odds_ratio_atbrgl3_scenario3) --------------------------------------------------------------------------------------------------------------------- # ATBRGL4 People should wash their hands regularly Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_atbrgl4_scenario1 <- df[df$ATBRGL4 %in% c(1, 3) & df$GENRE %in% c(0, 1), ] table_atbrgl4_scenario1 <- table(df_filtered_atbrgl4_scenario1$ATBRGL4, df_filtered_atbrgl4_scenario1$GENRE) rownames(table_atbrgl4_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl4_scenario1) <- c("Female", "Male") chi_result_atbrgl4_scenario1 <- chisq.test(table_atbrgl4_scenario1) odds_ratio_atbrgl4_scenario1 <- oddsratio(table_atbrgl4_scenario1, conf.level = 0.95)$measure print(kable(table_atbrgl4_scenario1, caption = "Contingency Table: Gender vs. Hand Washing Importance (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl4_scenario1) print(odds_ratio_atbrgl4_scenario1) ## Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl4_scenario2 <- df[df$ATBRGL4 %in% c(2, 3) & df$GENRE %in% c(0, 1), ] table_atbrgl4_scenario2 <- table(df_filtered_atbrgl4_scenario2$ATBRGL4, df_filtered_atbrgl4_scenario2$GENRE) rownames(table_atbrgl4_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl4_scenario2) <- c("Female", "Male") chi_result_atbrgl4_scenario2 <- chisq.test(table_atbrgl4_scenario2) odds_ratio_atbrgl4_scenario2 <- oddsratio(table_atbrgl4_scenario2, conf.level = 0.95)$measure print(kable(table_atbrgl4_scenario2, caption = "Contingency Table: Gender vs. Hand Washing Importance (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl4_scenario2) print(odds_ratio_atbrgl4_scenario2) ## Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl4_scenario3 <- df[df$ATBRGL4 %in% c(1, 2, 3) & df$GENRE %in% c(0, 1), ] df_filtered_atbrgl4_scenario3$Disagree_Neither <- df_filtered_atbrgl4_scenario3$ATBRGL4 %in% c(1, 2) table_atbrgl4_scenario3 <- table(df_filtered_atbrgl4_scenario3$Disagree_Neither, df_filtered_atbrgl4_scenario3$GENRE) rownames(table_atbrgl4_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl4_scenario3) <- c("Female", "Male") chi_result_atbrgl4_scenario3 <- chisq.test(table_atbrgl4_scenario3) odds_ratio_atbrgl4_scenario3 <- oddsratio(table_atbrgl4_scenario3, conf.level = 0.95)$measure print(kable(table_atbrgl4_scenario3, caption = "Contingency Table: Gender vs. Hand Washing Importance (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl4_scenario3) print(odds_ratio_atbrgl4_scenario3) --------------------------------------------------------------------------------------------------------------------- # ATBRGL5 Doctors should only prescribe antibiotics when they are needed Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_atbrgl5_scenario1 <- df[df$ATBRGL5 %in% c(1, 3) & df$GENRE %in% c(0, 1), ] table_atbrgl5_scenario1 <- table(df_filtered_atbrgl5_scenario1$ATBRGL5, df_filtered_atbrgl5_scenario1$GENRE) rownames(table_atbrgl5_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl5_scenario1) <- c("Female", "Male") chi_result_atbrgl5_scenario1 <- chisq.test(table_atbrgl5_scenario1) odds_ratio_atbrgl5_scenario1 <- oddsratio(table_atbrgl5_scenario1, conf.level = 0.95)$measure print(kable(table_atbrgl5_scenario1, caption = "Contingency Table: Gender vs. Antibiotic Prescription Necessity (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl5_scenario1) print(odds_ratio_atbrgl5_scenario1) ## Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl5_scenario2 <- df[df$ATBRGL5 %in% c(2, 3) & df$GENRE %in% c(0, 1), ] table_atbrgl5_scenario2 <- table(df_filtered_atbrgl5_scenario2$ATBRGL5, df_filtered_atbrgl5_scenario2$GENRE) rownames(table_atbrgl5_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl5_scenario2) <- c("Female", "Male") chi_result_atbrgl5_scenario2 <- chisq.test(table_atbrgl5_scenario2) odds_ratio_atbrgl5_scenario2 <- oddsratio(table_atbrgl5_scenario2, conf.level = 0.95)$measure print(kable(table_atbrgl5_scenario2, caption = "Contingency Table: Gender vs. Antibiotic Prescription Necessity (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl5_scenario2) print(odds_ratio_atbrgl5_scenario2) ## Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl5_scenario3 <- df[df$ATBRGL5 %in% c(1, 2, 3) & df$GENRE %in% c(0, 1), ] df_filtered_atbrgl5_scenario3$Disagree_Neither <- df_filtered_atbrgl5_scenario3$ATBRGL5 %in% c(1, 2) table_atbrgl5_scenario3 <- table(df_filtered_atbrgl5_scenario3$Disagree_Neither, df_filtered_atbrgl5_scenario3$GENRE) rownames(table_atbrgl5_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl5_scenario3) <- c("Female", "Male") chi_result_atbrgl5_scenario3 <- chisq.test(table_atbrgl5_scenario3) odds_ratio_atbrgl5_scenario3 <- oddsratio(table_atbrgl5_scenario3, conf.level = 0.95)$measure print(kable(table_atbrgl5_scenario3, caption = "Contingency Table: Gender vs. Antibiotic Prescription Necessity (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl5_scenario3) print(odds_ratio_atbrgl5_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##ATBRGL6= People should only use antibiotics when prescribed by a doctor or nurse Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_atbrgl6_scenario1 <- df[df$ATBRGL6 %in% c(1, 3) & df$GENRE %in% c(0, 1), ] table_atbrgl6_scenario1 <- table(df_filtered_atbrgl6_scenario1$ATBRGL6, df_filtered_atbrgl6_scenario1$GENRE) rownames(table_atbrgl6_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl6_scenario1) <- c("Female", "Male") chi_result_atbrgl6_scenario1 <- chisq.test(table_atbrgl6_scenario1) odds_ratio_atbrgl6_scenario1 <- oddsratio(table_atbrgl6_scenario1, conf.level = 0.95)$measure print(kable(table_atbrgl6_scenario1, caption = "Contingency Table: Gender vs. Antibiotic only when prescribed (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl6_scenario1) print(odds_ratio_atbrgl6_scenario1) ## Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl6_scenario2 <- df[df$ATBRGL6 %in% c(2, 3) & df$GENRE %in% c(0, 1), ] table_atbrgl6_scenario2 <- table(df_filtered_atbrgl6_scenario2$ATBRGL6, df_filtered_atbrgl6_scenario2$GENRE) rownames(table_atbrgl6_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl6_scenario2) <- c("Female", "Male") chi_result_atbrgl6_scenario2 <- chisq.test(table_atbrgl6_scenario2) odds_ratio_atbrgl6_scenario2 <- oddsratio(table_atbrgl6_scenario2, conf.level = 0.95)$measure print(kable(table_atbrgl6_scenario2, caption = "Contingency Table: Gender vs. Antibiotic only when prescribed (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl6_scenario2) print(odds_ratio_atbrgl6_scenario2) ## Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl6_scenario3 <- df[df$ATBRGL6 %in% c(1, 2, 3) & df$GENRE %in% c(0, 1), ] df_filtered_atbrgl6_scenario3$Disagree_Neither <- df_filtered_atbrgl6_scenario3$ATBRGL6 %in% c(1, 2) table_atbrgl6_scenario3 <- table(df_filtered_atbrgl6_scenario3$Disagree_Neither, df_filtered_atbrgl6_scenario3$GENRE) rownames(table_atbrgl6_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl6_scenario3) <- c("Female", "Male") chi_result_atbrgl6_scenario3 <- chisq.test(table_atbrgl6_scenario3) odds_ratio_atbrgl6_scenario3 <- oddsratio(table_atbrgl6_scenario3, conf.level = 0.95)$measure print(kable(table_atbrgl6_scenario3, caption = "Contingency Table: Gender vs. Antibiotic only when prescribed (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl6_scenario3) print(odds_ratio_atbrgl6_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM1= Antibiotic resistance is one of the biggest problems the world faces Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_resdim1_scenario1 <- df[df$RESDIM1 %in% c(1, 3) & df$GENRE %in% c(0, 1), ] table_resdim1_scenario1 <- table(df_filtered_resdim1_scenario1$RESDIM1, df_filtered_resdim1_scenario1$GENRE) rownames(table_resdim1_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_resdim1_scenario1) <- c("Female", "Male") chi_result_resdim1_scenario1 <- chisq.test(table_resdim1_scenario1) odds_ratio_resdim1_scenario1 <- oddsratio(table_resdim1_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim1_scenario1, caption = "Contingency Table: Gender vs. Perception of Antibiotic Resistance as a Global Problem (Strongly Agree vs. Strongly Disagree)")) print(chi_result_resdim1_scenario1) print(odds_ratio_resdim1_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim1_scenario2 <- df[df$RESDIM1 %in% c(2, 3) & df$GENRE %in% c(0, 1), ] table_resdim1_scenario2 <- table(df_filtered_resdim1_scenario2$RESDIM1, df_filtered_resdim1_scenario2$GENRE) rownames(table_resdim1_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_resdim1_scenario2) <- c("Female", "Male") chi_result_resdim1_scenario2 <- chisq.test(table_resdim1_scenario2) odds_ratio_resdim1_scenario2 <- oddsratio(table_resdim1_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim1_scenario2, caption = "Contingency Table: Gender vs. Perception of Antibiotic Resistance as a Global Problem (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim1_scenario2) print(odds_ratio_resdim1_scenario2) # Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim1_scenario3 <- df[df$RESDIM1 %in% c(1, 2, 3) & df$GENRE %in% c(0, 1), ] df_filtered_resdim1_scenario3$Disagree_Neither <- df_filtered_resdim1_scenario3$RESDIM1 %in% c(1, 2) table_resdim1_scenario3 <- table(df_filtered_resdim1_scenario3$Disagree_Neither, df_filtered_resdim1_scenario3$GENRE) rownames(table_resdim1_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_resdim1_scenario3) <- c("Female", "Male") chi_result_resdim1_scenario3 <- chisq.test(table_resdim1_scenario3) odds_ratio_resdim1_scenario3 <- oddsratio(table_resdim1_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim1_scenario3, caption = "Contingency Table: Gender vs. Perception of Antibiotic Resistance as a Global Problem (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_resdim1_scenario3) print(odds_ratio_resdim1_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM2= Medical experts will solve the problem of antibiotic resistance before it becomes too serious Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Load the Database_simplified dataframe df <- read_excel("C:/Database_simplified.xlsx") # Scenario 1: Strongly Agree vs. Strongly Disagree df_filtered_resdim2_scenario1 <- df[df$RESDIM2 %in% c(1, 3) & df$GENRE %in% c(0, 1), ] table_resdim2_scenario1 <- table(df_filtered_resdim2_scenario1$RESDIM2, df_filtered_resdim2_scenario1$GENRE) rownames(table_resdim2_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_resdim2_scenario1) <- c("Female", "Male") chi_result_resdim2_scenario1 <- chisq.test(table_resdim2_scenario1) odds_ratio_resdim2_scenario1 <- oddsratio(table_resdim2_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim2_scenario1, caption = "Contingency Table: Gender vs. Belief in Solving Antibiotic Resistance (Strongly Disagree vs. Strongly Agree)")) print(chi_result_resdim2_scenario1) print(odds_ratio_resdim2_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim2_scenario2 <- df[df$RESDIM2 %in% c(1, 2) & df$GENRE %in% c(0, 1), ] table_resdim2_scenario2 <- table(df_filtered_resdim2_scenario2$RESDIM2, df_filtered_resdim2_scenario2$GENRE) rownames(table_resdim2_scenario2) <- c("Strongly Disagree", "Neither Agree Nor Disagree") colnames(table_resdim2_scenario2) <- c("Female", "Male") chi_result_resdim2_scenario2 <- chisq.test(table_resdim2_scenario2) odds_ratio_resdim2_scenario2 <- oddsratio(table_resdim2_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim2_scenario2, caption = "Contingency Table: Gender vs. Belief in Solving Antibiotic Resistance (Strongly Disagree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim2_scenario2) print(odds_ratio_resdim2_scenario2) # Scenario 3: Strongly Agree + Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim2_scenario3 <- df[df$RESDIM2 %in% c(1, 2, 3) & df$GENRE %in% c(0, 1), ] df_filtered_resdim2_scenario3$Agree_Neither <- df_filtered_resdim2_scenario3$RESDIM2 %in% c(2, 3) table_resdim2_scenario3 <- table(df_filtered_resdim2_scenario3$Agree_Neither, df_filtered_resdim2_scenario3$GENRE) rownames(table_resdim2_scenario3) <- c("Strongly Disagree", "Strongly Agree + Neither") colnames(table_resdim2_scenario3) <- c("Female", "Male") chi_result_resdim2_scenario3 <- chisq.test(table_resdim2_scenario3) odds_ratio_resdim2_scenario3 <- oddsratio(table_resdim2_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim2_scenario3, caption = "Contingency Table: Gender vs. Belief in Solving Antibiotic Resistance (Strongly Disagree vs. Strongly Agree + Neither Agree Nor Disagree)")) print(chi_result_resdim2_scenario3) print(odds_ratio_resdim2_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM3= Everyone needs to use antibiotics responsibly Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_resdim3_scenario1 <- df[df$RESDIM3 %in% c(1, 3) & df$GENRE %in% c(0, 1), ] table_resdim3_scenario1 <- table(df_filtered_resdim3_scenario1$RESDIM3, df_filtered_resdim3_scenario1$GENRE) rownames(table_resdim3_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_resdim3_scenario1) <- c("Female", "Male") chi_result_resdim3_scenario1 <- chisq.test(table_resdim3_scenario1) odds_ratio_resdim3_scenario1 <- oddsratio(table_resdim3_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim3_scenario1, caption = "Contingency Table: Gender vs. Everyone needs to use antibiotics responsibly (Strongly Agree vs. Strongly Disagree)")) print(chi_result_resdim3_scenario1) print(odds_ratio_resdim3_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim3_scenario2 <- df[df$RESDIM3 %in% c(2, 3) & df$GENRE %in% c(0, 1), ] table_resdim3_scenario2 <- table(df_filtered_resdim3_scenario2$RESDIM3, df_filtered_resdim3_scenario2$GENRE) rownames(table_resdim3_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_resdim3_scenario2) <- c("Female", "Male") chi_result_resdim3_scenario2 <- chisq.test(table_resdim3_scenario2) odds_ratio_resdim3_scenario2 <- oddsratio(table_resdim3_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim3_scenario2, caption = "Contingency Table: Gender vs. Everyone needs to use antibiotics responsibly (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim3_scenario2) print(odds_ratio_resdim3_scenario2) # Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim3_scenario3 <- df[df$RESDIM3 %in% c(1, 2, 3) & df$GENRE %in% c(0, 1), ] df_filtered_resdim3_scenario3$Disagree_Neither <- df_filtered_resdim3_scenario3$RESDIM3 %in% c(1, 2) table_resdim3_scenario3 <- table(df_filtered_resdim3_scenario3$Disagree_Neither, df_filtered_resdim3_scenario3$GENRE) rownames(table_resdim3_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_resdim3_scenario3) <- c("Female", "Male") chi_result_resdim3_scenario3 <- chisq.test(table_resdim3_scenario3) odds_ratio_resdim3_scenario3 <- oddsratio(table_resdim3_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim3_scenario3, caption = "Contingency Table: Gender vs. Everyone needs to use antibiotics responsibly (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_resdim3_scenario3) print(odds_ratio_resdim3_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM4= People like me can't do much to stop antibiotic resistance Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Agree vs. Strongly Disagree df_filtered_resdim4_scenario1 <- df[df$RESDIM4 %in% c(1, 3) & df$GENRE %in% c(0, 1), ] table_resdim4_scenario1 <- table(df_filtered_resdim4_scenario1$RESDIM4, df_filtered_resdim4_scenario1$GENRE) rownames(table_resdim4_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_resdim4_scenario1) <- c("Female", "Male") chi_result_resdim4_scenario1 <- chisq.test(table_resdim4_scenario1) odds_ratio_resdim4_scenario1 <- oddsratio(table_resdim4_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim4_scenario1, caption = "Contingency Table: Gender vs. Belief in Individual Impact on Antibiotic Resistance (Strongly Disagree vs. Strongly Agree)")) print(chi_result_resdim4_scenario1) print(odds_ratio_resdim4_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim4_scenario2 <- df[df$RESDIM4 %in% c(1, 2) & df$GENRE %in% c(0, 1), ] table_resdim4_scenario2 <- table(df_filtered_resdim4_scenario2$RESDIM4, df_filtered_resdim4_scenario2$GENRE) rownames(table_resdim4_scenario2) <- c("Strongly Disagree", "Neither Agree Nor Disagree") colnames(table_resdim4_scenario2) <- c("Female", "Male") chi_result_resdim4_scenario2 <- chisq.test(table_resdim4_scenario2) odds_ratio_resdim4_scenario2 <- oddsratio(table_resdim4_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim4_scenario2, caption = "Contingency Table: Gender vs. Belief in Individual Impact on Antibiotic Resistance (Strongly Disagree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim4_scenario2) print(odds_ratio_resdim4_scenario2) # Scenario 3: Strongly Agree + Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim4_scenario3 <- df[df$RESDIM4 %in% c(1, 2, 3) & df$GENRE %in% c(0, 1), ] df_filtered_resdim4_scenario3$Agree_Neither <- df_filtered_resdim4_scenario3$RESDIM4 %in% c(2, 3) table_resdim4_scenario3 <- table(df_filtered_resdim4_scenario3$Agree_Neither, df_filtered_resdim4_scenario3$GENRE) rownames(table_resdim4_scenario3) <- c("Strongly Disagree", "Strongly Agree + Neither") colnames(table_resdim4_scenario3) <- c("Female", "Male") chi_result_resdim4_scenario3 <- chisq.test(table_resdim4_scenario3) odds_ratio_resdim4_scenario3 <- oddsratio(table_resdim4_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim4_scenario3, caption = "Contingency Table: Gender vs. Belief in Individual Impact on Antibiotic Resistance (Strongly Disagree vs. Strongly Agree + Neither Agree Nor Disagree)")) print(chi_result_resdim4_scenario3) print(odds_ratio_resdim4_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM5= I am worried about the impact that antibiotic resistance will have on my health and that of my family Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_resdim5_scenario1 <- df[df$RESDIM5 %in% c(1, 3) & df$GENRE %in% c(0, 1), ] table_resdim5_scenario1 <- table(df_filtered_resdim5_scenario1$RESDIM5, df_filtered_resdim5_scenario1$GENRE) rownames(table_resdim5_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_resdim5_scenario1) <- c("Female", "Male") chi_result_resdim5_scenario1 <- chisq.test(table_resdim5_scenario1) odds_ratio_resdim5_scenario1 <- oddsratio(table_resdim5_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim5_scenario1, caption = "Contingency Table: Gender vs. Impact of AMR on personal health and that of their family (Strongly Agree vs. Strongly Disagree)")) print(chi_result_resdim5_scenario1) print(odds_ratio_resdim5_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim5_scenario2 <- df[df$RESDIM5 %in% c(2, 3) & df$GENRE %in% c(0, 1), ] table_resdim5_scenario2 <- table(df_filtered_resdim5_scenario2$RESDIM5, df_filtered_resdim5_scenario2$GENRE) rownames(table_resdim5_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_resdim5_scenario2) <- c("Female", "Male") chi_result_resdim5_scenario2 <- chisq.test(table_resdim5_scenario2) odds_ratio_resdim5_scenario2 <- oddsratio(table_resdim5_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim5_scenario2, caption = "Contingency Table: Gender vs. Impact of AMR on personal health and that of their family (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim5_scenario2) print(odds_ratio_resdim5_scenario2) # Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim5_scenario3 <- df[df$RESDIM5 %in% c(1, 2, 3) & df$GENRE %in% c(0, 1), ] df_filtered_resdim5_scenario3$Disagree_Neither <- df_filtered_resdim5_scenario3$RESDIM5 %in% c(1, 2) table_resdim5_scenario3 <- table(df_filtered_resdim5_scenario3$Disagree_Neither, df_filtered_resdim5_scenario3$GENRE) rownames(table_resdim5_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_resdim5_scenario3) <- c("Female", "Male") chi_result_resdim5_scenario3 <- chisq.test(table_resdim5_scenario3) odds_ratio_resdim5_scenario3 <- oddsratio(table_resdim5_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim5_scenario3, caption = "Contingency Table: Gender vs. Impact of AMR on personal health and that of their family (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_resdim5_scenario3) print(odds_ratio_resdim5_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM6= I am not at risk of getting an antibiotic-resistant infection, as long as I take my antibiotics correctly Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Agree vs. Strongly Disagree df_filtered_resdim6_scenario1 <- df[df$RESDIM6 %in% c(1, 3) & df$GENRE %in% c(0, 1), ] table_resdim6_scenario1 <- table(df_filtered_resdim6_scenario1$RESDIM6, df_filtered_resdim6_scenario1$GENRE) print(table_resdim6_scenario1) rownames(table_resdim6_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_resdim6_scenario1) <- c("Female", "Male") chi_result_resdim6_scenario1 <- chisq.test(table_resdim6_scenario1) odds_ratio_resdim6_scenario1 <- oddsratio(table_resdim6_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim6_scenario1, caption = "Contingency Table: Gender vs. Perception of Risk of Antibiotic-Resistant Infection (Strongly Disagree vs. Strongly Agree)")) print(chi_result_resdim6_scenario1) print(odds_ratio_resdim6_scenario1) print(table_resdim6_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim6_scenario2 <- df[df$RESDIM6 %in% c(1, 2) & df$GENRE %in% c(0, 1), ] table_resdim6_scenario2 <- table(df_filtered_resdim6_scenario2$RESDIM6, df_filtered_resdim6_scenario2$GENRE) print(table_resdim6_scenario2) rownames(table_resdim6_scenario2) <- c("Strongly Disagree", "Neither Agree Nor Disagree") colnames(table_resdim6_scenario2) <- c("Female", "Male") chi_result_resdim6_scenario2 <- chisq.test(table_resdim6_scenario2) odds_ratio_resdim6_scenario2 <- oddsratio(table_resdim6_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim6_scenario2, caption = "Contingency Table: Gender vs. Perception of Risk of Antibiotic-Resistant Infection (Strongly Disagree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim6_scenario2) print(odds_ratio_resdim6_scenario2) # Scenario 3: Strongly Agree + Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim6_scenario3 <- df[df$RESDIM6 %in% c(1, 2, 3) & df$GENRE %in% c(0, 1), ] df_filtered_resdim6_scenario3$Agree_Neither <- df_filtered_resdim6_scenario3$RESDIM6 %in% c(2, 3) table_resdim6_scenario3 <- table(df_filtered_resdim6_scenario3$Agree_Neither, df_filtered_resdim6_scenario3$GENRE) print(table_resdim6_scenario3) rownames(table_resdim6_scenario3) <- c("Strongly Disagree", "Strongly Agree + Neither") colnames(table_resdim6_scenario3) <- c("Female", "Male") chi_result_resdim6_scenario3 <- chisq.test(table_resdim6_scenario3) odds_ratio_resdim6_scenario3 <- oddsratio(table_resdim6_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim6_scenario3, caption = "Contingency Table: Gender vs. Perception of Risk of Antibiotic-Resistant Infection (Strongly Disagree vs. Strongly Agree + Neither Agree Nor Disagree)")) print(chi_result_resdim6_scenario3) print(odds_ratio_resdim6_scenario3) ############################################### Comparisons by Nationality (Canadian vs Other) ####################################### Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) --------------------------------------------------------------------------------------------------------------- ##CUSIN1 (I wash my hands before cooking (No= 9.4%)) # Ensure that the dataframe name is consistent df_filtered <- Database_simplified[Database_simplified$CUSIN1 %in% c(0, 1) & Database_simplified$CIT1 %in% c(0, 1), ] # Create the contingency table table <- table(df_filtered$CUSIN1, df_filtered$CIT1) # Add descriptive labels to rows and columns rownames(table) <- c("CUSIN1 (Yes)", "CUSIN1 (No)") colnames(table) <- c("Canadian", "Other") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Nationality vs. Hand Washing") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ############ Verification using Fisher's test (in cases which one of the cells has 5 or less) # Fisher's Exact Test for Count Data #fisher_result <- fisher.test(table) # Print the results of the Fisher's Exact Test #print(fisher_result) # Calculating the odds ratio for a 2x2 table # Note: Odds ratios can be calculated from Fisher test objects as well #odds_ratio <- fisher_result$estimate # Calculating the confidence interval from the Fisher's Exact Test #confidence_interval <- fisher_result$conf.int # Printing the odds ratio and confidence interval #print(odds_ratio) #print(confidence_interval) ------------------------------------------------------------------------------------------------------- ##CUSIN2 (After handling raw food (meat and vegetables), I wash my hands with soap (No= 15.1%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") # Ensure that the dataframe name is consistent df_filtered <- Database_simplified[Database_simplified$CUSIN2 %in% c(0, 1) & Database_simplified$CIT1 %in% c(0, 1), ] # Create the contingency table table <- table(df_filtered$CUSIN2, df_filtered$CIT1) # Add descriptive labels to rows and columns rownames(table) <- c("CUSIN2 (Yes)", "CUSIN2 (No)") colnames(table) <- c("Canadian", "Other") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Nationality vs. After handling raw food (meat and vegetables), I wash my hands with soap") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------ ##CUSIN3 (I use the same kitchen utensils for handling raw and ready-to-eat foods (Yes=25.8%)) Database_simplified <- read_excel("C:/Database_simplified.xlsx") # Ensure that the dataframe name is consistent df_filtered <- Database_simplified[Database_simplified$CUSIN3 %in% c(0, 1) & Database_simplified$CIT1 %in% c(0, 1), ] # Create the contingency table table <- table(df_filtered$CUSIN3, df_filtered$CIT1) # Add descriptive labels to rows and columns rownames(table) <- c("CUSIN3 (Yes)", "CUSIN3 (No)") colnames(table) <- c("Canadian", "Other") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Nationality vs. I use the same kitchen utensils for handling raw and ready-to-eat foods") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------- ##CUSIN4 (I wash kitchen utensils that have been used for raw food before using them to prepare other foods (No=16.8%)) Database_simplified <- read_excel("C:/Database_simplified.xlsx") # Ensure that the dataframe name is consistent df_filtered <- Database_simplified[Database_simplified$CUSIN4 %in% c(0, 1) & Database_simplified$CIT1 %in% c(0, 1), ] # Create the contingency table table <- table(df_filtered$CUSIN4, df_filtered$CIT1) # Add descriptive labels to rows and columns rownames(table) <- c("CUSIN4 (Yes)", "CUSIN4 (No)") colnames(table) <- c("Canadian", "Other") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Nationality vs. I wash kitchen utensils that have been used for raw food before using them to prepare other foods") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------- ##CUSIN5 (I wash fruits and vegetables before eating them (No=20.7%)) Database_simplified <- read_excel("C:/Database_simplified.xlsx") # Ensure that the dataframe name is consistent df_filtered <- Database_simplified[Database_simplified$CUSIN5 %in% c(0, 1) & Database_simplified$CIT1 %in% c(0, 1), ] # Create the contingency table table <- table(df_filtered$CUSIN5, df_filtered$CIT1) # Add descriptive labels to rows and columns rownames(table) <- c("CUSIN5 (Yes)", "CUSIN5 (No)") colnames(table) <- c("Canadian", "Other") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Nationality vs. I wash fruits and vegetables before eating them") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------- ##CUSIN6 (I wash my hands before eating (No=21.5)) Database_simplified <- read_excel("C:/Database_simplified.xlsx") # Ensure that the dataframe name is consistent df_filtered <- Database_simplified[Database_simplified$CUSIN6 %in% c(0, 1) & Database_simplified$CIT1 %in% c(0, 1), ] # Create the contingency table table <- table(df_filtered$CUSIN6, df_filtered$CIT1) # Add descriptive labels to rows and columns rownames(table) <- c("CUSIN6 (Yes)", "CUSIN6 (No)") colnames(table) <- c("Canadian", "Other") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Nationality vs. I wash my hands before eating") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ---------------------------------------------------------------------------------------------------- ##PRESCATB1 When you get a prescription for antibiotics, do you follow the recommended ##length of treatment and daily dosage? (No=4.2%) (Sometimes=9.6%) (No+Sometimes=13.8%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) ############### 1st scenario= No # Make sure 'Database_simplified' is the correct name of your dataframe df <- Database_simplified # Filter only 'Yes' and 'No' responses for PRESCATB1 and nationalities 'Canadian' and 'Other' df_filtered_prescatb1 <- df[df$PRESCATB1 %in% c(0, 1) & df$CIT1 %in% c(0, 1), ] # Create the contingency table table_prescatb1 <- table(df_filtered_prescatb1$PRESCATB1, df_filtered_prescatb1$CIT1) # Add descriptive labels to the rows and columns rownames(table_prescatb1) <- c("Yes", "No") colnames(table_prescatb1) <- c("Canadian", "Other") # Perform the Chi-Squared test chi_result_prescatb1 <- chisq.test(table_prescatb1) # Calculate the odds ratio and confidence interval odds_ratio_prescatb1 <- oddsratio(table_prescatb1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_prescatb1, caption = "Contingency Table: Nationality vs. Following Prescription for Antibiotics")) # Print the results of the Chi-Squared test print(chi_result_prescatb1) # Print the odds ratio and confidence interval print(odds_ratio_prescatb1) ############ Verification using Fisher's test (in cases which one of the cells has 5 or less) # Fisher's Exact Test for Count Data fisher_result <- fisher.test(table_prescatb1) # Print the results of the Fisher's Exact Test print(fisher_result) # Calculating the odds ratio for a 2x2 table # Note: Odds ratios can be calculated from Fisher test objects as well odds_ratio <- fisher_result$estimate # Calculating the confidence interval from the Fisher's Exact Test confidence_interval <- fisher_result$conf.int # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ################## 2nd scenario= Sometimes # Filter for 'Yes' and 'Sometimes' responses for PRESCATB1 and nationalities 'Female' and 'Male' df_filtered_prescatb1_sometimes <- df[df$PRESCATB1 %in% c(0, 3) & df$CIT1 %in% c(0, 1), ] # Create the contingency table for 'Yes' vs 'Sometimes' table_prescatb1_sometimes <- table(df_filtered_prescatb1_sometimes$PRESCATB1, df_filtered_prescatb1_sometimes$CIT1) # Adjust the table to have 'Yes' and 'Sometimes' as row names # This step assumes that both 'Yes' and 'Sometimes' responses are present in the filtered data if (all(c(0, 3) %in% df_filtered_prescatb1_sometimes$PRESCATB1)) { rownames(table_prescatb1_sometimes) <- c("Yes", "Sometimes") } else { stop("Not all expected PRESCATB1 responses (Yes and Sometimes) are present in the filtered data.") } # Perform the Chi-Squared test chi_result_prescatb1_sometimes <- chisq.test(table_prescatb1_sometimes) # Calculate the odds ratio and confidence interval odds_ratio_prescatb1_sometimes <- oddsratio(table_prescatb1_sometimes, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_prescatb1_sometimes, caption = "Contingency Table: Nationality vs. Following Prescription for Antibiotics Sometimes")) # Print the results of the Chi-Squared test print(chi_result_prescatb1_sometimes) # Print the odds ratio and confidence interval print(odds_ratio_prescatb1_sometimes) ############ Verification using Fisher's test (in cases which one of the cells has 5 or less) # Fisher's Exact Test for Count Data fisher_result <- fisher.test(table_prescatb1_sometimes) # Print the results of the Fisher's Exact Test print(fisher_result) # Calculating the odds ratio for a 2x2 table # Note: Odds ratios can be calculated from Fisher test objects as well odds_ratio <- fisher_result$estimate # Calculating the confidence interval from the Fisher's Exact Test confidence_interval <- fisher_result$conf.int # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ################## 3rd scenario= No+Sometimes # Filter for 'Yes', 'No', and 'Sometimes' responses for PRESCATB1 and nationality 'Canadian' and 'Other' df_filtered_prescatb1_combined <- df[df$PRESCATB1 %in% c(0, 1, 3) & df$CIT1 %in% c(0, 1), ] # Create a new variable for the combined 'No' and 'Sometimes' condition df_filtered_prescatb1_combined$No_Sometimes <- df_filtered_prescatb1_combined$PRESCATB1 %in% c(1, 3) # Create the contingency table for 'Yes' vs 'No+Sometimes' table_prescatb1_combined <- table(df_filtered_prescatb1_combined$No_Sometimes, df_filtered_prescatb1_combined$CIT1) # Adjust the table to have 'Yes' and 'No+Sometimes' as row names rownames(table_prescatb1_combined) <- c("Yes", "No_Sometimes") # Perform the Chi-Squared test chi_result_prescatb1_combined <- chisq.test(table_prescatb1_combined) # Calculate the odds ratio and confidence interval odds_ratio_prescatb1_combined <- oddsratio(table_prescatb1_combined, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_prescatb1_combined, caption = "Contingency Table: Nationality vs. Following Prescription for Antibiotics (Yes vs. No+Sometimes)")) # Print the results of the Chi-Squared test print(chi_result_prescatb1_combined) # Print the odds ratio and confidence interval print(odds_ratio_prescatb1_combined) --------------------------------------------------------------------------------------------------------------------- ##ARRETATB Do you stop taking antibiotics when symptoms start to disappear? ##(Always=7.3%) (Sometimes=20.4%) (Always+Sometimes=27.7%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) df <- Database_simplified ############### 1st scenario= Always # Filter for 'Always' and 'Never' responses for ARRETATB and nationalities 'Canadian' and 'Other' df_filtered_arretatb <- df[df$ARRETATB %in% c(0, 1) & df$CIT1 %in% c(0, 1), ] # Create the contingency table for 'Always' vs 'Never' table_arretatb <- table(df_filtered_arretatb$ARRETATB, df_filtered_arretatb$CIT1) # Add descriptive labels to the rows and columns rownames(table_arretatb) <- c("Always", "Never") colnames(table_arretatb) <- c("Canadian", "Other") # Perform the Chi-Squared test chi_result_arretatb <- chisq.test(table_arretatb) # Calculate the odds ratio and confidence interval odds_ratio_arretatb <- oddsratio(table_arretatb, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_arretatb, caption = "Contingency Table: Nationality vs. Stopping Antibiotics Always vs. Never")) # Print the results of the Chi-Squared test print(chi_result_arretatb) # Print the odds ratio and confidence interval print(odds_ratio_arretatb) ############ Verification using Fisher's test (in cases which one of the cells has 5 or less) # Fisher's Exact Test for Count Data fisher_result <- fisher.test(table_arretatb) # Print the results of the Fisher's Exact Test print(fisher_result) # Calculating the odds ratio for a 2x2 table # Note: Odds ratios can be calculated from Fisher test objects as well odds_ratio <- fisher_result$estimate # Calculating the confidence interval from the Fisher's Exact Test confidence_interval <- fisher_result$conf.int # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ################# 2nd Cenario: Sometimes # Filter for 'Sometimes' and 'Never' responses for ARRETATB and nationalities 'Canadian' and 'Other' df_filtered_arretatb_sometimes <- df[df$ARRETATB %in% c(1, 2) & df$CIT1 %in% c(0, 1), ] # Create the contingency table for 'Sometimes' vs 'Never' table_arretatb_sometimes <- table(df_filtered_arretatb_sometimes$ARRETATB == 2, df_filtered_arretatb_sometimes$CIT1) # Add descriptive labels to the rows and columns rownames(table_arretatb_sometimes) <- c("Never", "Sometimes") colnames(table_arretatb_sometimes) <- c("Canadian", "Other") # Perform the Chi-Squared test chi_result_arretatb_sometimes <- chisq.test(table_arretatb_sometimes) # Calculate the odds ratio and confidence interval odds_ratio_arretatb_sometimes <- oddsratio(table_arretatb_sometimes, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_arretatb_sometimes, caption = "Contingency Table: Nationality vs. Stopping Antibiotics Sometimes vs. Never")) # Print the results of the Chi-Squared test print(chi_result_arretatb_sometimes) # Print the odds ratio and confidence interval print(odds_ratio_arretatb_sometimes) ############### #3rd scenario= Sometimes+Always # Filter for 'Always', 'Never', and 'Sometimes' responses for ARRETATB and nationalities 'Canadian' and 'Other' df_filtered_arretatb_combined <- df[df$ARRETATB %in% c(0, 1, 2) & df$CIT1 %in% c(0, 1), ] # Create a new variable for the combined 'Sometimes' and 'Always' condition df_filtered_arretatb_combined$Sometimes_Always <- df_filtered_arretatb_combined$ARRETATB %in% c(0, 2) # Create the contingency table for 'Sometimes+Always' vs 'Never' table_arretatb_combined <- table(df_filtered_arretatb_combined$Sometimes_Always, df_filtered_arretatb_combined$CIT1) # Add descriptive labels to the rows and columns rownames(table_arretatb_combined) <- c("Never", "Sometimes_Always") colnames(table_arretatb_combined) <- c("Canadian", "Other") # Perform the Chi-Squared test chi_result_arretatb_combined <- chisq.test(table_arretatb_combined) # Calculate the odds ratio and confidence interval odds_ratio_arretatb_combined <- oddsratio(table_arretatb_combined, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_arretatb_combined, caption = "Contingency Table: Nationality vs. Stopping Antibiotics (Sometimes+Always vs. Never)")) # Print the results of the Chi-Squared test print(chi_result_arretatb_combined) # Print the odds ratio and confidence interval print(odds_ratio_arretatb_combined) --------------------------------------------------------------------------------------------------------------------- ##ATBORAL1 Have you ever taken an oral antibiotic treatment (by mouth) without a medical prescription? (Yes=12.3%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) # Make sure 'Database_simplified' is the correct name of your dataframe df <- Database_simplified # Filter for 'Yes' and 'No' responses for ATBORAL and nationalities 'Canadian' and 'Other' df_filtered_atboral <- df[df$ATBORAL1 %in% c(0, 1) & df$CIT1 %in% c(0, 1), ] # Create the contingency table for 'Yes' vs 'No' table_atboral <- table(df_filtered_atboral$ATBORAL1, df_filtered_atboral$CIT1) # Add descriptive labels to the rows and columns rownames(table_atboral) <- c("Yes", "No") colnames(table_atboral) <- c("Canadian", "Other") # Perform the Chi-Squared test chi_result_atboral <- chisq.test(table_atboral) # Calculate the odds ratio and confidence interval odds_ratio_atboral <- oddsratio(table_atboral, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atboral, caption = "Contingency Table: Nationality vs. Taking Oral Antibiotics Without Prescription (Yes vs. No)")) # Print the results of the Chi-Squared test print(chi_result_atboral) # Print the odds ratio and confidence interval print(odds_ratio_atboral) -------------------------------------------------------------------------------------------------------- ### ATBANI1 I can exchange resistant bacteria with my pet (False=23.2%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") # Make sure 'Database_simplified' is the correct name of your dataframe df <- Database_simplified # Filter for 'True' and 'False' responses for ATBANI1 and nationalities 'Canadian' and 'Other' df_filtered_atbani1 <- df[df$ATBANI1 %in% c(0, 1) & df$CIT1 %in% c(0, 1), ] # Create the contingency table for 'True' vs 'False' table_atbani1 <- table(df_filtered_atbani1$ATBANI1, df_filtered_atbani1$CIT1) # Add descriptive labels to the rows and columns rownames(table_atbani1) <- c("True", "False") colnames(table_atbani1) <- c("Canadian", "Other") # Perform the Chi-Squared test chi_result_atbani1 <- chisq.test(table_atbani1) # Calculate the odds ratio and confidence interval odds_ratio_atbani1 <- oddsratio(table_atbani1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani1, caption = "Contingency Table: Nationality vs. Exchanging Resistant Bacteria with Pets (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani1) # Print the odds ratio and confidence interval print(odds_ratio_atbani1) --------------------------------------------------------------------------------------------------------------------- ### ATBANI2=The use of antibiotics in livestock and crops can increase the #presence of resistant bacteria in the environment (False=14.7%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") # Ensure 'Database_simplified' is the correct name of your dataframe df <- Database_simplified # Filter for 'True' and 'False' responses for ATBANI2 and nationalities 'Canadian' and 'Other' df_filtered_atbani2 <- df[df$ATBANI2 %in% c(0, 1) & df$CIT1 %in% c(0, 1), ] # Create the contingency table for 'True' vs 'False' table_atbani2 <- table(df_filtered_atbani2$ATBANI2, df_filtered_atbani2$CIT1) # Add descriptive labels to the rows and columns rownames(table_atbani2) <- c("True", "False") colnames(table_atbani2) <- c("canadian", "Other") # Perform the Chi-Squared test chi_result_atbani2 <- chisq.test(table_atbani2) # Calculate the odds ratio and confidence interval odds_ratio_atbani2 <- oddsratio(table_atbani2, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani2, caption = "Contingency Table: Nationality vs. Antibiotics in Livestock and Crops Affecting Environment (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani2) # Print the odds ratio and confidence interval print(odds_ratio_atbani2) ############ Verification using Fisher's test (in cases which one of the cells has 5 or less) # Fisher's Exact Test for Count Data fisher_result <- fisher.test(table_atbani2) # Print the results of the Fisher's Exact Test print(fisher_result) # Calculating the odds ratio for a 2x2 table # Note: Odds ratios can be calculated from Fisher test objects as well odds_ratio <- fisher_result$estimate # Calculating the confidence interval from the Fisher's Exact Test confidence_interval <- fisher_result$conf.int # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) -------------------------------------------------------------------------------------------------------------------- ##### ATBANI3 The use of antibiotics in livestock and crops can affect me directly ##(I can get resistant bacteria in my body) (False=26.3%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") # Ensure 'Database_simplified' is the correct name of your dataframe df <- Database_simplified # Filter for 'True' and 'False' responses for ATBANI3 and nationalities 'Canadian' and 'Other' df_filtered_atbani3 <- df[df$ATBANI3 %in% c(0, 1) & df$CIT1 %in% c(0, 1), ] # Create the contingency table for 'True' vs 'False' table_atbani3 <- table(df_filtered_atbani3$ATBANI3, df_filtered_atbani3$CIT1) # Add descriptive labels to the rows and columns rownames(table_atbani3) <- c("True", "False") colnames(table_atbani3) <- c("Canadian", "Other") # Perform the Chi-Squared test chi_result_atbani3 <- chisq.test(table_atbani3) # Calculate the odds ratio and confidence interval odds_ratio_atbani3 <- oddsratio(table_atbani3, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani3, caption = "Contingency Table: Nationality vs. Antibiotics in Livestock and Crops Affecting Humans Directly (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani3) # Print the odds ratio and confidence interval print(odds_ratio_atbani3) ------------------------------------------------------------------------------------------------------------------- ##### ATBANI4 Resistant bacteria are only found in hospitals (True=10.8%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") # Ensure 'Database_simplified' is the correct name of your dataframe df <- Database_simplified # Filter for 'True' and 'False' responses for ATBANI4 and nationalities 'Canadian' and 'Other' df_filtered_atbani4 <- df[df$ATBANI4 %in% c(0, 1) & df$CIT1 %in% c(0, 1), ] # Create the contingency table for 'True' vs 'False' table_atbani4 <- table(df_filtered_atbani4$ATBANI4, df_filtered_atbani4$CIT1) # Add descriptive labels to the rows and columns rownames(table_atbani4) <- c("True", "False") colnames(table_atbani4) <- c("Canadian", "Other") # Perform the Chi-Squared test chi_result_atbani4 <- chisq.test(table_atbani4) # Calculate the odds ratio and confidence interval odds_ratio_atbani4 <- oddsratio(table_atbani4, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani4, caption = "Contingency Table: Nationality vs. Resistant Bacteria Found Only in Hospitals (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani4) # Print the odds ratio and confidence interval print(odds_ratio_atbani4) ---------------------------------------------------------------------------------------------------------------------- #####RESATB1 Antibiotic resistance occurs when your body becomes resistant to antibiotics and they ##no longer work as well (True=58.3%) # Load the database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Filter for 'True' and 'False' responses for RESATB1 and nationalities 'Canadian' and 'Other' df_filtered_resatb1 <- df[df$RESATB1 %in% c(0, 1) & df$CIT1 %in% c(0, 1), ] # Create the contingency table for 'True' vs 'False' table_resatb1 <- table(df_filtered_resatb1$RESATB1, df_filtered_resatb1$CIT1) # Add descriptive labels to rows and columns rownames(table_resatb1) <- c("True", "False") colnames(table_resatb1) <- c("Canadian", "Other") # Perform the Chi-Squared test chi_result_resatb1 <- chisq.test(table_resatb1) # Calculate the odds ratio and confidence interval odds_ratio_resatb1 <- oddsratio(table_resatb1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb1, caption = "Contingency Table: Nationality vs. Understanding of Antibiotic Resistance (RESATB1: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb1) print(odds_ratio_resatb1) ------------------------------------------------------------------------------------------------------------------- #####RESATB2 Many infections are becoming increasingly resistant to antibiotic treatment (False=12.5%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") # Load the database df <- Database_simplified # Filter for 'True' and 'False' responses for RESATB2 and nationalities 'Canadian' and 'Other' df_filtered_resatb2 <- df[df$RESATB2 %in% c(0, 1) & df$CIT1 %in% c(0, 1), ] # Create the contingency table for 'True' vs 'False' table_resatb2 <- table(df_filtered_resatb2$RESATB2, df_filtered_resatb2$CIT1) # Add descriptive labels to rows and columns rownames(table_resatb2) <- c("True", "False") colnames(table_resatb2) <- c("Canadian", "Other") # Perform the Chi-Squared test chi_result_resatb2 <- chisq.test(table_resatb2) # Calculate the odds ratio and confidence interval odds_ratio_resatb2 <- oddsratio(table_resatb2, conf.level = 0.95)$measure # Print the formatted contingency table and test results print(kable(table_resatb2, caption = "Contingency Table: Nationality vs. Perception of Increasing Infection Resistance (RESATB2: True vs. False)")) print(chi_result_resatb2) print(odds_ratio_resatb2) ############ Verification using Fisher's test (in cases which one of the cells has 5 or less) # Fisher's Exact Test for Count Data fisher_result <- fisher.test(table_resatb2) # Print the results of the Fisher's Exact Test print(fisher_result) # Calculating the odds ratio for a 2x2 table # Note: Odds ratios can be calculated from Fisher test objects as well odds_ratio <- fisher_result$estimate # Calculating the confidence interval from the Fisher's Exact Test confidence_interval <- fisher_result$conf.int # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) --------------------------------------------------------------------------------------------------------------------- #####RESATB3 If bacteria are resistant to antibiotics, it can be very difficult or impossible to treat the infections they cause (False=16.7%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") # Load the database df <- Database_simplified # Filter for 'True' and 'False' responses for RESATB3 and nationalities 'Canadian' and 'Other' df_filtered_resatb3 <- df[df$RESATB3 %in% c(0, 1) & df$CIT1 %in% c(0, 1), ] # Create the contingency table for 'True' vs 'False' table_resatb3 <- table(df_filtered_resatb3$RESATB3, df_filtered_resatb3$CIT1) # Add descriptive labels to rows and columns rownames(table_resatb3) <- c("True", "False") colnames(table_resatb3) <- c("Canadian", "Other") # Perform the Chi-Squared test chi_result_resatb3 <- chisq.test(table_resatb3) # Calculate the odds ratio and confidence interval odds_ratio_resatb3 <- oddsratio(table_resatb3, conf.level = 0.95)$measure # Print the formatted contingency table and test results print(kable(table_resatb3, caption = "Contingency Table: Nationality vs. Perception of Difficulty Treating Infections (RESATB3: True vs. False)")) print(chi_result_resatb3) print(odds_ratio_resatb3) ############ Verification using Fisher's test (in cases which one of the cells has 5 or less) # Fisher's Exact Test for Count Data fisher_result <- fisher.test(table_resatb3) # Print the results of the Fisher's Exact Test print(fisher_result) # Calculating the odds ratio for a 2x2 table # Note: Odds ratios can be calculated from Fisher test objects as well odds_ratio <- fisher_result$estimate # Calculating the confidence interval from the Fisher's Exact Test confidence_interval <- fisher_result$conf.int # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ---------------------------------------------------------------------------------------------------------------------- #####RESATB4 Antibiotic resistance is an issue that could affect me or my family (False=11.8%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") # Load the database df <- Database_simplified # Filter for 'True' and 'False' responses for RESATB4 and nationalities 'Canadian' and 'Other' df_filtered_resatb4 <- df[df$RESATB4 %in% c(0, 1) & df$CIT1 %in% c(0, 1), ] # Create the contingency table for 'True' vs 'False' table_resatb4 <- table(df_filtered_resatb4$RESATB4, df_filtered_resatb4$CIT1) # Add descriptive labels to rows and columns rownames(table_resatb4) <- c("True", "False") colnames(table_resatb4) <- c("Canadian", "Other") # Perform the Chi-Squared test chi_result_resatb4 <- chisq.test(table_resatb4) # Calculate the odds ratio and confidence interval odds_ratio_resatb4 <- oddsratio(table_resatb4, conf.level = 0.95)$measure # Print the formatted contingency table and test results print(kable(table_resatb4, caption = "Contingency Table: Nationality vs. Perception of Antibiotic Resistance Affecting One's Family (RESATB4: True vs. False)")) print(chi_result_resatb4) print(odds_ratio_resatb4) ############ Verification using Fisher's test (in cases which one of the cells has 5 or less) # Fisher's Exact Test for Count Data fisher_result <- fisher.test(table_resatb4) # Print the results of the Fisher's Exact Test print(fisher_result) # Calculating the odds ratio for a 2x2 table # Note: Odds ratios can be calculated from Fisher test objects as well odds_ratio <- fisher_result$estimate # Calculating the confidence interval from the Fisher's Exact Test confidence_interval <- fisher_result$conf.int # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) --------------------------------------------------------------------------------------------------------------------- #####RESATB5 Antibiotic resistance is an issue in other countries but not here (True=9.9%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") # Load the database df <- Database_simplified # Filter for 'True' and 'False' responses for RESATB5 and nationalities 'Canadian' and 'Other' df_filtered_resatb5 <- df[df$RESATB5 %in% c(0, 1) & df$CIT1 %in% c(0, 1), ] # Create the contingency table for 'True' vs 'False' table_resatb5 <- table(df_filtered_resatb5$RESATB5, df_filtered_resatb5$CIT1) # Add descriptive labels to rows and columns rownames(table_resatb5) <- c("True", "False") colnames(table_resatb5) <- c("Canadian", "Other") # Perform the Chi-Squared test chi_result_resatb5 <- chisq.test(table_resatb5) # Calculate the odds ratio and confidence interval odds_ratio_resatb5 <- oddsratio(table_resatb5, conf.level = 0.95)$measure # Print the formatted contingency table and test results print(kable(table_resatb5, caption = "Contingency Table: Nationality vs. Perception of Antibiotic Resistance as an Issue Only in Other Countries (RESATB5: True vs. False)")) print(chi_result_resatb5) print(odds_ratio_resatb5) ############ Verification using Fisher's test (in cases which one of the cells has 5 or less) # Fisher's Exact Test for Count Data fisher_result <- fisher.test(table_resatb5) # Print the results of the Fisher's Exact Test print(fisher_result) # Calculating the odds ratio for a 2x2 table # Note: Odds ratios can be calculated from Fisher test objects as well odds_ratio <- fisher_result$estimate # Calculating the confidence interval from the Fisher's Exact Test confidence_interval <- fisher_result$conf.int # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) --------------------------------------------------------------------------------------------------------------------- #####RESATB6 Antibiotic resistance is only a problem for people who take antibiotics regularly (True=17.5%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") # Load the database df <- Database_simplified # Filter for 'True' and 'False' responses for RESATB6 and nationalities 'Canadian' and 'Other' df_filtered_resatb6 <- df[df$RESATB6 %in% c(0, 1) & df$CIT1 %in% c(0, 1), ] # Create the contingency table for 'True' vs 'False' table_resatb6 <- table(df_filtered_resatb6$RESATB6, df_filtered_resatb6$CIT1) # Add descriptive labels to rows and columns rownames(table_resatb6) <- c("True", "False") colnames(table_resatb6) <- c("Canadian", "Other") # Perform the Chi-Squared test chi_result_resatb6 <- chisq.test(table_resatb6) # Calculate the odds ratio and confidence interval odds_ratio_resatb6 <- oddsratio(table_resatb6, conf.level = 0.95)$measure # Print the formatted contingency table and test results print(kable(table_resatb6, caption = "Contingency Table: Nationality vs. Perception of Antibiotic Resistance as a Problem Only for Regular Antibiotic Users (RESATB6: True vs. False)")) print(chi_result_resatb6) print(odds_ratio_resatb6) ############ Verification using Fisher's test (in cases which one of the cells has 5 or less) # Fisher's Exact Test for Count Data fisher_result <- fisher.test(table_resatb6) # Print the results of the Fisher's Exact Test print(fisher_result) # Calculating the odds ratio for a 2x2 table # Note: Odds ratios can be calculated from Fisher test objects as well odds_ratio <- fisher_result$estimate # Calculating the confidence interval from the Fisher's Exact Test confidence_interval <- fisher_result$conf.int # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) --------------------------------------------------------------------------------------------------------------------- #####RESATB7 Bacteria that are resistant to antibiotics can be spread from person to person (False=20.2%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") # Load the database df <- Database_simplified # Filter for 'True' and 'False' responses for RESATB7 and nationalities 'Canadian' and 'Other' df_filtered_resatb7 <- df[df$RESATB7 %in% c(0, 1) & df$CIT1 %in% c(0, 1), ] # Create the contingency table for 'True' vs 'False' table_resatb7 <- table(df_filtered_resatb7$RESATB7, df_filtered_resatb7$CIT1) # Add descriptive labels to rows and columns rownames(table_resatb7) <- c("True", "False") colnames(table_resatb7) <- c("Canadian", "Other") # Perform the Chi-Squared test chi_result_resatb7 <- chisq.test(table_resatb7) # Calculate the odds ratio and confidence interval odds_ratio_resatb7 <- oddsratio(table_resatb7, conf.level = 0.95)$measure # Print the formatted contingency table and test results print(kable(table_resatb7, caption = "Contingency Table: Nationality vs. Perception of Bacteria Transmission Person to Person (RESATB7: True vs. False)")) print(chi_result_resatb7) print(odds_ratio_resatb7) ############ Verification using Fisher's test (in cases which one of the cells has 5 or less) # Fisher's Exact Test for Count Data fisher_result <- fisher.test(table_resatb7) # Print the results of the Fisher's Exact Test print(fisher_result) # Calculating the odds ratio for a 2x2 table # Note: Odds ratios can be calculated from Fisher test objects as well odds_ratio <- fisher_result$estimate # Calculating the confidence interval from the Fisher's Exact Test confidence_interval <- fisher_result$conf.int # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) -------------------------------------------------------------------------------------------------------------------- #####RESATB8 Antibiotic-resistant infections could make medical procedures like surgery, organ transplants, ##and cancer treatment much more dangerous (False=12.0%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") # Load the database df <- Database_simplified # Filter for 'True' and 'False' responses for RESATB8 and nationalities 'Canadian' and 'Other' df_filtered_resatb8 <- df[df$RESATB8 %in% c(0, 1) & df$CIT1 %in% c(0, 1), ] # Create the contingency table for 'True' vs 'False' table_resatb8 <- table(df_filtered_resatb8$RESATB8, df_filtered_resatb8$CIT1) # Add descriptive labels to rows and columns rownames(table_resatb8) <- c("True", "False") colnames(table_resatb8) <- c("Canadian", "Other") # Perform the Chi-Squared test chi_result_resatb8 <- chisq.test(table_resatb8) # Calculate the odds ratio and confidence interval odds_ratio_resatb8 <- oddsratio(table_resatb8, conf.level = 0.95)$measure # Print the formatted contingency table and test results print(kable(table_resatb8, caption = "Contingency Table: Nationality vs. Perception of Antibiotic-Resistant Infections and Medical Procedures (RESATB8: True vs. False)")) print(chi_result_resatb8) print(odds_ratio_resatb8) ############ Verification using Fisher's test (in cases which one of the cells has 5 or less) # Fisher's Exact Test for Count Data fisher_result <- fisher.test(table_resatb8) # Print the results of the Fisher's Exact Test print(fisher_result) # Calculating the odds ratio for a 2x2 table # Note: Odds ratios can be calculated from Fisher test objects as well odds_ratio <- fisher_result$estimate # Calculating the confidence interval from the Fisher's Exact Test confidence_interval <- fisher_result$conf.int # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ---------------------------------------------------------------------------------------------------- # ATBRGL1 Farmers should give fewer antibiotics to food-producing animals Database_simplified <- read_excel("C:/Database_simplified.xlsx") # Load the database df <- Database_simplified # Scenario 1: Strongly Disagree vs. Strongly Agree for ATBRGL1 df_filtered_atbrgl1_scenario1 <- df[df$ATBRGL1 %in% c(1, 3) & df$CIT1 %in% c(0, 1), ] table_atbrgl1_scenario1 <- table(df_filtered_atbrgl1_scenario1$ATBRGL1, df_filtered_atbrgl1_scenario1$CIT1) rownames(table_atbrgl1_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl1_scenario1) <- c("Canadian", "Other") chi_result_atbrgl1_scenario1 <- chisq.test(table_atbrgl1_scenario1) odds_ratio_atbrgl1_scenario1 <- oddsratio(table_atbrgl1_scenario1, conf.level = 0.95)$measure print(kable(table_atbrgl1_scenario1, caption = "Contingency Table: Nationality vs. ATBRGL1 (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl1_scenario1) print(odds_ratio_atbrgl1_scenario1) ############ Verification using Fisher's test (in cases which one of the cells has 5 or less) # Fisher's Exact Test for Count Data fisher_result <- fisher.test(table_atbrgl1_scenario1) # Print the results of the Fisher's Exact Test print(fisher_result) # Calculating the odds ratio for a 2x2 table # Note: Odds ratios can be calculated from Fisher test objects as well odds_ratio <- fisher_result$estimate # Calculating the confidence interval from the Fisher's Exact Test confidence_interval <- fisher_result$conf.int # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree for ATBRGL1 df_filtered_atbrgl1_scenario2 <- df[df$ATBRGL1 %in% c(2, 3) & df$CIT1 %in% c(0, 1), ] table_atbrgl1_scenario2 <- table(df_filtered_atbrgl1_scenario2$ATBRGL1, df_filtered_atbrgl1_scenario2$CIT1) rownames(table_atbrgl1_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl1_scenario2) <- c("Canadian", "Other") chi_result_atbrgl1_scenario2 <- chisq.test(table_atbrgl1_scenario2) odds_ratio_atbrgl1_scenario2 <- oddsratio(table_atbrgl1_scenario2, conf.level = 0.95)$measure print(kable(table_atbrgl1_scenario2, caption = "Contingency Table: Nationality vs. ATBRGL1 (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl1_scenario2) print(odds_ratio_atbrgl1_scenario2) ############################# 3rd scenario (Strongly desagree + Neither agree nor desagree=31.28%) vs. Strongly Agree # Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree for ATBRGL1 df_filtered_atbrgl1_scenario3 <- df[df$ATBRGL1 %in% c(1, 2, 3) & df$CIT1 %in% c(0, 1), ] df_filtered_atbrgl1_scenario3$Disagree_Neither <- df_filtered_atbrgl1_scenario3$ATBRGL1 %in% c(1, 2) table_atbrgl1_scenario3 <- table(df_filtered_atbrgl1_scenario3$Disagree_Neither, df_filtered_atbrgl1_scenario3$CIT1) rownames(table_atbrgl1_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl1_scenario3) <- c("Canadian", "Other") chi_result_atbrgl1_scenario3 <- chisq.test(table_atbrgl1_scenario3) odds_ratio_atbrgl1_scenario3 <- oddsratio(table_atbrgl1_scenario3, conf.level = 0.95)$measure print(kable(table_atbrgl1_scenario3, caption = "Contingency Table: Nationality vs. ATBRGL1 (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl1_scenario3) print(odds_ratio_atbrgl1_scenario3) -------------------------------------------------------------------------------------------------------------------- # ATBRGL2 People should not keep antibiotics and use them later for other illnesses Database_simplified <- read_excel("C:/Database_simplified.xlsx") # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Disagree vs. Strongly Agree for ATBRGL2 df_filtered_atbrgl2_scenario1 <- df[df$ATBRGL2 %in% c(1, 3) & df$CIT1 %in% c(0, 1), ] table_atbrgl2_scenario1 <- table(df_filtered_atbrgl2_scenario1$ATBRGL2, df_filtered_atbrgl2_scenario1$CIT1) rownames(table_atbrgl2_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl2_scenario1) <- c("Canadian", "Other") chi_result_atbrgl2_scenario1 <- chisq.test(table_atbrgl2_scenario1) odds_ratio_atbrgl2_scenario1 <- oddsratio(table_atbrgl2_scenario1, conf.level = 0.95)$measure print(kable(table_atbrgl2_scenario1, caption = "Contingency Table: Nationality vs. ATBRGL2 (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl2_scenario1) print(odds_ratio_atbrgl2_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree for ATBRGL2 df_filtered_atbrgl2_scenario2 <- df[df$ATBRGL2 %in% c(2, 3) & df$CIT1 %in% c(0, 1), ] table_atbrgl2_scenario2 <- table(df_filtered_atbrgl2_scenario2$ATBRGL2, df_filtered_atbrgl2_scenario2$CIT1) rownames(table_atbrgl2_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl2_scenario2) <- c("Canadian", "Other") chi_result_atbrgl2_scenario2 <- chisq.test(table_atbrgl2_scenario2) odds_ratio_atbrgl2_scenario2 <- oddsratio(table_atbrgl2_scenario2, conf.level = 0.95)$measure print(kable(table_atbrgl2_scenario2, caption = "Contingency Table: Nationality vs. ATBRGL2 (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl2_scenario2) print(odds_ratio_atbrgl2_scenario2) # Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree for ATBRGL2 df_filtered_atbrgl2_scenario3 <- df[df$ATBRGL2 %in% c(1, 2, 3) & df$CIT1 %in% c(0, 1), ] df_filtered_atbrgl2_scenario3$Disagree_Neither <- df_filtered_atbrgl2_scenario3$ATBRGL2 %in% c(1, 2) table_atbrgl2_scenario3 <- table(df_filtered_atbrgl2_scenario3$Disagree_Neither, df_filtered_atbrgl2_scenario3$CIT1) rownames(table_atbrgl2_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl2_scenario3) <- c("Canadian", "Other") chi_result_atbrgl2_scenario3 <- chisq.test(table_atbrgl2_scenario3) odds_ratio_atbrgl2_scenario3 <- oddsratio(table_atbrgl2_scenario3, conf.level = 0.95)$measure print(kable(table_atbrgl2_scenario3, caption = "Contingency Table: Nationality vs. ATBRGL2 (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl2_scenario3) print(odds_ratio_atbrgl2_scenario3) -------------------------------------------------------------------------------------------------------------------- # ATBRGL3 Parents should make sure all of their children’s vaccinations are up-to-date Database_simplified <- read_excel("C:/Database_simplified.xlsx") # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Disagree vs. Strongly Agree for ATBRGL3 df_filtered_atbrgl3_scenario1 <- df[df$ATBRGL3 %in% c(1, 3) & df$CIT1 %in% c(0, 1), ] table_atbrgl3_scenario1 <- table(df_filtered_atbrgl3_scenario1$ATBRGL3, df_filtered_atbrgl3_scenario1$CIT1) rownames(table_atbrgl3_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl3_scenario1) <- c("Canadian", "Other") chi_result_atbrgl3_scenario1 <- chisq.test(table_atbrgl3_scenario1) odds_ratio_atbrgl3_scenario1 <- oddsratio(table_atbrgl3_scenario1, conf.level = 0.95)$measure print(kable(table_atbrgl3_scenario1, caption = "Contingency Table: Nationality vs. ATBRGL3 (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl3_scenario1) print(odds_ratio_atbrgl3_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree for ATBRGL3 df_filtered_atbrgl3_scenario2 <- df[df$ATBRGL3 %in% c(2, 3) & df$CIT1 %in% c(0, 1), ] table_atbrgl3_scenario2 <- table(df_filtered_atbrgl3_scenario2$ATBRGL3, df_filtered_atbrgl3_scenario2$CIT1) rownames(table_atbrgl3_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl3_scenario2) <- c("Canadian", "Other") chi_result_atbrgl3_scenario2 <- chisq.test(table_atbrgl3_scenario2) odds_ratio_atbrgl3_scenario2 <- oddsratio(table_atbrgl3_scenario2, conf.level = 0.95)$measure print(kable(table_atbrgl3_scenario2, caption = "Contingency Table: Nationality vs. ATBRGL3 (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl3_scenario2) print(odds_ratio_atbrgl3_scenario2) # Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree for ATBRGL3 df_filtered_atbrgl3_scenario3 <- df[df$ATBRGL3 %in% c(1, 2, 3) & df$CIT1 %in% c(0, 1), ] df_filtered_atbrgl3_scenario3$Disagree_Neither <- df_filtered_atbrgl3_scenario3$ATBRGL3 %in% c(1, 2) table_atbrgl3_scenario3 <- table(df_filtered_atbrgl3_scenario3$Disagree_Neither, df_filtered_atbrgl3_scenario3$CIT1) rownames(table_atbrgl3_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl3_scenario3) <- c("Canadian", "Other") chi_result_atbrgl3_scenario3 <- chisq.test(table_atbrgl3_scenario3) odds_ratio_atbrgl3_scenario3 <- oddsratio(table_atbrgl3_scenario3, conf.level = 0.95)$measure print(kable(table_atbrgl3_scenario3, caption = "Contingency Table: Nationality vs. ATBRGL3 (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl3_scenario3) print(odds_ratio_atbrgl3_scenario3) --------------------------------------------------------------------------------------------------------------------- # ATBRGL4 People should wash their hands regularly Database_simplified <- read_excel("C:/Database_simplified.xlsx") # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Disagree vs. Strongly Agree for ATBRGL4 df_filtered_atbrgl4_scenario1 <- df[df$ATBRGL4 %in% c(1, 3) & df$CIT1 %in% c(0, 1), ] table_atbrgl4_scenario1 <- table(df_filtered_atbrgl4_scenario1$ATBRGL4, df_filtered_atbrgl4_scenario1$CIT1) rownames(table_atbrgl4_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl4_scenario1) <- c("Canadian", "Other") chi_result_atbrgl4_scenario1 <- chisq.test(table_atbrgl4_scenario1) odds_ratio_atbrgl4_scenario1 <- oddsratio(table_atbrgl4_scenario1, conf.level = 0.95)$measure print(kable(table_atbrgl4_scenario1, caption = "Contingency Table: Nationality vs. ATBRGL4 (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl4_scenario1) print(odds_ratio_atbrgl4_scenario1) ############ Verification using Fisher's test (in cases which one of the cells has 5 or less) # Fisher's Exact Test for Count Data fisher_result <- fisher.test(table_atbrgl4_scenario1) # Print the results of the Fisher's Exact Test print(fisher_result) # Calculating the odds ratio for a 2x2 table # Note: Odds ratios can be calculated from Fisher test objects as well odds_ratio <- fisher_result$estimate # Calculating the confidence interval from the Fisher's Exact Test confidence_interval <- fisher_result$conf.int # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree para ATBRGL4 df_filtered_atbrgl4_scenario2 <- df[df$ATBRGL4 %in% c(2, 3) & df$CIT1 %in% c(0, 1), ] table_atbrgl4_scenario2 <- table(df_filtered_atbrgl4_scenario2$ATBRGL4, df_filtered_atbrgl4_scenario2$CIT1) rownames(table_atbrgl4_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl4_scenario2) <- c("Canadian", "Other") chi_result_atbrgl4_scenario2 <- chisq.test(table_atbrgl4_scenario2) odds_ratio_atbrgl4_scenario2 <- oddsratio(table_atbrgl4_scenario2, conf.level = 0.95)$measure print(kable(table_atbrgl4_scenario2, caption = "Contingency Table: Nationality vs. ATBRGL4 (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl4_scenario2) print(odds_ratio_atbrgl4_scenario2) # Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree for ATBRGL4 df_filtered_atbrgl4_scenario3 <- df[df$ATBRGL4 %in% c(1, 2, 3) & df$CIT1 %in% c(0, 1), ] df_filtered_atbrgl4_scenario3$Disagree_Neither <- df_filtered_atbrgl4_scenario3$ATBRGL4 %in% c(1, 2) table_atbrgl4_scenario3 <- table(df_filtered_atbrgl4_scenario3$Disagree_Neither, df_filtered_atbrgl4_scenario3$CIT1) rownames(table_atbrgl4_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl4_scenario3) <- c("Canadian", "Other") chi_result_atbrgl4_scenario3 <- chisq.test(table_atbrgl4_scenario3) odds_ratio_atbrgl4_scenario3 <- oddsratio(table_atbrgl4_scenario3, conf.level = 0.95)$measure print(kable(table_atbrgl4_scenario3, caption = "Contingency Table: Nationality vs. ATBRGL4 (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl4_scenario3) print(odds_ratio_atbrgl4_scenario3) --------------------------------------------------------------------------------------------------------------------- # ATBRGL5 Doctors should only prescribe antibiotics when they are needed Database_simplified <- read_excel("C:/Database_simplified.xlsx") # Load the Database_simplified dataframe df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_atbrgl5_scenario1 <- df[df$ATBRGL5 %in% c(1, 3) & df$CIT1 %in% c(0, 1), ] table_atbrgl5_scenario1 <- table(df_filtered_atbrgl5_scenario1$ATBRGL5, df_filtered_atbrgl5_scenario1$CIT1) rownames(table_atbrgl5_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl5_scenario1) <- c("Canadian", "Other") chi_result_atbrgl5_scenario1 <- chisq.test(table_atbrgl5_scenario1) odds_ratio_atbrgl5_scenario1 <- oddsratio(table_atbrgl5_scenario1, conf.level = 0.95)$measure print(kable(table_atbrgl5_scenario1, caption = "Contingency Table: Nationality vs. ATBRGL5 (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl5_scenario1) print(odds_ratio_atbrgl5_scenario1) ############ Verification using Fisher's test (in cases which one of the cells has 5 or less) # Fisher's Exact Test for Count Data fisher_result <- fisher.test(table_atbrgl5_scenario1) # Print the results of the Fisher's Exact Test print(fisher_result) # Calculating the odds ratio for a 2x2 table # Note: Odds ratios can be calculated from Fisher test objects as well odds_ratio <- fisher_result$estimate # Calculating the confidence interval from the Fisher's Exact Test confidence_interval <- fisher_result$conf.int # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ## Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl5_scenario2 <- df[df$ATBRGL5 %in% c(2, 3) & df$CIT1 %in% c(0, 1), ] table_atbrgl5_scenario2 <- table(df_filtered_atbrgl5_scenario2$ATBRGL5, df_filtered_atbrgl5_scenario2$CIT1) rownames(table_atbrgl5_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl5_scenario2) <- c("Canadian", "Other") chi_result_atbrgl5_scenario2 <- chisq.test(table_atbrgl5_scenario2) odds_ratio_atbrgl5_scenario2 <- oddsratio(table_atbrgl5_scenario2, conf.level = 0.95)$measure print(kable(table_atbrgl5_scenario2, caption = "Contingency Table: Nationality vs. ATBRGL5 (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl5_scenario2) print(odds_ratio_atbrgl5_scenario2) ############ Verification using Fisher's test (in cases which one of the cells has 5 or less) # Fisher's Exact Test for Count Data fisher_result <- fisher.test(table_atbrgl5_scenario2) # Print the results of the Fisher's Exact Test print(fisher_result) # Calculating the odds ratio for a 2x2 table # Note: Odds ratios can be calculated from Fisher test objects as well odds_ratio <- fisher_result$estimate # Calculating the confidence interval from the Fisher's Exact Test confidence_interval <- fisher_result$conf.int # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ## Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl5_scenario3 <- df[df$ATBRGL5 %in% c(1, 2, 3) & df$CIT1 %in% c(0, 1), ] df_filtered_atbrgl5_scenario3$Disagree_Neither <- df_filtered_atbrgl5_scenario3$ATBRGL5 %in% c(1, 2) table_atbrgl5_scenario3 <- table(df_filtered_atbrgl5_scenario3$Disagree_Neither, df_filtered_atbrgl5_scenario3$CIT1) rownames(table_atbrgl5_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl5_scenario3) <- c("Canadian", "Other") chi_result_atbrgl5_scenario3 <- chisq.test(table_atbrgl5_scenario3) odds_ratio_atbrgl5_scenario3 <- oddsratio(table_atbrgl5_scenario3, conf.level = 0.95)$measure print(kable(table_atbrgl5_scenario3, caption = "Contingency Table: Nationality vs. ATBRGL5 (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl5_scenario3) print(odds_ratio_atbrgl5_scenario3) ############ Verification using Fisher's test (in cases which one of the cells has 5 or less) # Fisher's Exact Test for Count Data fisher_result <- fisher.test(table_atbrgl5_scenario3) # Print the results of the Fisher's Exact Test print(fisher_result) # Calculating the odds ratio for a 2x2 table # Note: Odds ratios can be calculated from Fisher test objects as well odds_ratio <- fisher_result$estimate # Calculating the confidence interval from the Fisher's Exact Test confidence_interval <- fisher_result$conf.int # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ---------------------------------------------------------------------------------------------------------------------- ##ATBRGL6= People should only use antibiotics when prescribed by a doctor or nurse Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_atbrgl6_scenario1 <- df[df$ATBRGL6 %in% c(1, 3) & df$CIT1 %in% c(0, 1), ] table_atbrgl6_scenario1 <- table(df_filtered_atbrgl6_scenario1$ATBRGL6, df_filtered_atbrgl6_scenario1$CIT1) rownames(table_atbrgl6_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl6_scenario1) <- c("Canadian", "Other") chi_result_atbrgl6_scenario1 <- chisq.test(table_atbrgl6_scenario1) odds_ratio_atbrgl6_scenario1 <- oddsratio(table_atbrgl6_scenario1, conf.level = 0.95)$measure print(kable(table_atbrgl6_scenario1, caption = "Contingency Table: Nationality vs. ATBRGL6 (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl6_scenario1) print(odds_ratio_atbrgl6_scenario1) ############ Verification using Fisher's test (in cases which one of the cells has 5 or less) # Fisher's Exact Test for Count Data fisher_result <- fisher.test(table_atbrgl6_scenario1) # Print the results of the Fisher's Exact Test print(fisher_result) # Calculating the odds ratio for a 2x2 table # Note: Odds ratios can be calculated from Fisher test objects as well odds_ratio <- fisher_result$estimate # Calculating the confidence interval from the Fisher's Exact Test confidence_interval <- fisher_result$conf.int # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ## Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl6_scenario2 <- df[df$ATBRGL6 %in% c(2, 3) & df$CIT1 %in% c(0, 1), ] table_atbrgl6_scenario2 <- table(df_filtered_atbrgl6_scenario2$ATBRGL6, df_filtered_atbrgl6_scenario2$CIT1) rownames(table_atbrgl6_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl6_scenario2) <- c("Canadian", "Other") chi_result_atbrgl6_scenario2 <- chisq.test(table_atbrgl6_scenario2) odds_ratio_atbrgl6_scenario2 <- oddsratio(table_atbrgl6_scenario2, conf.level = 0.95)$measure print(kable(table_atbrgl6_scenario2, caption = "Contingency Table: Nationality vs. ATBRGL6 (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl6_scenario2) print(odds_ratio_atbrgl6_scenario2) ############ Verification using Fisher's test (in cases which one of the cells has 5 or less) # Fisher's Exact Test for Count Data fisher_result <- fisher.test(table_atbrgl6_scenario2) # Print the results of the Fisher's Exact Test print(fisher_result) # Calculating the odds ratio for a 2x2 table # Note: Odds ratios can be calculated from Fisher test objects as well odds_ratio <- fisher_result$estimate # Calculating the confidence interval from the Fisher's Exact Test confidence_interval <- fisher_result$conf.int # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ## Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl6_scenario3 <- df[df$ATBRGL6 %in% c(1, 2, 3) & df$CIT1 %in% c(0, 1), ] df_filtered_atbrgl6_scenario3$Disagree_Neither <- df_filtered_atbrgl6_scenario3$ATBRGL6 %in% c(1, 2) table_atbrgl6_scenario3 <- table(df_filtered_atbrgl6_scenario3$Disagree_Neither, df_filtered_atbrgl6_scenario3$CIT1) rownames(table_atbrgl6_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl6_scenario3) <- c("Canadian", "Other") chi_result_atbrgl6_scenario3 <- chisq.test(table_atbrgl6_scenario3) odds_ratio_atbrgl6_scenario3 <- oddsratio(table_atbrgl6_scenario3, conf.level = 0.95)$measure print(kable(table_atbrgl6_scenario3, caption = "Contingency Table: Nationality vs. ATBRGL6 (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl6_scenario3) print(odds_ratio_atbrgl6_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM1= Antibiotic resistance is one of the biggest problems the world faces Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Load the Database_simplified dataframe df <- read_excel("C:/Database_simplified.xlsx") # Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_resdim1_scenario1 <- df[df$RESDIM1 %in% c(1, 3) & df$CIT1 %in% c(0, 1), ] table_resdim1_scenario1 <- table(df_filtered_resdim1_scenario1$RESDIM1, df_filtered_resdim1_scenario1$CIT1) rownames(table_resdim1_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_resdim1_scenario1) <- c("Canadian", "Other") chi_result_resdim1_scenario1 <- chisq.test(table_resdim1_scenario1) odds_ratio_resdim1_scenario1 <- oddsratio(table_resdim1_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim1_scenario1, caption = "Contingency Table: Nationality vs. Perception of Antibiotic Resistance as a Global Problem (Strongly Agree vs. Strongly Disagree)")) print(chi_result_resdim1_scenario1) print(odds_ratio_resdim1_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim1_scenario2 <- df[df$RESDIM1 %in% c(2, 3) & df$CIT1 %in% c(0, 1), ] table_resdim1_scenario2 <- table(df_filtered_resdim1_scenario2$RESDIM1, df_filtered_resdim1_scenario2$CIT1) rownames(table_resdim1_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_resdim1_scenario2) <- c("Canadian", "Other") chi_result_resdim1_scenario2 <- chisq.test(table_resdim1_scenario2) odds_ratio_resdim1_scenario2 <- oddsratio(table_resdim1_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim1_scenario2, caption = "Contingency Table: Nationality vs. Perception of Antibiotic Resistance as a Global Problem (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim1_scenario2) print(odds_ratio_resdim1_scenario2) # Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim1_scenario3 <- df[df$RESDIM1 %in% c(1, 2, 3) & df$CIT1 %in% c(0, 1), ] df_filtered_resdim1_scenario3$Disagree_Neither <- df_filtered_resdim1_scenario3$RESDIM1 %in% c(1, 2) table_resdim1_scenario3 <- table(df_filtered_resdim1_scenario3$Disagree_Neither, df_filtered_resdim1_scenario3$CIT1) rownames(table_resdim1_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_resdim1_scenario3) <- c("Canadian", "Other") chi_result_resdim1_scenario3 <- chisq.test(table_resdim1_scenario3) odds_ratio_resdim1_scenario3 <- oddsratio(table_resdim1_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim1_scenario3, caption = "Contingency Table: Nationality vs. Perception of Antibiotic Resistance as a Global Problem (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_resdim1_scenario3) print(odds_ratio_resdim1_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM2= Medical experts will solve the problem of antibiotic resistance before it becomes too serious Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Load the Database_simplified dataframe df <- read_excel("C:/Database_simplified.xlsx") # Scenario 1: Strongly Agree vs. Strongly Disagree df_filtered_resdim2_scenario1 <- df[df$RESDIM2 %in% c(1, 3) & df$CIT1 %in% c(0, 1), ] table_resdim2_scenario1 <- table(df_filtered_resdim2_scenario1$RESDIM2, df_filtered_resdim2_scenario1$CIT1) rownames(table_resdim2_scenario1) <- c("Strongly Agree", "Strongly Disagree") colnames(table_resdim2_scenario1) <- c("Canadian", "Other") chi_result_resdim2_scenario1 <- chisq.test(table_resdim2_scenario1) odds_ratio_resdim2_scenario1 <- oddsratio(table_resdim2_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim2_scenario1, caption = "Contingency Table: Nationality vs. Belief in Solving Antibiotic Resistance (Strongly Disagree vs. Strongly Agree)")) print(chi_result_resdim2_scenario1) print(odds_ratio_resdim2_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim2_scenario2 <- df[df$RESDIM2 %in% c(1, 2) & df$CIT1 %in% c(0, 1), ] table_resdim2_scenario2 <- table(df_filtered_resdim2_scenario2$RESDIM2, df_filtered_resdim2_scenario2$CIT1) rownames(table_resdim2_scenario2) <- c("Strongly Disagree", "Neither Agree Nor Disagree") colnames(table_resdim2_scenario2) <- c("Canadian", "Other") chi_result_resdim2_scenario2 <- chisq.test(table_resdim2_scenario2) odds_ratio_resdim2_scenario2 <- oddsratio(table_resdim2_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim2_scenario2, caption = "Contingency Table: Nationality vs. Belief in Solving Antibiotic Resistance (Strongly Disagree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim2_scenario2) print(odds_ratio_resdim2_scenario2) # Scenario 3: Strongly Agree + Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim2_scenario3 <- df[df$RESDIM2 %in% c(1, 2, 3) & df$CIT1 %in% c(0, 1), ] df_filtered_resdim2_scenario3$Agree_Neither <- df_filtered_resdim2_scenario3$RESDIM2 %in% c(2, 3) table_resdim2_scenario3 <- table(df_filtered_resdim2_scenario3$Agree_Neither, df_filtered_resdim2_scenario3$CIT1) rownames(table_resdim2_scenario3) <- c("Strongly Disagree", "Strongly Agree + Neither") colnames(table_resdim2_scenario3) <- c("Canadian", "Other") chi_result_resdim2_scenario3 <- chisq.test(table_resdim2_scenario3) odds_ratio_resdim2_scenario3 <- oddsratio(table_resdim2_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim2_scenario3, caption = "Contingency Table: Nationality vs. Belief in Solving Antibiotic Resistance (Strongly Disagree vs. Strongly Agree + Neither Agree Nor Disagree)")) print(chi_result_resdim2_scenario3) print(odds_ratio_resdim2_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM3= Everyone needs to use antibiotics responsibly Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_resdim3_scenario1 <- df[df$RESDIM3 %in% c(1, 3) & df$CIT1 %in% c(0, 1), ] table_resdim3_scenario1 <- table(df_filtered_resdim3_scenario1$RESDIM3, df_filtered_resdim3_scenario1$CIT1) rownames(table_resdim3_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_resdim3_scenario1) <- c("Canadian", "Other") chi_result_resdim3_scenario1 <- chisq.test(table_resdim3_scenario1) odds_ratio_resdim3_scenario1 <- oddsratio(table_resdim3_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim3_scenario1, caption = "Contingency Table: Nationality vs. Everyone Needs to Use Antibiotics Responsibly (Strongly Agree vs. Strongly Disagree)")) print(chi_result_resdim3_scenario1) print(odds_ratio_resdim3_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim3_scenario2 <- df[df$RESDIM3 %in% c(2, 3) & df$CIT1 %in% c(0, 1), ] table_resdim3_scenario2 <- table(df_filtered_resdim3_scenario2$RESDIM3, df_filtered_resdim3_scenario2$CIT1) rownames(table_resdim3_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_resdim3_scenario2) <- c("Canadian", "Other") chi_result_resdim3_scenario2 <- chisq.test(table_resdim3_scenario2) odds_ratio_resdim3_scenario2 <- oddsratio(table_resdim3_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim3_scenario2, caption = "Contingency Table: Nationality vs. Everyone Needs to Use Antibiotics Responsibly (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim3_scenario2) print(odds_ratio_resdim3_scenario2) # Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim3_scenario3 <- df[df$RESDIM3 %in% c(1, 2, 3) & df$CIT1 %in% c(0, 1), ] df_filtered_resdim3_scenario3$Disagree_Neither <- df_filtered_resdim3_scenario3$RESDIM3 %in% c(1, 2) table_resdim3_scenario3 <- table(df_filtered_resdim3_scenario3$Disagree_Neither, df_filtered_resdim3_scenario3$CIT1) rownames(table_resdim3_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_resdim3_scenario3) <- c("Canadian", "Other") chi_result_resdim3_scenario3 <- chisq.test(table_resdim3_scenario3) odds_ratio_resdim3_scenario3 <- oddsratio(table_resdim3_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim3_scenario3, caption = "Contingency Table: Nationality vs. Everyone Needs to Use Antibiotics Responsibly (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_resdim3_scenario3) print(odds_ratio_resdim3_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM4= People like me can't do much to stop antibiotic resistance Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Agree vs. Strongly Disagree df_filtered_resdim4_scenario1 <- df[df$RESDIM4 %in% c(1, 3) & df$CIT1 %in% c(0, 1), ] table_resdim4_scenario1 <- table(df_filtered_resdim4_scenario1$RESDIM4, df_filtered_resdim4_scenario1$CIT1) rownames(table_resdim4_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_resdim4_scenario1) <- c("Canadian", "Other") chi_result_resdim4_scenario1 <- chisq.test(table_resdim4_scenario1) odds_ratio_resdim4_scenario1 <- oddsratio(table_resdim4_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim4_scenario1, caption = "Contingency Table: Nationality vs. Belief in Individual Impact on Antibiotic Resistance (Strongly Disagree vs. Strongly Agree)")) print(chi_result_resdim4_scenario1) print(odds_ratio_resdim4_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim4_scenario2 <- df[df$RESDIM4 %in% c(1, 2) & df$CIT1 %in% c(0, 1), ] table_resdim4_scenario2 <- table(df_filtered_resdim4_scenario2$RESDIM4, df_filtered_resdim4_scenario2$CIT1) rownames(table_resdim4_scenario2) <- c("Strongly Disagree", "Neither Agree Nor Disagree") colnames(table_resdim4_scenario2) <- c("Canadian", "Other") chi_result_resdim4_scenario2 <- chisq.test(table_resdim4_scenario2) odds_ratio_resdim4_scenario2 <- oddsratio(table_resdim4_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim4_scenario2, caption = "Contingency Table: Nationality vs. Belief in Individual Impact on Antibiotic Resistance (Strongly Disagree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim4_scenario2) print(odds_ratio_resdim4_scenario2) # Scenario 3: Strongly Agree + Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim4_scenario3 <- df[df$RESDIM4 %in% c(1, 2, 3) & df$CIT1 %in% c(0, 1), ] df_filtered_resdim4_scenario3$Agree_Neither <- df_filtered_resdim4_scenario3$RESDIM4 %in% c(2, 3) table_resdim4_scenario3 <- table(df_filtered_resdim4_scenario3$Agree_Neither, df_filtered_resdim4_scenario3$CIT1) rownames(table_resdim4_scenario3) <- c("Strongly Disagree", "Strongly Agree + Neither") colnames(table_resdim4_scenario3) <- c("Canadian", "Other") chi_result_resdim4_scenario3 <- chisq.test(table_resdim4_scenario3) odds_ratio_resdim4_scenario3 <- oddsratio(table_resdim4_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim4_scenario3, caption = "Contingency Table: Nationality vs. Belief in Individual Impact on Antibiotic Resistance (Strongly Disagree vs. Strongly Agree + Neither Agree Nor Disagree)")) print(chi_result_resdim4_scenario3) print(odds_ratio_resdim4_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM5= I am worried about the impact that antibiotic resistance will have on my health and that of my family # Load the Database_simplified dataframe df <- read_excel("C:/Database_simplified.xlsx") # Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_resdim5_scenario1 <- df[df$RESDIM5 %in% c(1, 3) & df$CIT1 %in% c(0, 1), ] table_resdim5_scenario1 <- table(df_filtered_resdim5_scenario1$RESDIM5, df_filtered_resdim5_scenario1$CIT1) rownames(table_resdim5_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_resdim5_scenario1) <- c("Canadian", "Other") chi_result_resdim5_scenario1 <- chisq.test(table_resdim5_scenario1) odds_ratio_resdim5_scenario1 <- oddsratio(table_resdim5_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim5_scenario1, caption = "Contingency Table: Nationality vs. Impact of AMR on personal health and that of their family (Strongly Agree vs. Strongly Disagree)")) print(chi_result_resdim5_scenario1) print(odds_ratio_resdim5_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim5_scenario2 <- df[df$RESDIM5 %in% c(2, 3) & df$CIT1 %in% c(0, 1), ] table_resdim5_scenario2 <- table(df_filtered_resdim5_scenario2$RESDIM5, df_filtered_resdim5_scenario2$CIT1) rownames(table_resdim5_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_resdim5_scenario2) <- c("Canadian", "Other") chi_result_resdim5_scenario2 <- chisq.test(table_resdim5_scenario2) odds_ratio_resdim5_scenario2 <- oddsratio(table_resdim5_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim5_scenario2, caption = "Contingency Table: Nationality vs. Impact of AMR on personal health and that of their family (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim5_scenario2) print(odds_ratio_resdim5_scenario2) # Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim5_scenario3 <- df[df$RESDIM5 %in% c(1, 2, 3) & df$CIT1 %in% c(0, 1), ] df_filtered_resdim5_scenario3$Disagree_Neither <- df_filtered_resdim5_scenario3$RESDIM5 %in% c(1, 2) table_resdim5_scenario3 <- table(df_filtered_resdim5_scenario3$Disagree_Neither, df_filtered_resdim5_scenario3$CIT1) rownames(table_resdim5_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_resdim5_scenario3) <- c("Canadian", "Other") chi_result_resdim5_scenario3 <- chisq.test(table_resdim5_scenario3) odds_ratio_resdim5_scenario3 <- oddsratio(table_resdim5_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim5_scenario3, caption = "Contingency Table: Nationality vs. Impact of AMR on personal health and that of their family (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_resdim5_scenario3) print(odds_ratio_resdim5_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM6= I am not at risk of getting an antibiotic-resistant infection, as long as I take my antibiotics correctly # Load the Database_simplified dataframe df <- read_excel("C:/Database_simplified.xlsx") # Scenario 1: Strongly Agree vs. Strongly Disagree df_filtered_resdim6_scenario1 <- df[df$RESDIM6 %in% c(1, 3) & df$CIT1 %in% c(0, 1), ] table_resdim6_scenario1 <- table(df_filtered_resdim6_scenario1$RESDIM6, df_filtered_resdim6_scenario1$CIT1) rownames(table_resdim6_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_resdim6_scenario1) <- c("Canadian", "Other") chi_result_resdim6_scenario1 <- chisq.test(table_resdim6_scenario1) odds_ratio_resdim6_scenario1 <- oddsratio(table_resdim6_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim6_scenario1, caption = "Contingency Table: Nationality vs. Perception of Risk of Antibiotic-Resistant Infection (Strongly Disagree vs. Strongly Agree)")) print(chi_result_resdim6_scenario1) print(odds_ratio_resdim6_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim6_scenario2 <- df[df$RESDIM6 %in% c(1, 2) & df$CIT1 %in% c(0, 1), ] table_resdim6_scenario2 <- table(df_filtered_resdim6_scenario2$RESDIM6, df_filtered_resdim6_scenario2$CIT1) rownames(table_resdim6_scenario2) <- c("Strongly Disagree", "Neither Agree Nor Disagree") colnames(table_resdim6_scenario2) <- c("Canadian", "Other") chi_result_resdim6_scenario2 <- chisq.test(table_resdim6_scenario2) odds_ratio_resdim6_scenario2 <- oddsratio(table_resdim6_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim6_scenario2, caption = "Contingency Table: Nationality vs. Perception of Risk of Antibiotic-Resistant Infection (Strongly Disagree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim6_scenario2) print(odds_ratio_resdim6_scenario2) # Scenario 3: Strongly Agree + Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim6_scenario3 <- df[df$RESDIM6 %in% c(1, 2, 3) & df$CIT1 %in% c(0, 1), ] df_filtered_resdim6_scenario3$Agree_Neither <- df_filtered_resdim6_scenario3$RESDIM6 %in% c(2, 3) table_resdim6_scenario3 <- table(df_filtered_resdim6_scenario3$Agree_Neither, df_filtered_resdim6_scenario3$CIT1) rownames(table_resdim6_scenario3) <- c("Strongly Disagree", "Strongly Agree + Neither") colnames(table_resdim6_scenario3) <- c("Canadian", "Other") chi_result_resdim6_scenario3 <- chisq.test(table_resdim6_scenario3) odds_ratio_resdim6_scenario3 <- oddsratio(table_resdim6_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim6_scenario3, caption = "Contingency Table: Nationality vs. Perception of Risk of Antibiotic-Resistant Infection (Strongly Disagree vs. Strongly Agree + Neither Agree Nor Disagree)")) print(chi_result_resdim6_scenario3) print(odds_ratio_resdim6_scenario3) ############################################### Comparisons by Age############################################# ############################################### 18-34 vs. Other ############################################### ###CUSIN1 (I wash my hands before cooking (No= 9.4%)) # Load the Database_simplified dataframe Database_simplified <- read_excel("C:/Database_simplified.xlsx") # Filter the DataFrame df_filtered <- Database_simplified[Database_simplified$CUSIN1 %in% c(0, 1) & Database_simplified$AGE %in% c(1, 2, 3, 4, 5, 6), ] # Create a new variable for age categorization df_filtered$Age_Group <- ifelse(df_filtered$AGE %in% c(1, 2), "18-34", "35+") # Create the Contingency Table table <- table(df_filtered$CUSIN1, df_filtered$Age_Group) # Add descriptive labels rownames(table) <- c("CUSIN1 (Yes)", "CUSIN1 (No)") colnames(table) <- c("18-34", "35+") # Print the contingency table using knitr kable(table, caption = "Contingency Table: Age Group vs. Hand Washing") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) --------------------------------------------------------------------------------------------------- ##CUSIN2 (After handling raw food (meat and vegetables), I wash my hands with soap (No= 15.1%) df_filtered <- Database_simplified[Database_simplified$CUSIN2 %in% c(0, 1) & Database_simplified$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered$Age_Group <- ifelse(df_filtered$AGE %in% c(1, 2), "18-34", "35+") table <- table(df_filtered$CUSIN2, df_filtered$Age_Group) rownames(table) <- c("CUSIN2 (Yes)", "CUSIN2 (No)") colnames(table) <- c("18-34", "35+") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: AGE vs. After handling raw food (meat and vegetables), I wash my hands with soap") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------ ##CUSIN3 (I use the same kitchen utensils for handling raw and ready-to-eat foods (Yes=25.8%)) df_filtered <- Database_simplified[Database_simplified$CUSIN3 %in% c(0, 1) & Database_simplified$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered$Age_Group <- ifelse(df_filtered$AGE %in% c(1, 2), "18-34", "35+") table <- table(df_filtered$CUSIN3, df_filtered$Age_Group) rownames(table) <- c("CUSIN3 (Yes)", "CUSIN3 (No)") colnames(table) <- c("18-34", "35+") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: AGE vs. I use the same kitchen utensils for handling raw and ready-to-eat foods") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------- ##CUSIN4 (I wash kitchen utensils that have been used for raw food before using them to prepare other foods (No=16.8%)) df_filtered <- Database_simplified[Database_simplified$CUSIN4 %in% c(0, 1) & Database_simplified$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered$Age_Group <- ifelse(df_filtered$AGE %in% c(1, 2), "18-34", "35+") table <- table(df_filtered$CUSIN4, df_filtered$Age_Group) rownames(table) <- c("CUSIN4 (Yes)", "CUSIN4 (No)") colnames(table) <- c("18-34", "35+") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Age vs. I wash kitchen utensils that have been used for raw food before using them to prepare other foods") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------- ##CUSIN5 (I wash fruits and vegetables before eating them (No=20.7%)) df_filtered <- Database_simplified[Database_simplified$CUSIN5 %in% c(0, 1) & Database_simplified$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered$Age_Group <- ifelse(df_filtered$AGE %in% c(1, 2), "18-34", "35+") table <- table(df_filtered$CUSIN5, df_filtered$Age_Group) rownames(table) <- c("CUSIN5 (Yes)", "CUSIN5 (No)") colnames(table) <- c("18-34", "35+") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Age vs. I wash fruits and vegetables before eating them") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------- ##CUSIN6 (I wash my hands before eating (No=21.5)) df_filtered <- Database_simplified[Database_simplified$CUSIN6 %in% c(0, 1) & Database_simplified$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered$Age_Group <- ifelse(df_filtered$AGE %in% c(1, 2), "18-34", "35+") table <- table(df_filtered$CUSIN6, df_filtered$Age_Group) rownames(table) <- c("CUSIN6 (Yes)", "CUSIN6 (No)") colnames(table) <- c("18-34", "35+") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Age vs. I wash my hands before eating") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) --------------------------------------------------------------------------------------------------------------------- ##PRESCATB1 When you get a prescription for antibiotics, do you follow the recommended ##length of treatment and daily dosage? (No=4.2%) (Sometimes=9.6%) (No+Sometimes=13.8%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) df <- Database_simplified ############### 1st scenario= No df_filtered_prescatb1 <- df[df$PRESCATB1 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_prescatb1$Age_Group <- ifelse(df_filtered_prescatb1$AGE %in% c(1, 2), "18-34", "35+") table_prescatb1 <- table(df_filtered_prescatb1$PRESCATB1, df_filtered_prescatb1$Age_Group) # Add descriptive labels to the rows and columns rownames(table_prescatb1) <- c("Yes", "No") # Perform the Chi-Squared test chi_result_prescatb1 <- chisq.test(table_prescatb1) # Calculate the odds ratio and confidence interval odds_ratio_prescatb1 <- oddsratio(table_prescatb1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_prescatb1, caption = "Contingency Table: Age vs. Following Prescription for Antibiotics")) # Print the results of the Chi-Squared test print(chi_result_prescatb1) # Print the odds ratio and confidence interval print(odds_ratio_prescatb1) ################## 2nd scenario= Sometimes df_filtered_prescatb1_sometimes <- df[df$PRESCATB1 %in% c(0, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_prescatb1_sometimes$Age_Group <- ifelse(df_filtered_prescatb1_sometimes$AGE %in% c(1, 2), "18-34", "35+") table_prescatb1_sometimes <- table(df_filtered_prescatb1_sometimes$PRESCATB1, df_filtered_prescatb1_sometimes$Age_Group) # Add descriptive labels to the rows and columns rownames(table_prescatb1_sometimes) <- c("Yes", "No") # Perform the Chi-Squared test chi_result_prescatb1_sometimes <- chisq.test(table_prescatb1_sometimes) # Calculate the odds ratio and confidence interval odds_ratio_prescatb1_sometimes <- oddsratio(table_prescatb1_sometimes, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_prescatb1_sometimes, caption = "Contingency Table: Age vs. Following Prescription for Antibiotics Sometimes")) # Print the results of the Chi-Squared test print(chi_result_prescatb1_sometimes) # Print the odds ratio and confidence interval print(odds_ratio_prescatb1_sometimes) ################## 3rd scenario= No+Sometimes # Filter for 'Yes', 'No', and 'Sometimes' responses for PRESCATB1 and genders 'Female' and 'Male' df_filtered_prescatb1_combined <- df[df$PRESCATB1 %in% c(0, 1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_prescatb1_combined$Age_Group <- ifelse(df_filtered_prescatb1_combined$AGE %in% c(1, 2), "18-34", "35+") df_filtered_prescatb1_combined$No_Sometimes <- df_filtered_prescatb1_combined$PRESCATB1 %in% c(1, 3) table_prescatb1_combined <- table(df_filtered_prescatb1_combined$No_Sometimes, df_filtered_prescatb1_combined$Age_Group) # Adjust the table to have 'Yes' and 'No+Sometimes' as row names rownames(table_prescatb1_combined) <- c("Yes", "No_Sometimes") # Perform the Chi-Squared test chi_result_prescatb1_combined <- chisq.test(table_prescatb1_combined) # Calculate the odds ratio and confidence interval odds_ratio_prescatb1_combined <- oddsratio(table_prescatb1_combined, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_prescatb1_combined, caption = "Contingency Table: Age vs. Following Prescription for Antibiotics (Yes vs. No+Sometimes)")) # Print the results of the Chi-Squared test print(chi_result_prescatb1_combined) # Print the odds ratio and confidence interval print(odds_ratio_prescatb1_combined) --------------------------------------------------------------------------------------------------------------------- ##ARRETATB Do you stop taking antibiotics when symptoms start to disappear? ##(Always=7.3%) (Sometimes=20.4%) (Always+Sometimes=27.7%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) df <- Database_simplified ############### 1st scenario= Always df_filtered_arretatb <- df[df$ARRETATB %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_arretatb$Age_Group <- ifelse(df_filtered_arretatb$AGE %in% c(1, 2), "18-34", "35+") table_arretatb <- table(df_filtered_arretatb$ARRETATB, df_filtered_arretatb$Age_Group) # (Restante do script permanece o mesmo, substituindo 'GENRE' por 'Age_Group') # Add descriptive labels to the rows and columns rownames(table_arretatb) <- c("Always", "Never") # Perform the Chi-Squared test chi_result_arretatb <- chisq.test(table_arretatb) # Calculate the odds ratio and confidence interval odds_ratio_arretatb <- oddsratio(table_arretatb, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_arretatb, caption = "Contingency Table: Age vs. Stopping Antibiotics Always vs. Never")) # Print the results of the Chi-Squared test print(chi_result_arretatb) # Print the odds ratio and confidence interval print(odds_ratio_arretatb) ################# 2nd Cenario: Sometimes df_filtered_arretatb_sometimes <- df[df$ARRETATB %in% c(1, 2) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_arretatb_sometimes$Age_Group <- ifelse(df_filtered_arretatb_sometimes$AGE %in% c(1, 2), "18-34", "35+") table_arretatb_sometimes <- table(df_filtered_arretatb_sometimes$ARRETATB == 2, df_filtered_arretatb_sometimes$Age_Group) # Add descriptive labels to the rows and columns rownames(table_arretatb_sometimes) <- c("Never", "Sometimes") # Perform the Chi-Squared test chi_result_arretatb_sometimes <- chisq.test(table_arretatb_sometimes) # Calculate the odds ratio and confidence interval odds_ratio_arretatb_sometimes <- oddsratio(table_arretatb_sometimes, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_arretatb_sometimes, caption = "Contingency Table: Age vs. Stopping Antibiotics Sometimes vs. Never")) # Print the results of the Chi-Squared test print(chi_result_arretatb_sometimes) # Print the odds ratio and confidence interval print(odds_ratio_arretatb_sometimes) ############### #3rd scenario= Sometimes+Always df_filtered_arretatb_combined <- df[df$ARRETATB %in% c(0, 1, 2) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_arretatb_combined$Age_Group <- ifelse(df_filtered_arretatb_combined$AGE %in% c(1, 2), "18-34", "35+") df_filtered_arretatb_combined$Sometimes_Always <- df_filtered_arretatb_combined$ARRETATB %in% c(0, 2) table_arretatb_combined <- table(df_filtered_arretatb_combined$Sometimes_Always, df_filtered_arretatb_combined$Age_Group) # Add descriptive labels to the rows and columns rownames(table_arretatb_combined) <- c("Never", "Sometimes_Always") # Perform the Chi-Squared test chi_result_arretatb_combined <- chisq.test(table_arretatb_combined) # Calculate the odds ratio and confidence interval odds_ratio_arretatb_combined <- oddsratio(table_arretatb_combined, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_arretatb_combined, caption = "Contingency Table: Age vs. Stopping Antibiotics (Sometimes+Always vs. Never)")) # Print the results of the Chi-Squared test print(chi_result_arretatb_combined) # Print the odds ratio and confidence interval print(odds_ratio_arretatb_combined) --------------------------------------------------------------------------------------------------------------------- ##ATBORAL1 Have you ever taken an oral antibiotic treatment (by mouth) without a medical prescription? (Yes=12.3%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified df_filtered_atboral <- df[df$ATBORAL1 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atboral$Age_Group <- ifelse(df_filtered_atboral$AGE %in% c(1, 2), "18-34", "35+") table_atboral <- table(df_filtered_atboral$ATBORAL1, df_filtered_atboral$Age_Group) # Add descriptive labels to the rows and columns rownames(table_atboral) <- c("Yes", "No") # Perform the Chi-Squared test chi_result_atboral <- chisq.test(table_atboral) # Calculate the odds ratio and confidence interval odds_ratio_atboral <- oddsratio(table_atboral, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atboral, caption = "Contingency Table: Age vs. Taking Oral Antibiotics Without Prescription (Yes vs. No)")) # Print the results of the Chi-Squared test print(chi_result_atboral) # Print the odds ratio and confidence interval print(odds_ratio_atboral) -------------------------------------------------------------------------------------------------------- ### ATBANI1 I can exchange resistant bacteria with my pet (False=23.2%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified df_filtered_atbani1 <- df[df$ATBANI1 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbani1$Age_Group <- ifelse(df_filtered_atbani1$AGE %in% c(1, 2), "18-34", "35+") table_atbani1 <- table(df_filtered_atbani1$ATBANI1, df_filtered_atbani1$Age_Group) rownames(table_atbani1) <- c("True", "False") colnames(table_atbani1) <- c("18-34", "35+") # Perform the Chi-Squared test chi_result_atbani1 <- chisq.test(table_atbani1) # Calculate the odds ratio and confidence interval odds_ratio_atbani1 <- oddsratio(table_atbani1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani1, caption = "Contingency Table: Age vs. Exchanging Resistant Bacteria with Pets (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani1) # Print the odds ratio and confidence interval print(odds_ratio_atbani1) --------------------------------------------------------------------------------------------------------------------- ### ATBANI2=The use of antibiotics in livestock and crops can increase the #presence of resistant bacteria in the environment (False=14.7%) df_filtered_atbani2 <- df[df$ATBANI2 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbani2$Age_Group <- ifelse(df_filtered_atbani2$AGE %in% c(1, 2), "18-34", "35+") table_atbani2 <- table(df_filtered_atbani2$ATBANI2, df_filtered_atbani2$Age_Group) rownames(table_atbani2) <- c("True", "False") colnames(table_atbani2) <- c("18-34", "35+") # Perform the Chi-Squared test chi_result_atbani2 <- chisq.test(table_atbani2) # Calculate the odds ratio and confidence interval odds_ratio_atbani2 <- oddsratio(table_atbani2, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani2, caption = "Contingency Table: Age vs. Antibiotics in Livestock and Crops Affecting Environment (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani2) # Print the odds ratio and confidence interval print(odds_ratio_atbani2) -------------------------------------------------------------------------------------------------------------------- ##### ATBANI3 The use of antibiotics in livestock and crops can affect me directly ##(I can get resistant bacteria in my body) (False=26.3%) df_filtered_atbani3 <- df[df$ATBANI3 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbani3$Age_Group <- ifelse(df_filtered_atbani3$AGE %in% c(1, 2), "18-34", "35+") table_atbani3 <- table(df_filtered_atbani3$ATBANI3, df_filtered_atbani3$Age_Group) rownames(table_atbani3) <- c("True", "False") colnames(table_atbani3) <- c("18-34", "35+") # Perform the Chi-Squared test chi_result_atbani3 <- chisq.test(table_atbani3) # Calculate the odds ratio and confidence interval odds_ratio_atbani3 <- oddsratio(table_atbani3, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani3, caption = "Contingency Table: Age vs. Antibiotics in Livestock and Crops Affecting Humans Directly (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani3) # Print the odds ratio and confidence interval print(odds_ratio_atbani3) ------------------------------------------------------------------------------------------------------------------- ##### ATBANI4 Resistant bacteria are only found in hospitals (True=10.8%) df_filtered_atbani4 <- df[df$ATBANI4 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbani4$Age_Group <- ifelse(df_filtered_atbani4$AGE %in% c(1, 2), "18-34", "35+") table_atbani4 <- table(df_filtered_atbani4$ATBANI4, df_filtered_atbani4$Age_Group) rownames(table_atbani4) <- c("True", "False") colnames(table_atbani4) <- c("18-34", "35+") # Perform the Chi-Squared test chi_result_atbani4 <- chisq.test(table_atbani4) # Calculate the odds ratio and confidence interval odds_ratio_atbani4 <- oddsratio(table_atbani4, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani4, caption = "Contingency Table: Age vs. Resistant Bacteria Found Only in Hospitals (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani4) # Print the odds ratio and confidence interval print(odds_ratio_atbani4) ---------------------------------------------------------------------------------------------------------------------- #####RESATB1 Antibiotic resistance occurs when your body becomes resistant to antibiotics and they ##no longer work as well (True=58.3%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified df_filtered_resatb1 <- df[df$RESATB1 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resatb1$Age_Group <- ifelse(df_filtered_resatb1$AGE %in% c(1, 2), "18-34", "35+") table_resatb1 <- table(df_filtered_resatb1$RESATB1, df_filtered_resatb1$Age_Group) rownames(table_resatb1) <- c("True", "False") colnames(table_resatb1) <- c("18-34", "35+") # Perform the Chi-Squared test chi_result_resatb1 <- chisq.test(table_resatb1) # Calculate the odds ratio and confidence interval odds_ratio_resatb1 <- oddsratio(table_resatb1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb1, caption = "Contingency Table: Age vs. Understanding of Antibiotic Resistance (RESATB1: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb1) print(odds_ratio_resatb1) ------------------------------------------------------------------------------------------------------------------- #####RESATB2 Many infections are becoming increasingly resistant to antibiotic treatment (False=12.5%) # Load the database df <- Database_simplified df_filtered_resatb2 <- df[df$RESATB2 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resatb2$Age_Group <- ifelse(df_filtered_resatb2$AGE %in% c(1, 2), "18-34", "35+") table_resatb2 <- table(df_filtered_resatb2$RESATB2, df_filtered_resatb2$Age_Group) rownames(table_resatb2) <- c("True", "False") colnames(table_resatb2) <- c("18-34", "35+") # Perform the Chi-Squared test chi_result_resatb2 <- chisq.test(table_resatb2) # Calculate the odds ratio and confidence interval odds_ratio_resatb2 <- oddsratio(table_resatb2, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb2, caption = "Contingency Table: Age vs. Perception of Increasing Infection Resistance (RESATB2: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb2) print(odds_ratio_resatb2) --------------------------------------------------------------------------------------------------------------------- #####RESATB3 If bacteria are resistant to antibiotics, it can be very difficult or impossible to treat the infections they cause (False=16.7%) # Load the database df <- Database_simplified df_filtered_resatb3 <- df[df$RESATB3 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resatb3$Age_Group <- ifelse(df_filtered_resatb3$AGE %in% c(1, 2), "18-34", "35+") table_resatb3 <- table(df_filtered_resatb3$RESATB3, df_filtered_resatb3$Age_Group) rownames(table_resatb3) <- c("True", "False") colnames(table_resatb3) <- c("18-34", "35+") # Perform the Chi-Squared test chi_result_resatb3 <- chisq.test(table_resatb3) # Calculate the odds ratio and confidence interval odds_ratio_resatb3 <- oddsratio(table_resatb3, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb3, caption = "Contingency Table: Age vs. Perception of Difficulty Treating Infections (RESATB3: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb3) print(odds_ratio_resatb3) ---------------------------------------------------------------------------------------------------------------------- #####RESATB4 Antibiotic resistance is an issue that could affect me or my family (False=11.8%) # Load the database df <- Database_simplified df_filtered_resatb4 <- df[df$RESATB4 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resatb4$Age_Group <- ifelse(df_filtered_resatb4$AGE %in% c(1, 2), "18-34", "35+") table_resatb4 <- table(df_filtered_resatb4$RESATB4, df_filtered_resatb4$Age_Group) rownames(table_resatb4) <- c("True", "False") colnames(table_resatb4) <- c("18-34", "35+") # Perform the Chi-Squared test chi_result_resatb4 <- chisq.test(table_resatb4) # Calculate the odds ratio and confidence interval odds_ratio_resatb4 <- oddsratio(table_resatb4, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb4, caption = "Contingency Table: Age vs. Perception of Antibiotic Resistance Affecting One's Family (RESATB4: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb4) print(odds_ratio_resatb4) --------------------------------------------------------------------------------------------------------------------- #####RESATB5 Antibiotic resistance is an issue in other countries but not here (True=9.9%) # Load the database df <- Database_simplified df_filtered_resatb5 <- df[df$RESATB5 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resatb5$Age_Group <- ifelse(df_filtered_resatb5$AGE %in% c(1, 2), "18-34", "35+") table_resatb5 <- table(df_filtered_resatb5$RESATB5, df_filtered_resatb5$Age_Group) rownames(table_resatb5) <- c("True", "False") colnames(table_resatb5) <- c("18-34", "35+") # Perform the Chi-Squared test chi_result_resatb5 <- chisq.test(table_resatb5) # Calculate the odds ratio and confidence interval odds_ratio_resatb5 <- oddsratio(table_resatb5, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb5, caption = "Contingency Table: Age vs. Perception of Antibiotic Resistance as an Issue Only in Other Countries (RESATB5: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb5) print(odds_ratio_resatb5) --------------------------------------------------------------------------------------------------------------------- #####RESATB6 Antibiotic resistance is only a problem for people who take antibiotics regularly (True=17.5%) # Load the database df <- Database_simplified df_filtered_resatb6 <- df[df$RESATB6 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resatb6$Age_Group <- ifelse(df_filtered_resatb6$AGE %in% c(1, 2), "18-34", "35+") table_resatb6 <- table(df_filtered_resatb6$RESATB6, df_filtered_resatb6$Age_Group) rownames(table_resatb6) <- c("True", "False") colnames(table_resatb6) <- c("18-34", "35+") # Perform the Chi-Squared test chi_result_resatb6 <- chisq.test(table_resatb6) # Calculate the odds ratio and confidence interval odds_ratio_resatb6 <- oddsratio(table_resatb6, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb6, caption = "Contingency Table: Age vs. Perception of Antibiotic Resistance as a Problem Only for Regular Antibiotic Users (RESATB6: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb6) print(odds_ratio_resatb6) --------------------------------------------------------------------------------------------------------------------- #####RESATB7 Bacteria that are resistant to antibiotics can be spread from person to person (False=20.2%) # Load the database df <- Database_simplified df_filtered_resatb7 <- df[df$RESATB7 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resatb7$Age_Group <- ifelse(df_filtered_resatb7$AGE %in% c(1, 2), "18-34", "35+") table_resatb7 <- table(df_filtered_resatb7$RESATB7, df_filtered_resatb7$Age_Group) rownames(table_resatb7) <- c("True", "False") colnames(table_resatb7) <- c("18-34", "35+") # Perform the Chi-Squared test chi_result_resatb7 <- chisq.test(table_resatb7) # Calculate the odds ratio and confidence interval odds_ratio_resatb7 <- oddsratio(table_resatb7, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb7, caption = "Contingency Table: Age vs. Perception of Bacteria Transmission Person to Person (RESATB7: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb7) print(odds_ratio_resatb7) -------------------------------------------------------------------------------------------------------------------- #####RESATB8 Antibiotic-resistant infections could make medical procedures like surgery, organ transplants, ##and cancer treatment much more dangerous (False=12.0%) # Load the database df <- Database_simplified df_filtered_resatb8 <- df[df$RESATB8 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resatb8$Age_Group <- ifelse(df_filtered_resatb8$AGE %in% c(1, 2), "18-34", "35+") table_resatb8 <- table(df_filtered_resatb8$RESATB8, df_filtered_resatb8$Age_Group) rownames(table_resatb8) <- c("True", "False") colnames(table_resatb8) <- c("18-34", "35+") # Perform the Chi-Squared test chi_result_resatb8 <- chisq.test(table_resatb8) # Calculate the odds ratio and confidence interval odds_ratio_resatb8 <- oddsratio(table_resatb8, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb8, caption = "Contingency Table: Age vs. Perception of Antibiotic-Resistant Infections and Medical Procedures (RESATB8: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb8) print(odds_ratio_resatb8) -------------------------------------------------------------------------------------------------------------------- # ATBRGL1 Farmers should give fewer antibiotics to food-producing animals ##################### 1st scenario (Strongly desagree=8.68%) vs. Strongly Agree Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load dataframe df <- Database_simplified df_filtered_atbrgl1_scenario1 <- df[df$ATBRGL1 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl1_scenario1$Age_Group <- ifelse(df_filtered_atbrgl1_scenario1$AGE %in% c(1, 2), "18-34", "35+") table_atbrgl1_scenario1 <- table(df_filtered_atbrgl1_scenario1$ATBRGL1, df_filtered_atbrgl1_scenario1$Age_Group) rownames(table_atbrgl1_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl1_scenario1) <- c("18-34", "35+") # Perform the Chi-Squared test chi_result_atbrgl1_scenario1 <- chisq.test(table_atbrgl1_scenario1) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl1_scenario1 <- oddsratio(table_atbrgl1_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl1_scenario1, caption = "Contingency Table: Age vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Strongly Disagree)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_atbrgl1_scenario1) print(odds_ratio_atbrgl1_scenario1) ############################# 2nd scenario Farmers should give fewer antibiotics to ##food-producing animals (Neither agree nor desagree=22.6%) vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_atbrgl1_scenario2 <- df[df$ATBRGL1 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl1_scenario2$Age_Group <- ifelse(df_filtered_atbrgl1_scenario2$AGE %in% c(1, 2), "18-34", "35+") table_atbrgl1_scenario2 <- table(df_filtered_atbrgl1_scenario2$ATBRGL1, df_filtered_atbrgl1_scenario2$Age_Group) rownames(table_atbrgl1_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl1_scenario2) <- c("18-34", "35+") # Perform the Chi-Squared test chi_result_atbrgl1_scenario2 <- chisq.test(table_atbrgl1_scenario2) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl1_scenario2 <- oddsratio(table_atbrgl1_scenario2, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl1_scenario2, caption = "Contingency Table: Age vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Neither Agree Nor Disagree)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_atbrgl1_scenario2) print(odds_ratio_atbrgl1_scenario2) ############################# 3rd scenario (Strongly desagree + Neither agree nor desagree=31.28%) vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_atbrgl1_scenario3 <- df[df$ATBRGL1 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl1_scenario3$Age_Group <- ifelse(df_filtered_atbrgl1_scenario3$AGE %in% c(1, 2), "18-34", "35+") df_filtered_atbrgl1_scenario3$Disagree_Neither <- df_filtered_atbrgl1_scenario3$ATBRGL1 %in% c(1, 2) table_atbrgl1_scenario3 <- table(df_filtered_atbrgl1_scenario3$Disagree_Neither, df_filtered_atbrgl1_scenario3$Age_Group) rownames(table_atbrgl1_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl1_scenario3) <- c("18-34", "35+") # Perform the Chi-Squared test chi_result_atbrgl1_scenario3 <- chisq.test(table_atbrgl1_scenario3) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl1_scenario3 <- oddsratio(table_atbrgl1_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl1_scenario3, caption = "Contingency Table: Age vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Strongly Disagree + Neither)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_atbrgl1_scenario3) print(odds_ratio_atbrgl1_scenario3) -------------------------------------------------------------------------------------------------------------------- # ATBRGL2 People should not keep antibiotics and use them later for other illnesses ############################# 1st scenario Strongly desagree vs. Strongly Agree Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the database df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_atbrgl2_scenario1 <- df[df$ATBRGL2 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl2_scenario1$Age_Group <- ifelse(df_filtered_atbrgl2_scenario1$AGE %in% c(1, 2), "18-34", "35+") table_atbrgl2_scenario1 <- table(df_filtered_atbrgl2_scenario1$ATBRGL2, df_filtered_atbrgl2_scenario1$Age_Group) rownames(table_atbrgl2_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl2_scenario1) <- c("18-34", "35+") # Perform Chi-Squared test chi_result_atbrgl2_scenario1 <- chisq.test(table_atbrgl2_scenario1) # Calculate odds ratio and confidence interval odds_ratio_atbrgl2_scenario1 <- oddsratio(table_atbrgl2_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl2_scenario1, caption = "Contingency Table: Age vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl2_scenario1) print(odds_ratio_atbrgl2_scenario1) ############################# 2nd scenario Neither agree nor desagree vs. Strongly Agree # Filter for 'Strongly Agree' (3) and 'Neither Agree Nor Disagree' (2) responses for ATBRGL2 df_filtered_atbrgl2_scenario2 <- df[df$ATBRGL2 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl2_scenario2$Age_Group <- ifelse(df_filtered_atbrgl2_scenario2$AGE %in% c(1, 2), "18-34", "35+") table_atbrgl2_scenario2 <- table(df_filtered_atbrgl2_scenario2$ATBRGL2, df_filtered_atbrgl2_scenario2$Age_Group) rownames(table_atbrgl2_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl2_scenario2) <- c("18-34", "35+") # Perform Chi-Squared test chi_result_atbrgl2_scenario2 <- chisq.test(table_atbrgl2_scenario2) # Calculate odds ratio and confidence interval odds_ratio_atbrgl2_scenario2 <- oddsratio(table_atbrgl2_scenario2, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl2_scenario2, caption = "Contingency Table: Age vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl2_scenario2) print(odds_ratio_atbrgl2_scenario2) ############################# 3rd scenario Neither agree nor desagree + Stringly Disagree vs. Strongly Agree df_filtered_atbrgl2_scenario3 <- df[df$ATBRGL2 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl2_scenario3$Age_Group <- ifelse(df_filtered_atbrgl2_scenario3$AGE %in% c(1, 2), "18-34", "35+") df_filtered_atbrgl2_scenario3$Disagree_Neither <- df_filtered_atbrgl2_scenario3$ATBRGL2 %in% c(1, 2) table_atbrgl2_scenario3 <- table(df_filtered_atbrgl2_scenario3$Disagree_Neither, df_filtered_atbrgl2_scenario3$Age_Group) rownames(table_atbrgl2_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl2_scenario3) <- c("18-34", "35+") # Perform the Chi-Squared test chi_result_atbrgl2_scenario3 <- chisq.test(table_atbrgl2_scenario3) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl2_scenario3 <- oddsratio(table_atbrgl2_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl2_scenario3, caption = "Contingency Table: Age vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl2_scenario3) print(odds_ratio_atbrgl2_scenario3) -------------------------------------------------------------------------------------------------------------------- # ATBRGL3 Parents should make sure all of their children’s vaccinations are up-to-date Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) ####1st scenario # Load dataframe df <- Database_simplified df_filtered_atbrgl3_scenario1 <- df[df$ATBRGL3 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl3_scenario1$Age_Group <- ifelse(df_filtered_atbrgl3_scenario1$AGE %in% c(1, 2), "18-34", "35+") table_atbrgl3_scenario1 <- table(df_filtered_atbrgl3_scenario1$ATBRGL3, df_filtered_atbrgl3_scenario1$Age_Group) rownames(table_atbrgl3_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl3_scenario1) <- c("18-34", "35+") # Perform Chi-Squared test chi_result_atbrgl3_scenario1 <- chisq.test(table_atbrgl3_scenario1) # Calculate odds ratio and confidence interval odds_ratio_atbrgl3_scenario1 <- oddsratio(table_atbrgl3_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl3_scenario1, caption = "Contingency Table: Age vs. Opinion on Children's Vaccinations (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl3_scenario1) print(odds_ratio_atbrgl3_scenario1) ### 2nd Scenario df_filtered_atbrgl3_scenario2 <- df[df$ATBRGL3 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl3_scenario2$Age_Group <- ifelse(df_filtered_atbrgl3_scenario2$AGE %in% c(1, 2), "18-34", "35+") table_atbrgl3_scenario2 <- table(df_filtered_atbrgl3_scenario2$ATBRGL3, df_filtered_atbrgl3_scenario2$Age_Group) rownames(table_atbrgl3_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl3_scenario2) <- c("18-34", "35+") # Perform Chi-Squared test chi_result_atbrgl3_scenario2 <- chisq.test(table_atbrgl3_scenario2) # Calculate odds ratio and confidence interval odds_ratio_atbrgl3_scenario2 <- oddsratio(table_atbrgl3_scenario2, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl3_scenario2, caption = "Contingency Table: Age vs. Opinion on Children's Vaccinations (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl3_scenario2) print(odds_ratio_atbrgl3_scenario2) ## 3rd scenario df_filtered_atbrgl3_scenario3 <- df[df$ATBRGL3 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl3_scenario3$Age_Group <- ifelse(df_filtered_atbrgl3_scenario3$AGE %in% c(1, 2), "18-34", "35+") df_filtered_atbrgl3_scenario3$Disagree_Neither <- df_filtered_atbrgl3_scenario3$ATBRGL3 %in% c(1, 2) table_atbrgl3_scenario3 <- table(df_filtered_atbrgl3_scenario3$Disagree_Neither, df_filtered_atbrgl3_scenario3$Age_Group) rownames(table_atbrgl3_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl3_scenario3) <- c("18-34", "35+") # Perform the Chi-Squared test chi_result_atbrgl3_scenario3 <- chisq.test(table_atbrgl3_scenario3) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl3_scenario3 <- oddsratio(table_atbrgl3_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl3_scenario3, caption = "Contingency Table: Age vs. Opinion on Children's Vaccinations (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl3_scenario3) print(odds_ratio_atbrgl3_scenario3) --------------------------------------------------------------------------------------------------------------------- # ATBRGL4 People should wash their hands regularly Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_atbrgl4_scenario1 <- df[df$ATBRGL4 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl4_scenario1$Age_Group <- ifelse(df_filtered_atbrgl4_scenario1$AGE %in% c(1, 2), "18-34", "35+") table_atbrgl4_scenario1 <- table(df_filtered_atbrgl4_scenario1$ATBRGL4, df_filtered_atbrgl4_scenario1$Age_Group) rownames(table_atbrgl4_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl4_scenario1) <- c("18-34", "35+") chi_result_atbrgl4_scenario1 <- chisq.test(table_atbrgl4_scenario1) odds_ratio_atbrgl4_scenario1 <- oddsratio(table_atbrgl4_scenario1, conf.level = 0.95)$measure print(kable(table_atbrgl4_scenario1, caption = "Contingency Table: Age vs. Hand Washing Importance (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl4_scenario1) print(odds_ratio_atbrgl4_scenario1) ## Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl4_scenario2 <- df[df$ATBRGL4 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl4_scenario2$Age_Group <- ifelse(df_filtered_atbrgl4_scenario2$AGE %in% c(1, 2), "18-34", "35+") table_atbrgl4_scenario2 <- table(df_filtered_atbrgl4_scenario2$ATBRGL4, df_filtered_atbrgl4_scenario2$Age_Group) rownames(table_atbrgl4_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl4_scenario2) <- c("18-34", "35+") chi_result_atbrgl4_scenario2 <- chisq.test(table_atbrgl4_scenario2) odds_ratio_atbrgl4_scenario2 <- oddsratio(table_atbrgl4_scenario2, conf.level = 0.95)$measure print(kable(table_atbrgl4_scenario2, caption = "Contingency Table: Age vs. Hand Washing Importance (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl4_scenario2) print(odds_ratio_atbrgl4_scenario2) ## Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl4_scenario3 <- df[df$ATBRGL4 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl4_scenario3$Age_Group <- ifelse(df_filtered_atbrgl4_scenario3$AGE %in% c(1, 2), "18-34", "35+") df_filtered_atbrgl4_scenario3$Disagree_Neither <- df_filtered_atbrgl4_scenario3$ATBRGL4 %in% c(1, 2) table_atbrgl4_scenario3 <- table(df_filtered_atbrgl4_scenario3$Disagree_Neither, df_filtered_atbrgl4_scenario3$Age_Group) rownames(table_atbrgl4_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl4_scenario3) <- c("18-34", "35+") chi_result_atbrgl4_scenario3 <- chisq.test(table_atbrgl4_scenario3) odds_ratio_atbrgl4_scenario3 <- oddsratio(table_atbrgl4_scenario3, conf.level = 0.95)$measure print(kable(table_atbrgl4_scenario3, caption = "Contingency Table: Age vs. Hand Washing Importance (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl4_scenario3) print(odds_ratio_atbrgl4_scenario3) --------------------------------------------------------------------------------------------------------------------- #ATBRGL5 Doctors should only prescribe antibiotics when they are needed Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_atbrgl5_scenario1 <- df[df$ATBRGL5 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl5_scenario1$Age_Group <- ifelse(df_filtered_atbrgl5_scenario1$AGE %in% c(1, 2), "18-34", "35+") table_atbrgl5_scenario1 <- table(df_filtered_atbrgl5_scenario1$ATBRGL5, df_filtered_atbrgl5_scenario1$Age_Group) rownames(table_atbrgl5_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl5_scenario1) <- c("18-34", "35+") chi_result_atbrgl5_scenario1 <- chisq.test(table_atbrgl5_scenario1) odds_ratio_atbrgl5_scenario1 <- oddsratio(table_atbrgl5_scenario1, conf.level = 0.95)$measure print(kable(table_atbrgl5_scenario1, caption = "Contingency Table: Age vs. Antibiotic Prescription Necessity (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl5_scenario1) print(odds_ratio_atbrgl5_scenario1) ## Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl5_scenario2 <- df[df$ATBRGL5 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl5_scenario2$Age_Group <- ifelse(df_filtered_atbrgl5_scenario2$AGE %in% c(1, 2), "18-34", "35+") table_atbrgl5_scenario2 <- table(df_filtered_atbrgl5_scenario2$ATBRGL5, df_filtered_atbrgl5_scenario2$Age_Group) rownames(table_atbrgl5_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl5_scenario2) <- c("18-34", "35+") chi_result_atbrgl5_scenario2 <- chisq.test(table_atbrgl5_scenario2) odds_ratio_atbrgl5_scenario2 <- oddsratio(table_atbrgl5_scenario2, conf.level = 0.95)$measure print(kable(table_atbrgl5_scenario2, caption = "Contingency Table: Age vs. Antibiotic Prescription Necessity (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl5_scenario2) print(odds_ratio_atbrgl5_scenario2) ## Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl5_scenario3 <- df[df$ATBRGL5 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl5_scenario3$Age_Group <- ifelse(df_filtered_atbrgl5_scenario3$AGE %in% c(1, 2), "18-34", "35+") df_filtered_atbrgl5_scenario3$Disagree_Neither <- df_filtered_atbrgl5_scenario3$ATBRGL5 %in% c(1, 2) table_atbrgl5_scenario3 <- table(df_filtered_atbrgl5_scenario3$Disagree_Neither, df_filtered_atbrgl5_scenario3$Age_Group) rownames(table_atbrgl5_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl5_scenario3) <- c("18-34", "35+") chi_result_atbrgl5_scenario3 <- chisq.test(table_atbrgl5_scenario3) odds_ratio_atbrgl5_scenario3 <- oddsratio(table_atbrgl5_scenario3, conf.level = 0.95)$measure print(kable(table_atbrgl5_scenario3, caption = "Contingency Table: Age vs. Antibiotic Prescription Necessity (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl5_scenario3) print(odds_ratio_atbrgl5_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##ATBRGL6= People should only use antibiotics when prescribed by a doctor or nurse Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_atbrgl6_scenario1 <- df[df$ATBRGL6 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl6_scenario1$Age_Group <- ifelse(df_filtered_atbrgl6_scenario1$AGE %in% c(1, 2), "18-34", "35+") table_atbrgl6_scenario1 <- table(df_filtered_atbrgl6_scenario1$ATBRGL6, df_filtered_atbrgl6_scenario1$Age_Group) rownames(table_atbrgl6_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl6_scenario1) <- c("18-34", "35+") chi_result_atbrgl6_scenario1 <- chisq.test(table_atbrgl6_scenario1) odds_ratio_atbrgl6_scenario1 <- oddsratio(table_atbrgl6_scenario1, conf.level = 0.95)$measure print(kable(table_atbrgl6_scenario1, caption = "Contingency Table: Age vs. Antibiotic only when prescribed (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl6_scenario1) print(odds_ratio_atbrgl6_scenario1) ## Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl6_scenario2 <- df[df$ATBRGL6 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl6_scenario2$Age_Group <- ifelse(df_filtered_atbrgl6_scenario2$AGE %in% c(1, 2), "18-34", "35+") table_atbrgl6_scenario2 <- table(df_filtered_atbrgl6_scenario2$ATBRGL6, df_filtered_atbrgl6_scenario2$Age_Group) rownames(table_atbrgl6_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl6_scenario2) <- c("18-34", "35+") chi_result_atbrgl6_scenario2 <- chisq.test(table_atbrgl6_scenario2) odds_ratio_atbrgl6_scenario2 <- oddsratio(table_atbrgl6_scenario2, conf.level = 0.95)$measure print(kable(table_atbrgl6_scenario2, caption = "Contingency Table: Age vs. Antibiotic only when prescribed (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl6_scenario2) print(odds_ratio_atbrgl6_scenario2) ## Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl6_scenario3 <- df[df$ATBRGL6 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl6_scenario3$Age_Group <- ifelse(df_filtered_atbrgl6_scenario3$AGE %in% c(1, 2), "18-34", "35+") df_filtered_atbrgl6_scenario3$Disagree_Neither <- df_filtered_atbrgl6_scenario3$ATBRGL6 %in% c(1, 2) table_atbrgl6_scenario3 <- table(df_filtered_atbrgl6_scenario3$Disagree_Neither, df_filtered_atbrgl6_scenario3$Age_Group) rownames(table_atbrgl6_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl6_scenario3) <- c("18-34", "35+") chi_result_atbrgl6_scenario3 <- chisq.test(table_atbrgl6_scenario3) odds_ratio_atbrgl6_scenario3 <- oddsratio(table_atbrgl6_scenario3, conf.level = 0.95)$measure print(kable(table_atbrgl6_scenario3, caption = "Contingency Table: Age vs. Antibiotic only when prescribed (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl6_scenario3) print(odds_ratio_atbrgl6_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM1= Antibiotic resistance is one of the biggest problems the world faces Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_resdim1_scenario1 <- df[df$RESDIM1 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim1_scenario1$Age_Group <- ifelse(df_filtered_resdim1_scenario1$AGE %in% c(1, 2), "18-34", "35+") table_resdim1_scenario1 <- table(df_filtered_resdim1_scenario1$RESDIM1, df_filtered_resdim1_scenario1$Age_Group) rownames(table_resdim1_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_resdim1_scenario1) <- c("18-34", "35+") chi_result_resdim1_scenario1 <- chisq.test(table_resdim1_scenario1) odds_ratio_resdim1_scenario1 <- oddsratio(table_resdim1_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim1_scenario1, caption = "Contingency Table: Age vs. Perception of Antibiotic Resistance as a Global Problem (Strongly Agree vs. Strongly Disagree)")) print(chi_result_resdim1_scenario1) print(odds_ratio_resdim1_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim1_scenario2 <- df[df$RESDIM1 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim1_scenario2$Age_Group <- ifelse(df_filtered_resdim1_scenario2$AGE %in% c(1, 2), "18-34", "35+") table_resdim1_scenario2 <- table(df_filtered_resdim1_scenario2$RESDIM1, df_filtered_resdim1_scenario2$Age_Group) rownames(table_resdim1_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_resdim1_scenario2) <- c("18-34", "35+") chi_result_resdim1_scenario2 <- chisq.test(table_resdim1_scenario2) odds_ratio_resdim1_scenario2 <- oddsratio(table_resdim1_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim1_scenario2, caption = "Contingency Table: Age vs. Perception of Antibiotic Resistance as a Global Problem (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim1_scenario2) print(odds_ratio_resdim1_scenario2) # Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim1_scenario3 <- df[df$RESDIM1 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim1_scenario3$Age_Group <- ifelse(df_filtered_resdim1_scenario3$AGE %in% c(1, 2), "18-34", "35+") df_filtered_resdim1_scenario3$Disagree_Neither <- df_filtered_resdim1_scenario3$RESDIM1 %in% c(1, 2) table_resdim1_scenario3 <- table(df_filtered_resdim1_scenario3$Disagree_Neither, df_filtered_resdim1_scenario3$Age_Group) rownames(table_resdim1_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_resdim1_scenario3) <- c("18-34", "35+") chi_result_resdim1_scenario3 <- chisq.test(table_resdim1_scenario3) odds_ratio_resdim1_scenario3 <- oddsratio(table_resdim1_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim1_scenario3, caption = "Contingency Table: Age vs. Perception of Antibiotic Resistance as a Global Problem (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_resdim1_scenario3) print(odds_ratio_resdim1_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM2= Medical experts will solve the problem of antibiotic resistance before it becomes too serious Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Load the Database_simplified dataframe df <- read_excel("C:/Database_simplified.xlsx") # Scenario 1: Strongly Agree vs. Strongly Disagree df_filtered_resdim2_scenario1 <- df[df$RESDIM2 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim2_scenario1$Age_Group <- ifelse(df_filtered_resdim2_scenario1$AGE %in% c(1, 2), "18-34", "35+") table_resdim2_scenario1 <- table(df_filtered_resdim2_scenario1$RESDIM2, df_filtered_resdim2_scenario1$Age_Group) rownames(table_resdim2_scenario1) <- c("Strongly Agree", "Strongly Disagree") colnames(table_resdim2_scenario1) <- c("18-34", "35+") chi_result_resdim2_scenario1 <- chisq.test(table_resdim2_scenario1) odds_ratio_resdim2_scenario1 <- oddsratio(table_resdim2_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim2_scenario1, caption = "Contingency Table: Age vs. Belief in Solving Antibiotic Resistance (Strongly Disagree vs. Strongly Agree)")) print(chi_result_resdim2_scenario1) print(odds_ratio_resdim2_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim2_scenario2 <- df[df$RESDIM2 %in% c(1, 2) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim2_scenario2$Age_Group <- ifelse(df_filtered_resdim2_scenario2$AGE %in% c(1, 2), "18-34", "35+") table_resdim2_scenario2 <- table(df_filtered_resdim2_scenario2$RESDIM2, df_filtered_resdim2_scenario2$Age_Group) rownames(table_resdim2_scenario2) <- c("Strongly Disagree", "Neither Agree Nor Disagree") colnames(table_resdim2_scenario2) <- c("18-34", "35+") chi_result_resdim2_scenario2 <- chisq.test(table_resdim2_scenario2) odds_ratio_resdim2_scenario2 <- oddsratio(table_resdim2_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim2_scenario2, caption = "Contingency Table: Age vs. Belief in Solving Antibiotic Resistance (Strongly Disagree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim2_scenario2) print(odds_ratio_resdim2_scenario2) # Scenario 3: Strongly Agree + Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim2_scenario3 <- df[df$RESDIM2 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim2_scenario3$Age_Group <- ifelse(df_filtered_resdim2_scenario3$AGE %in% c(1, 2), "18-34", "35+") df_filtered_resdim2_scenario3$Agree_Neither <- df_filtered_resdim2_scenario3$RESDIM2 %in% c(2, 3) table_resdim2_scenario3 <- table(df_filtered_resdim2_scenario3$Agree_Neither, df_filtered_resdim2_scenario3$Age_Group) rownames(table_resdim2_scenario3) <- c("Strongly Disagree", "Strongly Agree + Neither") colnames(table_resdim2_scenario3) <- c("18-34", "35+") chi_result_resdim2_scenario3 <- chisq.test(table_resdim2_scenario3) odds_ratio_resdim2_scenario3 <- oddsratio(table_resdim2_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim2_scenario3, caption = "Contingency Table: Age vs. Belief in Solving Antibiotic Resistance (Strongly Disagree vs. Strongly Agree + Neither Agree Nor Disagree)")) print(chi_result_resdim2_scenario3) print(odds_ratio_resdim2_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM3= Everyone needs to use antibiotics responsibly Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_resdim3_scenario1 <- df[df$RESDIM3 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim3_scenario1$Age_Group <- ifelse(df_filtered_resdim3_scenario1$AGE %in% c(1, 2), "18-34", "35+") table_resdim3_scenario1 <- table(df_filtered_resdim3_scenario1$RESDIM3, df_filtered_resdim3_scenario1$Age_Group) rownames(table_resdim3_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_resdim3_scenario1) <- c("18-34", "35+") chi_result_resdim3_scenario1 <- chisq.test(table_resdim3_scenario1) odds_ratio_resdim3_scenario1 <- oddsratio(table_resdim3_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim3_scenario1, caption = "Contingency Table: Age vs. Everyone needs to use antibiotics responsibly (Strongly Agree vs. Strongly Disagree)")) print(chi_result_resdim3_scenario1) print(odds_ratio_resdim3_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim3_scenario2 <- df[df$RESDIM3 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim3_scenario2$Age_Group <- ifelse(df_filtered_resdim3_scenario2$AGE %in% c(1, 2), "18-34", "35+") table_resdim3_scenario2 <- table(df_filtered_resdim3_scenario2$RESDIM3, df_filtered_resdim3_scenario2$Age_Group) rownames(table_resdim3_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_resdim3_scenario2) <- c("18-34", "35+") chi_result_resdim3_scenario2 <- chisq.test(table_resdim3_scenario2) odds_ratio_resdim3_scenario2 <- oddsratio(table_resdim3_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim3_scenario2, caption = "Contingency Table: Age vs. Everyone needs to use antibiotics responsibly (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim3_scenario2) print(odds_ratio_resdim3_scenario2) # Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim3_scenario3 <- df[df$RESDIM3 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim3_scenario3$Age_Group <- ifelse(df_filtered_resdim3_scenario3$AGE %in% c(1, 2), "18-34", "35+") df_filtered_resdim3_scenario3$Disagree_Neither <- df_filtered_resdim3_scenario3$RESDIM3 %in% c(1, 2) table_resdim3_scenario3 <- table(df_filtered_resdim3_scenario3$Disagree_Neither, df_filtered_resdim3_scenario3$Age_Group) rownames(table_resdim3_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_resdim3_scenario3) <- c("18-34", "35+") chi_result_resdim3_scenario3 <- chisq.test(table_resdim3_scenario3) odds_ratio_resdim3_scenario3 <- oddsratio(table_resdim3_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim3_scenario3, caption = "Contingency Table: Age vs. Everyone needs to use antibiotics responsibly (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_resdim3_scenario3) print(odds_ratio_resdim3_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM4= People like me can't do much to stop antibiotic resistance Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Agree vs. Strongly Disagree df_filtered_resdim4_scenario1 <- df[df$RESDIM4 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim4_scenario1$Age_Group <- ifelse(df_filtered_resdim4_scenario1$AGE %in% c(1, 2), "18-34", "35+") table_resdim4_scenario1 <- table(df_filtered_resdim4_scenario1$RESDIM4, df_filtered_resdim4_scenario1$Age_Group) rownames(table_resdim4_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_resdim4_scenario1) <- c("18-34", "35+") chi_result_resdim4_scenario1 <- chisq.test(table_resdim4_scenario1) odds_ratio_resdim4_scenario1 <- oddsratio(table_resdim4_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim4_scenario1, caption = "Contingency Table: Age vs. Belief in Individual Impact on Antibiotic Resistance (Strongly Disagree vs. Strongly Agree)")) print(chi_result_resdim4_scenario1) print(odds_ratio_resdim4_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim4_scenario2 <- df[df$RESDIM4 %in% c(1, 2) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim4_scenario2$Age_Group <- ifelse(df_filtered_resdim4_scenario2$AGE %in% c(1, 2), "18-34", "35+") table_resdim4_scenario2 <- table(df_filtered_resdim4_scenario2$RESDIM4, df_filtered_resdim4_scenario2$Age_Group) rownames(table_resdim4_scenario2) <- c("Strongly Disagree", "Neither Agree Nor Disagree") colnames(table_resdim4_scenario2) <- c("18-34", "35+") chi_result_resdim4_scenario2 <- chisq.test(table_resdim4_scenario2) odds_ratio_resdim4_scenario2 <- oddsratio(table_resdim4_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim4_scenario2, caption = "Contingency Table: Age vs. Belief in Individual Impact on Antibiotic Resistance (Strongly Disagree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim4_scenario2) print(odds_ratio_resdim4_scenario2) # Scenario 3: Strongly Agree + Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim4_scenario3 <- df[df$RESDIM4 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim4_scenario3$Age_Group <- ifelse(df_filtered_resdim4_scenario3$AGE %in% c(1, 2), "18-34", "35+") df_filtered_resdim4_scenario3$Agree_Neither <- df_filtered_resdim4_scenario3$RESDIM4 %in% c(2, 3) table_resdim4_scenario3 <- table(df_filtered_resdim4_scenario3$Agree_Neither, df_filtered_resdim4_scenario3$Age_Group) rownames(table_resdim4_scenario3) <- c("Strongly Disagree", "Strongly Agree + Neither") colnames(table_resdim4_scenario3) <- c("18-34", "35+") chi_result_resdim4_scenario3 <- chisq.test(table_resdim4_scenario3) odds_ratio_resdim4_scenario3 <- oddsratio(table_resdim4_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim4_scenario3, caption = "Contingency Table: Age vs. Belief in Individual Impact on Antibiotic Resistance (Strongly Disagree vs. Strongly Agree + Neither Agree Nor Disagree)")) print(chi_result_resdim4_scenario3) print(odds_ratio_resdim4_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM5= I am worried about the impact that antibiotic resistance will have on my health and that of my family Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_resdim5_scenario1 <- df[df$RESDIM5 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim5_scenario1$Age_Group <- ifelse(df_filtered_resdim5_scenario1$AGE %in% c(1, 2), "18-34", "35+") table_resdim5_scenario1 <- table(df_filtered_resdim5_scenario1$RESDIM5, df_filtered_resdim5_scenario1$Age_Group) rownames(table_resdim5_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_resdim5_scenario1) <- c("18-34", "35+") chi_result_resdim5_scenario1 <- chisq.test(table_resdim5_scenario1) odds_ratio_resdim5_scenario1 <- oddsratio(table_resdim5_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim5_scenario1, caption = "Contingency Table: Age vs. Impact of AMR on personal health and that of their family (Strongly Agree vs. Strongly Disagree)")) print(chi_result_resdim5_scenario1) print(odds_ratio_resdim5_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim5_scenario2 <- df[df$RESDIM5 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim5_scenario2$Age_Group <- ifelse(df_filtered_resdim5_scenario2$AGE %in% c(1, 2), "18-34", "35+") table_resdim5_scenario2 <- table(df_filtered_resdim5_scenario2$RESDIM5, df_filtered_resdim5_scenario2$Age_Group) rownames(table_resdim5_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_resdim5_scenario2) <- c("18-34", "35+") chi_result_resdim5_scenario2 <- chisq.test(table_resdim5_scenario2) odds_ratio_resdim5_scenario2 <- oddsratio(table_resdim5_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim5_scenario2, caption = "Contingency Table: Age vs. Impact of AMR on personal health and that of their family (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim5_scenario2) print(odds_ratio_resdim5_scenario2) # Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim5_scenario3 <- df[df$RESDIM5 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim5_scenario3$Age_Group <- ifelse(df_filtered_resdim5_scenario3$AGE %in% c(1, 2), "18-34", "35+") df_filtered_resdim5_scenario3$Disagree_Neither <- df_filtered_resdim5_scenario3$RESDIM5 %in% c(1, 2) table_resdim5_scenario3 <- table(df_filtered_resdim5_scenario3$Disagree_Neither, df_filtered_resdim5_scenario3$Age_Group) rownames(table_resdim5_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_resdim5_scenario3) <- c("18-34", "35+") chi_result_resdim5_scenario3 <- chisq.test(table_resdim5_scenario3) odds_ratio_resdim5_scenario3 <- oddsratio(table_resdim5_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim5_scenario3, caption = "Contingency Table: Age vs. Impact of AMR on personal health and that of their family (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_resdim5_scenario3) print(odds_ratio_resdim5_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM6= I am not at risk of getting an antibiotic-resistant infection, as long as I take my antibiotics correctly Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Agree vs. Strongly Disagree df_filtered_resdim6_scenario1 <- df[df$RESDIM6 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim6_scenario1$Age_Group <- ifelse(df_filtered_resdim6_scenario1$AGE %in% c(1, 2), "18-34", "35+") table_resdim6_scenario1 <- table(df_filtered_resdim6_scenario1$RESDIM6, df_filtered_resdim6_scenario1$Age_Group) rownames(table_resdim6_scenario1) <- c("Strongly Agree", "Strongly Disagree") colnames(table_resdim6_scenario1) <- c("18-34", "35+") chi_result_resdim6_scenario1 <- chisq.test(table_resdim6_scenario1) odds_ratio_resdim6_scenario1 <- oddsratio(table_resdim6_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim6_scenario1, caption = "Contingency Table: Age vs. Perception of Risk of Antibiotic-Resistant Infection (Strongly Disagree vs. Strongly Agree)")) print(chi_result_resdim6_scenario1) print(odds_ratio_resdim6_scenario1) print(table_resdim6_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim6_scenario2 <- df[df$RESDIM6 %in% c(1, 2) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim6_scenario2$Age_Group <- ifelse(df_filtered_resdim6_scenario2$AGE %in% c(1, 2), "18-34", "35+") table_resdim6_scenario2 <- table(df_filtered_resdim6_scenario2$RESDIM6, df_filtered_resdim6_scenario2$Age_Group) rownames(table_resdim6_scenario2) <- c("Strongly Disagree", "Neither Agree Nor Disagree") colnames(table_resdim6_scenario2) <- c("18-34", "35+") chi_result_resdim6_scenario2 <- chisq.test(table_resdim6_scenario2) odds_ratio_resdim6_scenario2 <- oddsratio(table_resdim6_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim6_scenario2, caption = "Contingency Table: Age vs. Perception of Risk of Antibiotic-Resistant Infection (Strongly Disagree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim6_scenario2) print(odds_ratio_resdim6_scenario2) # Scenario 3: Strongly Agree + Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim6_scenario3 <- df[df$RESDIM6 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim6_scenario3$Age_Group <- ifelse(df_filtered_resdim6_scenario3$AGE %in% c(1, 2), "18-34", "35+") df_filtered_resdim6_scenario3$Agree_Neither <- df_filtered_resdim6_scenario3$RESDIM6 %in% c(2, 3) table_resdim6_scenario3 <- table(df_filtered_resdim6_scenario3$Agree_Neither, df_filtered_resdim6_scenario3$Age_Group) rownames(table_resdim6_scenario3) <- c("Strongly Disagree", "Strongly Agree + Neither") colnames(table_resdim6_scenario3) <- c("18-34", "35+") chi_result_resdim6_scenario3 <- chisq.test(table_resdim6_scenario3) odds_ratio_resdim6_scenario3 <- oddsratio(table_resdim6_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim6_scenario3, caption = "Contingency Table: Age vs. Perception of Risk of Antibiotic-Resistant Infection (Strongly Disagree vs. Strongly Agree + Neither Agree Nor Disagree)")) print(chi_result_resdim6_scenario3) print(odds_ratio_resdim6_scenario3) ############################################### 35-54 vs. Other ############################################### ###CUSIN1 (I wash my hands before cooking (No= 9.4%)) # Load the Database_simplified dataframe Database_simplified <- read_excel("C:/Database_simplified.xlsx") # Filter the DataFrame df_filtered <- Database_simplified[Database_simplified$CUSIN1 %in% c(0, 1) & Database_simplified$AGE %in% c(1, 2, 3, 4, 5, 6), ] # Create a new variable for age categorization df_filtered$Age_Group <- ifelse(df_filtered$AGE %in% c(3, 4), "35-54", "Other") # Create the Contingency Table table <- table(df_filtered$CUSIN1, df_filtered$Age_Group) # Add descriptive labels rownames(table) <- c("CUSIN1 (Yes)", "CUSIN1 (No)") colnames(table) <- c("35-54", "Other") # Print the contingency table using knitr kable(table, caption = "Contingency Table: Age Group vs. Hand Washing") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) --------------------------------------------------------------------------------------------------- ##CUSIN2 (After handling raw food (meat and vegetables), I wash my hands with soap (No= 15.1%) df_filtered <- Database_simplified[Database_simplified$CUSIN2 %in% c(0, 1) & Database_simplified$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered$Age_Group <- ifelse(df_filtered$AGE %in% c(3, 4), "35-54", "Other") table <- table(df_filtered$CUSIN2, df_filtered$Age_Group) rownames(table) <- c("CUSIN2 (Yes)", "CUSIN2 (No)") colnames(table) <- c("35-54", "Other") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: AGE vs. After handling raw food (meat and vegetables), I wash my hands with soap") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------ ##CUSIN3 (I use the same kitchen utensils for handling raw and ready-to-eat foods (Yes=25.8%)) df_filtered <- Database_simplified[Database_simplified$CUSIN3 %in% c(0, 1) & Database_simplified$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered$Age_Group <- ifelse(df_filtered$AGE %in% c(3, 4), "35-54", "Other") table <- table(df_filtered$CUSIN3, df_filtered$Age_Group) rownames(table) <- c("CUSIN3 (Yes)", "CUSIN3 (No)") colnames(table) <- c("18-34", "35+") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: AGE vs. I use the same kitchen utensils for handling raw and ready-to-eat foods") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------- ##CUSIN4 (I wash kitchen utensils that have been used for raw food before using them to prepare other foods (No=16.8%)) df_filtered <- Database_simplified[Database_simplified$CUSIN4 %in% c(0, 1) & Database_simplified$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered$Age_Group <- ifelse(df_filtered$AGE %in% c(3, 4), "35-54", "Other") table <- table(df_filtered$CUSIN4, df_filtered$Age_Group) rownames(table) <- c("CUSIN4 (Yes)", "CUSIN4 (No)") colnames(table) <- c("35-54", "Other") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Age vs. I wash kitchen utensils that have been used for raw food before using them to prepare other foods") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------- ##CUSIN5 (I wash fruits and vegetables before eating them (No=20.7%)) df_filtered <- Database_simplified[Database_simplified$CUSIN5 %in% c(0, 1) & Database_simplified$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered$Age_Group <- ifelse(df_filtered$AGE %in% c(3, 4), "35-54", "Other") table <- table(df_filtered$CUSIN5, df_filtered$Age_Group) rownames(table) <- c("CUSIN5 (Yes)", "CUSIN5 (No)") colnames(table) <- c("35-54", "Other") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Age vs. I wash fruits and vegetables before eating them") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------- ##CUSIN6 (I wash my hands before eating (No=21.5)) df_filtered <- Database_simplified[Database_simplified$CUSIN6 %in% c(0, 1) & Database_simplified$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered$Age_Group <- ifelse(df_filtered$AGE %in% c(3, 4), "35-54", "Other") table <- table(df_filtered$CUSIN6, df_filtered$Age_Group) rownames(table) <- c("CUSIN6 (Yes)", "CUSIN6 (No)") colnames(table) <- c("35-54", "Other") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Age vs. I wash my hands before eating") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) --------------------------------------------------------------------------------------------------------------------- ##PRESCATB1 When you get a prescription for antibiotics, do you follow the recommended ##length of treatment and daily dosage? (No=4.2%) (Sometimes=9.6%) (No+Sometimes=13.8%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) df <- Database_simplified ############### 1st scenario= No df_filtered_prescatb1 <- df[df$PRESCATB1 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_prescatb1$Age_Group <- ifelse(df_filtered_prescatb1$AGE %in% c(3, 4), "35-54", "Other") table_prescatb1 <- table(df_filtered_prescatb1$PRESCATB1, df_filtered_prescatb1$Age_Group) # Add descriptive labels to the rows and columns rownames(table_prescatb1) <- c("Yes", "No") # Perform the Chi-Squared test chi_result_prescatb1 <- chisq.test(table_prescatb1) # Calculate the odds ratio and confidence interval odds_ratio_prescatb1 <- oddsratio(table_prescatb1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_prescatb1, caption = "Contingency Table: Age vs. Following Prescription for Antibiotics")) # Print the results of the Chi-Squared test print(chi_result_prescatb1) # Print the odds ratio and confidence interval print(odds_ratio_prescatb1) ################## 2nd scenario= Sometimes df_filtered_prescatb1_sometimes <- df[df$PRESCATB1 %in% c(0, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_prescatb1_sometimes$Age_Group <- ifelse(df_filtered_prescatb1_sometimes$AGE %in% c(3, 4), "35-54", "Other") table_prescatb1_sometimes <- table(df_filtered_prescatb1_sometimes$PRESCATB1, df_filtered_prescatb1_sometimes$Age_Group) # Add descriptive labels to the rows and columns rownames(table_prescatb1_sometimes) <- c("Yes", "No") # Perform the Chi-Squared test chi_result_prescatb1_sometimes <- chisq.test(table_prescatb1_sometimes) # Calculate the odds ratio and confidence interval odds_ratio_prescatb1_sometimes <- oddsratio(table_prescatb1_sometimes, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_prescatb1_sometimes, caption = "Contingency Table: Age vs. Following Prescription for Antibiotics Sometimes")) # Print the results of the Chi-Squared test print(chi_result_prescatb1_sometimes) # Print the odds ratio and confidence interval print(odds_ratio_prescatb1_sometimes) ################## 3rd scenario= No+Sometimes # Filter for 'Yes', 'No', and 'Sometimes' responses for PRESCATB1 and genders 'Female' and 'Male' df_filtered_prescatb1_combined <- df[df$PRESCATB1 %in% c(0, 1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_prescatb1_combined$Age_Group <- ifelse(df_filtered_prescatb1_combined$AGE %in% c(3, 4), "35-54", "Other") df_filtered_prescatb1_combined$No_Sometimes <- df_filtered_prescatb1_combined$PRESCATB1 %in% c(1, 3) table_prescatb1_combined <- table(df_filtered_prescatb1_combined$No_Sometimes, df_filtered_prescatb1_combined$Age_Group) # Adjust the table to have 'Yes' and 'No+Sometimes' as row names rownames(table_prescatb1_combined) <- c("Yes", "No_Sometimes") # Perform the Chi-Squared test chi_result_prescatb1_combined <- chisq.test(table_prescatb1_combined) # Calculate the odds ratio and confidence interval odds_ratio_prescatb1_combined <- oddsratio(table_prescatb1_combined, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_prescatb1_combined, caption = "Contingency Table: Age vs. Following Prescription for Antibiotics (Yes vs. No+Sometimes)")) # Print the results of the Chi-Squared test print(chi_result_prescatb1_combined) # Print the odds ratio and confidence interval print(odds_ratio_prescatb1_combined) --------------------------------------------------------------------------------------------------------------------- ##ARRETATB Do you stop taking antibiotics when symptoms start to disappear? ##(Always=7.3%) (Sometimes=20.4%) (Always+Sometimes=27.7%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) df <- Database_simplified ############### 1st scenario= Always df_filtered_arretatb <- df[df$ARRETATB %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_arretatb$Age_Group <- ifelse(df_filtered_arretatb$AGE %in% c(3, 4), "35-54", "Other") table_arretatb <- table(df_filtered_arretatb$ARRETATB, df_filtered_arretatb$Age_Group) # Add descriptive labels to the rows and columns rownames(table_arretatb) <- c("Always", "Never") # Perform the Chi-Squared test chi_result_arretatb <- chisq.test(table_arretatb) # Calculate the odds ratio and confidence interval odds_ratio_arretatb <- oddsratio(table_arretatb, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_arretatb, caption = "Contingency Table: Age vs. Stopping Antibiotics Always vs. Never")) # Print the results of the Chi-Squared test print(chi_result_arretatb) # Print the odds ratio and confidence interval print(odds_ratio_arretatb) ################# 2nd Cenario: Sometimes df_filtered_arretatb_sometimes <- df[df$ARRETATB %in% c(1, 2) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_arretatb_sometimes$Age_Group <- ifelse(df_filtered_arretatb_sometimes$AGE %in% c(3, 4), "35-54", "Other") table_arretatb_sometimes <- table(df_filtered_arretatb_sometimes$ARRETATB == 2, df_filtered_arretatb_sometimes$Age_Group) # Add descriptive labels to the rows and columns rownames(table_arretatb_sometimes) <- c("Never", "Sometimes") # Perform the Chi-Squared test chi_result_arretatb_sometimes <- chisq.test(table_arretatb_sometimes) # Calculate the odds ratio and confidence interval odds_ratio_arretatb_sometimes <- oddsratio(table_arretatb_sometimes, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_arretatb_sometimes, caption = "Contingency Table: Age vs. Stopping Antibiotics Sometimes vs. Never")) # Print the results of the Chi-Squared test print(chi_result_arretatb_sometimes) # Print the odds ratio and confidence interval print(odds_ratio_arretatb_sometimes) ############### #3rd scenario= Sometimes+Always df_filtered_arretatb_combined <- df[df$ARRETATB %in% c(0, 1, 2) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_arretatb_combined$Age_Group <- ifelse(df_filtered_arretatb_combined$AGE %in% c(3, 4), "35-54", "Other") df_filtered_arretatb_combined$Sometimes_Always <- df_filtered_arretatb_combined$ARRETATB %in% c(0, 2) table_arretatb_combined <- table(df_filtered_arretatb_combined$Sometimes_Always, df_filtered_arretatb_combined$Age_Group) # Add descriptive labels to the rows and columns rownames(table_arretatb_combined) <- c("Never", "Sometimes_Always") # Perform the Chi-Squared test chi_result_arretatb_combined <- chisq.test(table_arretatb_combined) # Calculate the odds ratio and confidence interval odds_ratio_arretatb_combined <- oddsratio(table_arretatb_combined, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_arretatb_combined, caption = "Contingency Table: Age vs. Stopping Antibiotics (Sometimes+Always vs. Never)")) # Print the results of the Chi-Squared test print(chi_result_arretatb_combined) # Print the odds ratio and confidence interval print(odds_ratio_arretatb_combined) --------------------------------------------------------------------------------------------------------------------- ##ATBORAL1 Have you ever taken an oral antibiotic treatment (by mouth) without a medical prescription? (Yes=12.3%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) df <- Database_simplified df_filtered_atboral <- df[df$ATBORAL1 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atboral$Age_Group <- ifelse(df_filtered_atboral$AGE %in% c(3, 4), "35-54", "Other") table_atboral <- table(df_filtered_atboral$ATBORAL1, df_filtered_atboral$Age_Group) # Add descriptive labels to the rows and columns rownames(table_atboral) <- c("Yes", "No") # Perform the Chi-Squared test chi_result_atboral <- chisq.test(table_atboral) # Calculate the odds ratio and confidence interval odds_ratio_atboral <- oddsratio(table_atboral, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atboral, caption = "Contingency Table: Age vs. Taking Oral Antibiotics Without Prescription (Yes vs. No)")) # Print the results of the Chi-Squared test print(chi_result_atboral) # Print the odds ratio and confidence interval print(odds_ratio_atboral) -------------------------------------------------------------------------------------------------------- ### ATBANI1 I can exchange resistant bacteria with my pet (False=23.2%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) df <- Database_simplified df_filtered_atbani1 <- df[df$ATBANI1 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbani1$Age_Group <- ifelse(df_filtered_atbani1$AGE %in% c(3, 4), "35-54", "Other") table_atbani1 <- table(df_filtered_atbani1$ATBANI1, df_filtered_atbani1$Age_Group) rownames(table_atbani1) <- c("True", "False") colnames(table_atbani1) <- c("35-54", "Other") # Perform the Chi-Squared test chi_result_atbani1 <- chisq.test(table_atbani1) # Calculate the odds ratio and confidence interval odds_ratio_atbani1 <- oddsratio(table_atbani1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani1, caption = "Contingency Table: Age vs. Exchanging Resistant Bacteria with Pets (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani1) # Print the odds ratio and confidence interval print(odds_ratio_atbani1) --------------------------------------------------------------------------------------------------------------------- ### ATBANI2=The use of antibiotics in livestock and crops can increase the #presence of resistant bacteria in the environment (False=14.7%) df_filtered_atbani2 <- df[df$ATBANI2 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbani2$Age_Group <- ifelse(df_filtered_atbani2$AGE %in% c(3, 4), "35-54", "Other") table_atbani2 <- table(df_filtered_atbani2$ATBANI2, df_filtered_atbani2$Age_Group) rownames(table_atbani2) <- c("True", "False") colnames(table_atbani2) <- c("35-54", "Other") # Perform the Chi-Squared test chi_result_atbani2 <- chisq.test(table_atbani2) # Calculate the odds ratio and confidence interval odds_ratio_atbani2 <- oddsratio(table_atbani2, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani2, caption = "Contingency Table: Age vs. Antibiotics in Livestock and Crops Affecting Environment (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani2) # Print the odds ratio and confidence interval print(odds_ratio_atbani2) -------------------------------------------------------------------------------------------------------------------- ##### ATBANI3 The use of antibiotics in livestock and crops can affect me directly ##(I can get resistant bacteria in my body) (False=26.3%) df_filtered_atbani3 <- df[df$ATBANI3 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbani3$Age_Group <- ifelse(df_filtered_atbani3$AGE %in% c(3, 4), "35-54", "Other") table_atbani3 <- table(df_filtered_atbani3$ATBANI3, df_filtered_atbani3$Age_Group) rownames(table_atbani3) <- c("True", "False") colnames(table_atbani3) <- c("35-54", "Other") # Perform the Chi-Squared test chi_result_atbani3 <- chisq.test(table_atbani3) # Calculate the odds ratio and confidence interval odds_ratio_atbani3 <- oddsratio(table_atbani3, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani3, caption = "Contingency Table: Age vs. Antibiotics in Livestock and Crops Affecting Humans Directly (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani3) # Print the odds ratio and confidence interval print(odds_ratio_atbani3) ------------------------------------------------------------------------------------------------------------------- ##### ATBANI4 Resistant bacteria are only found in hospitals (True=10.8%) df_filtered_atbani4 <- df[df$ATBANI4 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbani4$Age_Group <- ifelse(df_filtered_atbani4$AGE %in% c(3, 4), "35-54", "Other") table_atbani4 <- table(df_filtered_atbani4$ATBANI4, df_filtered_atbani4$Age_Group) rownames(table_atbani4) <- c("True", "False") colnames(table_atbani4) <- c("35-54", "Other") # Perform the Chi-Squared test chi_result_atbani4 <- chisq.test(table_atbani4) # Calculate the odds ratio and confidence interval odds_ratio_atbani4 <- oddsratio(table_atbani4, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani4, caption = "Contingency Table: Age vs. Resistant Bacteria Found Only in Hospitals (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani4) # Print the odds ratio and confidence interval print(odds_ratio_atbani4) ---------------------------------------------------------------------------------------------------------------------- #####RESATB1 Antibiotic resistance occurs when your body becomes resistant to antibiotics and they ##no longer work as well (True=58.3%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) df <- Database_simplified df_filtered_resatb1 <- df[df$RESATB1 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resatb1$Age_Group <- ifelse(df_filtered_resatb1$AGE %in% c(3, 4), "35-54", "Other") table_resatb1 <- table(df_filtered_resatb1$RESATB1, df_filtered_resatb1$Age_Group) rownames(table_resatb1) <- c("True", "False") colnames(table_resatb1) <- c("35-54", "Other") # Perform the Chi-Squared test chi_result_resatb1 <- chisq.test(table_resatb1) # Calculate the odds ratio and confidence interval odds_ratio_resatb1 <- oddsratio(table_resatb1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb1, caption = "Contingency Table: Age vs. Understanding of Antibiotic Resistance (RESATB1: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb1) print(odds_ratio_resatb1) ------------------------------------------------------------------------------------------------------------------- #####RESATB2 Many infections are becoming increasingly resistant to antibiotic treatment (False=12.5%) # Load the database df <- Database_simplified df_filtered_resatb2 <- df[df$RESATB2 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resatb2$Age_Group <- ifelse(df_filtered_resatb2$AGE %in% c(3, 4), "35-54", "Other") table_resatb2 <- table(df_filtered_resatb2$RESATB2, df_filtered_resatb2$Age_Group) rownames(table_resatb2) <- c("True", "False") colnames(table_resatb2) <- c("35-54", "Other") # Perform the Chi-Squared test chi_result_resatb2 <- chisq.test(table_resatb2) # Calculate the odds ratio and confidence interval odds_ratio_resatb2 <- oddsratio(table_resatb2, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb2, caption = "Contingency Table: Age vs. Perception of Increasing Infection Resistance (RESATB2: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb2) print(odds_ratio_resatb2) --------------------------------------------------------------------------------------------------------------------- #####RESATB3 If bacteria are resistant to antibiotics, it can be very difficult or impossible to treat the infections they cause (False=16.7%) # Load the database df <- Database_simplified df_filtered_resatb3 <- df[df$RESATB3 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resatb3$Age_Group <- ifelse(df_filtered_resatb3$AGE %in% c(3, 4), "35-54", "Other") table_resatb3 <- table(df_filtered_resatb3$RESATB3, df_filtered_resatb3$Age_Group) rownames(table_resatb3) <- c("True", "False") colnames(table_resatb3) <- c("35-54", "Other") # Perform the Chi-Squared test chi_result_resatb3 <- chisq.test(table_resatb3) # Calculate the odds ratio and confidence interval odds_ratio_resatb3 <- oddsratio(table_resatb3, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb3, caption = "Contingency Table: Age vs. Perception of Difficulty Treating Infections (RESATB3: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb3) print(odds_ratio_resatb3) ---------------------------------------------------------------------------------------------------------------------- #####RESATB4 Antibiotic resistance is an issue that could affect me or my family (False=11.8%) # Load the database df <- Database_simplified df_filtered_resatb4 <- df[df$RESATB4 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resatb4$Age_Group <- ifelse(df_filtered_resatb4$AGE %in% c(3, 4), "35-54", "Other") table_resatb4 <- table(df_filtered_resatb4$RESATB4, df_filtered_resatb4$Age_Group) rownames(table_resatb4) <- c("True", "False") colnames(table_resatb4) <- c("35-54", "Other") # Perform the Chi-Squared test chi_result_resatb4 <- chisq.test(table_resatb4) # Calculate the odds ratio and confidence interval odds_ratio_resatb4 <- oddsratio(table_resatb4, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb4, caption = "Contingency Table: Age vs. Perception of Antibiotic Resistance Affecting One's Family (RESATB4: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb4) print(odds_ratio_resatb4) --------------------------------------------------------------------------------------------------------------------- #####RESATB5 Antibiotic resistance is an issue in other countries but not here (True=9.9%) # Load the database df <- Database_simplified df_filtered_resatb5 <- df[df$RESATB5 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resatb5$Age_Group <- ifelse(df_filtered_resatb5$AGE %in% c(3, 4), "35-54", "Other") table_resatb5 <- table(df_filtered_resatb5$RESATB5, df_filtered_resatb5$Age_Group) rownames(table_resatb5) <- c("True", "False") colnames(table_resatb5) <- c("35-54", "Other") # Perform the Chi-Squared test chi_result_resatb5 <- chisq.test(table_resatb5) # Calculate the odds ratio and confidence interval odds_ratio_resatb5 <- oddsratio(table_resatb5, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb5, caption = "Contingency Table: Age vs. Perception of Antibiotic Resistance as an Issue Only in Other Countries (RESATB5: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb5) print(odds_ratio_resatb5) --------------------------------------------------------------------------------------------------------------------- #####RESATB6 Antibiotic resistance is only a problem for people who take antibiotics regularly (True=17.5%) # Load the database df <- Database_simplified df_filtered_resatb6 <- df[df$RESATB6 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resatb6$Age_Group <- ifelse(df_filtered_resatb6$AGE %in% c(3, 4), "35-54", "Other") table_resatb6 <- table(df_filtered_resatb6$RESATB6, df_filtered_resatb6$Age_Group) rownames(table_resatb6) <- c("True", "False") colnames(table_resatb6) <- c("35-54", "Other") # Perform the Chi-Squared test chi_result_resatb6 <- chisq.test(table_resatb6) # Calculate the odds ratio and confidence interval odds_ratio_resatb6 <- oddsratio(table_resatb6, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb6, caption = "Contingency Table: Age vs. Perception of Antibiotic Resistance as a Problem Only for Regular Antibiotic Users (RESATB6: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb6) print(odds_ratio_resatb6) --------------------------------------------------------------------------------------------------------------------- #####RESATB7 Bacteria that are resistant to antibiotics can be spread from person to person (False=20.2%) # Load the database df <- Database_simplified df_filtered_resatb7 <- df[df$RESATB7 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resatb7$Age_Group <- ifelse(df_filtered_resatb7$AGE %in% c(3, 4), "35-54", "Other") table_resatb7 <- table(df_filtered_resatb7$RESATB7, df_filtered_resatb7$Age_Group) rownames(table_resatb7) <- c("True", "False") colnames(table_resatb7) <- c("35-54", "Other") # Perform the Chi-Squared test chi_result_resatb7 <- chisq.test(table_resatb7) # Calculate the odds ratio and confidence interval odds_ratio_resatb7 <- oddsratio(table_resatb7, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb7, caption = "Contingency Table: Age vs. Perception of Bacteria Transmission Person to Person (RESATB7: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb7) print(odds_ratio_resatb7) -------------------------------------------------------------------------------------------------------------------- #####RESATB8 Antibiotic-resistant infections could make medical procedures like surgery, organ transplants, ##and cancer treatment much more dangerous (False=12.0%) # Load the database df <- Database_simplified df_filtered_resatb8 <- df[df$RESATB8 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resatb8$Age_Group <- ifelse(df_filtered_resatb8$AGE %in% c(3, 4), "35-54", "Other") table_resatb8 <- table(df_filtered_resatb8$RESATB8, df_filtered_resatb8$Age_Group) rownames(table_resatb8) <- c("True", "False") colnames(table_resatb8) <- c("35-54", "Other") # Perform the Chi-Squared test chi_result_resatb8 <- chisq.test(table_resatb8) # Calculate the odds ratio and confidence interval odds_ratio_resatb8 <- oddsratio(table_resatb8, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb8, caption = "Contingency Table: Age vs. Perception of Antibiotic-Resistant Infections and Medical Procedures (RESATB8: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb8) print(odds_ratio_resatb8) -------------------------------------------------------------------------------------------------------------------- # ATBRGL1 Farmers should give fewer antibiotics to food-producing animals ##################### 1st scenario (Strongly desagree=8.68%) vs. Strongly Agree Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load dataframe df <- Database_simplified df_filtered_atbrgl1_scenario1 <- df[df$ATBRGL1 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl1_scenario1$Age_Group <- ifelse(df_filtered_atbrgl1_scenario1$AGE %in% c(3, 4), "35-54", "Other") table_atbrgl1_scenario1 <- table(df_filtered_atbrgl1_scenario1$ATBRGL1, df_filtered_atbrgl1_scenario1$Age_Group) rownames(table_atbrgl1_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl1_scenario1) <- c("35-54", "Other") # Perform the Chi-Squared test chi_result_atbrgl1_scenario1 <- chisq.test(table_atbrgl1_scenario1) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl1_scenario1 <- oddsratio(table_atbrgl1_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl1_scenario1, caption = "Contingency Table: Age vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Strongly Disagree)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_atbrgl1_scenario1) print(odds_ratio_atbrgl1_scenario1) ############################# 2nd scenario Farmers should give fewer antibiotics to ##food-producing animals (Neither agree nor desagree=22.6%) vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_atbrgl1_scenario2 <- df[df$ATBRGL1 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl1_scenario2$Age_Group <- ifelse(df_filtered_atbrgl1_scenario2$AGE %in% c(3, 4), "35-54", "Other") table_atbrgl1_scenario2 <- table(df_filtered_atbrgl1_scenario2$ATBRGL1, df_filtered_atbrgl1_scenario2$Age_Group) rownames(table_atbrgl1_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl1_scenario2) <- c("35-54", "Other") # Perform the Chi-Squared test chi_result_atbrgl1_scenario2 <- chisq.test(table_atbrgl1_scenario2) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl1_scenario2 <- oddsratio(table_atbrgl1_scenario2, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl1_scenario2, caption = "Contingency Table: Age vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Neither Agree Nor Disagree)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_atbrgl1_scenario2) print(odds_ratio_atbrgl1_scenario2) ############################# 3rd scenario (Strongly desagree + Neither agree nor desagree=31.28%) vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_atbrgl1_scenario3 <- df[df$ATBRGL1 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl1_scenario3$Age_Group <- ifelse(df_filtered_atbrgl1_scenario3$AGE %in% c(3, 4), "35-54", "Other") df_filtered_atbrgl1_scenario3$Disagree_Neither <- df_filtered_atbrgl1_scenario3$ATBRGL1 %in% c(1, 2) table_atbrgl1_scenario3 <- table(df_filtered_atbrgl1_scenario3$Disagree_Neither, df_filtered_atbrgl1_scenario3$Age_Group) rownames(table_atbrgl1_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl1_scenario3) <- c("35-54", "Other") # Perform the Chi-Squared test chi_result_atbrgl1_scenario3 <- chisq.test(table_atbrgl1_scenario3) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl1_scenario3 <- oddsratio(table_atbrgl1_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl1_scenario3, caption = "Contingency Table: Age vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Strongly Disagree + Neither)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_atbrgl1_scenario3) print(odds_ratio_atbrgl1_scenario3) -------------------------------------------------------------------------------------------------------------------- # ATBRGL2 People should not keep antibiotics and use them later for other illnesses ############################# 1st scenario Strongly desagree vs. Strongly Agree Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the database df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_atbrgl2_scenario1 <- df[df$ATBRGL2 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl2_scenario1$Age_Group <- ifelse(df_filtered_atbrgl2_scenario1$AGE %in% c(3, 4), "35-54", "Other") table_atbrgl2_scenario1 <- table(df_filtered_atbrgl2_scenario1$ATBRGL2, df_filtered_atbrgl2_scenario1$Age_Group) rownames(table_atbrgl2_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl2_scenario1) <- c("35-54", "Other") # Perform Chi-Squared test chi_result_atbrgl2_scenario1 <- chisq.test(table_atbrgl2_scenario1) # Calculate odds ratio and confidence interval odds_ratio_atbrgl2_scenario1 <- oddsratio(table_atbrgl2_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl2_scenario1, caption = "Contingency Table: Age vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl2_scenario1) print(odds_ratio_atbrgl2_scenario1) ############################# 2nd scenario Neither agree nor desagree vs. Strongly Agree # Filter for 'Strongly Agree' (3) and 'Neither Agree Nor Disagree' (2) responses for ATBRGL2 df_filtered_atbrgl2_scenario2 <- df[df$ATBRGL2 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl2_scenario2$Age_Group <- ifelse(df_filtered_atbrgl2_scenario2$AGE %in% c(3, 4), "35-54", "Other") table_atbrgl2_scenario2 <- table(df_filtered_atbrgl2_scenario2$ATBRGL2, df_filtered_atbrgl2_scenario2$Age_Group) rownames(table_atbrgl2_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl2_scenario2) <- c("35-54", "Other") # Perform Chi-Squared test chi_result_atbrgl2_scenario2 <- chisq.test(table_atbrgl2_scenario2) # Calculate odds ratio and confidence interval odds_ratio_atbrgl2_scenario2 <- oddsratio(table_atbrgl2_scenario2, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl2_scenario2, caption = "Contingency Table: Age vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl2_scenario2) print(odds_ratio_atbrgl2_scenario2) ############################# 3rd scenario Neither agree nor desagree + Stringly Disagree vs. Strongly Agree df_filtered_atbrgl2_scenario3 <- df[df$ATBRGL2 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl2_scenario3$Age_Group <- ifelse(df_filtered_atbrgl2_scenario3$AGE %in% c(3, 4), "35-54", "Other") df_filtered_atbrgl2_scenario3$Disagree_Neither <- df_filtered_atbrgl2_scenario3$ATBRGL2 %in% c(1, 2) table_atbrgl2_scenario3 <- table(df_filtered_atbrgl2_scenario3$Disagree_Neither, df_filtered_atbrgl2_scenario3$Age_Group) rownames(table_atbrgl2_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl2_scenario3) <- c("35-54", "Other") # Perform the Chi-Squared test chi_result_atbrgl2_scenario3 <- chisq.test(table_atbrgl2_scenario3) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl2_scenario3 <- oddsratio(table_atbrgl2_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl2_scenario3, caption = "Contingency Table: Age vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl2_scenario3) print(odds_ratio_atbrgl2_scenario3) -------------------------------------------------------------------------------------------------------------------- # ATBRGL3 Parents should make sure all of their children’s vaccinations are up-to-date Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) ####1st scenario # Load dataframe df <- Database_simplified df_filtered_atbrgl3_scenario1 <- df[df$ATBRGL3 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl3_scenario1$Age_Group <- ifelse(df_filtered_atbrgl3_scenario1$AGE %in% c(3, 4), "35-54", "Other") table_atbrgl3_scenario1 <- table(df_filtered_atbrgl3_scenario1$ATBRGL3, df_filtered_atbrgl3_scenario1$Age_Group) rownames(table_atbrgl3_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl3_scenario1) <- c("35-54", "Other") # Perform Chi-Squared test chi_result_atbrgl3_scenario1 <- chisq.test(table_atbrgl3_scenario1) # Calculate odds ratio and confidence interval odds_ratio_atbrgl3_scenario1 <- oddsratio(table_atbrgl3_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl3_scenario1, caption = "Contingency Table: Age vs. Opinion on Children's Vaccinations (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl3_scenario1) print(odds_ratio_atbrgl3_scenario1) ### 2nd Scenario df_filtered_atbrgl3_scenario2 <- df[df$ATBRGL3 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl3_scenario2$Age_Group <- ifelse(df_filtered_atbrgl3_scenario2$AGE %in% c(3, 4), "35-54", "Other") table_atbrgl3_scenario2 <- table(df_filtered_atbrgl3_scenario2$ATBRGL3, df_filtered_atbrgl3_scenario2$Age_Group) rownames(table_atbrgl3_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl3_scenario2) <- c("35-54", "Other") # Perform Chi-Squared test chi_result_atbrgl3_scenario2 <- chisq.test(table_atbrgl3_scenario2) # Calculate odds ratio and confidence interval odds_ratio_atbrgl3_scenario2 <- oddsratio(table_atbrgl3_scenario2, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl3_scenario2, caption = "Contingency Table: Age vs. Opinion on Children's Vaccinations (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl3_scenario2) print(odds_ratio_atbrgl3_scenario2) ## 3rd scenario df_filtered_atbrgl3_scenario3 <- df[df$ATBRGL3 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl3_scenario3$Age_Group <- ifelse(df_filtered_atbrgl3_scenario3$AGE %in% c(3, 4), "35-54", "Other") df_filtered_atbrgl3_scenario3$Disagree_Neither <- df_filtered_atbrgl3_scenario3$ATBRGL3 %in% c(1, 2) table_atbrgl3_scenario3 <- table(df_filtered_atbrgl3_scenario3$Disagree_Neither, df_filtered_atbrgl3_scenario3$Age_Group) rownames(table_atbrgl3_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl3_scenario3) <- c("35-54", "Other") # Perform the Chi-Squared test chi_result_atbrgl3_scenario3 <- chisq.test(table_atbrgl3_scenario3) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl3_scenario3 <- oddsratio(table_atbrgl3_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl3_scenario3, caption = "Contingency Table: Age vs. Opinion on Children's Vaccinations (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl3_scenario3) print(odds_ratio_atbrgl3_scenario3) --------------------------------------------------------------------------------------------------------------------- # ATBRGL4 People should wash their hands regularly Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_atbrgl4_scenario1 <- df[df$ATBRGL4 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl4_scenario1$Age_Group <- ifelse(df_filtered_atbrgl4_scenario1$AGE %in% c(3, 4), "35-54", "Other") table_atbrgl4_scenario1 <- table(df_filtered_atbrgl4_scenario1$ATBRGL4, df_filtered_atbrgl4_scenario1$Age_Group) rownames(table_atbrgl4_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl4_scenario1) <- c("35-54", "Other") chi_result_atbrgl4_scenario1 <- chisq.test(table_atbrgl4_scenario1) odds_ratio_atbrgl4_scenario1 <- oddsratio(table_atbrgl4_scenario1, conf.level = 0.95)$measure print(kable(table_atbrgl4_scenario1, caption = "Contingency Table: Age vs. Hand Washing Importance (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl4_scenario1) print(odds_ratio_atbrgl4_scenario1) ## Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl4_scenario2 <- df[df$ATBRGL4 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl4_scenario2$Age_Group <- ifelse(df_filtered_atbrgl4_scenario2$AGE %in% c(3, 4), "35-54", "Other") table_atbrgl4_scenario2 <- table(df_filtered_atbrgl4_scenario2$ATBRGL4, df_filtered_atbrgl4_scenario2$Age_Group) rownames(table_atbrgl4_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl4_scenario2) <- c("35-54", "Other") chi_result_atbrgl4_scenario2 <- chisq.test(table_atbrgl4_scenario2) odds_ratio_atbrgl4_scenario2 <- oddsratio(table_atbrgl4_scenario2, conf.level = 0.95)$measure print(kable(table_atbrgl4_scenario2, caption = "Contingency Table: Age vs. Hand Washing Importance (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl4_scenario2) print(odds_ratio_atbrgl4_scenario2) ## Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl4_scenario3 <- df[df$ATBRGL4 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl4_scenario3$Age_Group <- ifelse(df_filtered_atbrgl4_scenario3$AGE %in% c(3, 4), "35-54", "Other") df_filtered_atbrgl4_scenario3$Disagree_Neither <- df_filtered_atbrgl4_scenario3$ATBRGL4 %in% c(1, 2) table_atbrgl4_scenario3 <- table(df_filtered_atbrgl4_scenario3$Disagree_Neither, df_filtered_atbrgl4_scenario3$Age_Group) rownames(table_atbrgl4_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl4_scenario3) <- c("35-54", "Other") chi_result_atbrgl4_scenario3 <- chisq.test(table_atbrgl4_scenario3) odds_ratio_atbrgl4_scenario3 <- oddsratio(table_atbrgl4_scenario3, conf.level = 0.95)$measure print(kable(table_atbrgl4_scenario3, caption = "Contingency Table: Age vs. Hand Washing Importance (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl4_scenario3) print(odds_ratio_atbrgl4_scenario3) --------------------------------------------------------------------------------------------------------------------- #ATBRGL5 Doctors should only prescribe antibiotics when they are needed Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_atbrgl5_scenario1 <- df[df$ATBRGL5 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl5_scenario1$Age_Group <- ifelse(df_filtered_atbrgl5_scenario1$AGE %in% c(3, 4), "35-54", "Other") table_atbrgl5_scenario1 <- table(df_filtered_atbrgl5_scenario1$ATBRGL5, df_filtered_atbrgl5_scenario1$Age_Group) rownames(table_atbrgl5_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl5_scenario1) <- c("35-54", "Other") chi_result_atbrgl5_scenario1 <- chisq.test(table_atbrgl5_scenario1) odds_ratio_atbrgl5_scenario1 <- oddsratio(table_atbrgl5_scenario1, conf.level = 0.95)$measure print(kable(table_atbrgl5_scenario1, caption = "Contingency Table: Age vs. Antibiotic Prescription Necessity (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl5_scenario1) print(odds_ratio_atbrgl5_scenario1) ## Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl5_scenario2 <- df[df$ATBRGL5 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl5_scenario2$Age_Group <- ifelse(df_filtered_atbrgl5_scenario2$AGE %in% c(3, 4), "35-54", "Other") table_atbrgl5_scenario2 <- table(df_filtered_atbrgl5_scenario2$ATBRGL5, df_filtered_atbrgl5_scenario2$Age_Group) rownames(table_atbrgl5_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl5_scenario2) <- c("35-54", "Other") chi_result_atbrgl5_scenario2 <- chisq.test(table_atbrgl5_scenario2) odds_ratio_atbrgl5_scenario2 <- oddsratio(table_atbrgl5_scenario2, conf.level = 0.95)$measure print(kable(table_atbrgl5_scenario2, caption = "Contingency Table: Age vs. Antibiotic Prescription Necessity (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl5_scenario2) print(odds_ratio_atbrgl5_scenario2) ## Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl5_scenario3 <- df[df$ATBRGL5 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl5_scenario3$Age_Group <- ifelse(df_filtered_atbrgl5_scenario3$AGE %in% c(3, 4), "35-54", "Other") df_filtered_atbrgl5_scenario3$Disagree_Neither <- df_filtered_atbrgl5_scenario3$ATBRGL5 %in% c(1, 2) table_atbrgl5_scenario3 <- table(df_filtered_atbrgl5_scenario3$Disagree_Neither, df_filtered_atbrgl5_scenario3$Age_Group) rownames(table_atbrgl5_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl5_scenario3) <- c("35-54", "Other") chi_result_atbrgl5_scenario3 <- chisq.test(table_atbrgl5_scenario3) odds_ratio_atbrgl5_scenario3 <- oddsratio(table_atbrgl5_scenario3, conf.level = 0.95)$measure print(kable(table_atbrgl5_scenario3, caption = "Contingency Table: Age vs. Antibiotic Prescription Necessity (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl5_scenario3) print(odds_ratio_atbrgl5_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##ATBRGL6= People should only use antibiotics when prescribed by a doctor or nurse Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_atbrgl6_scenario1 <- df[df$ATBRGL6 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl6_scenario1$Age_Group <- ifelse(df_filtered_atbrgl6_scenario1$AGE %in% c(3, 4), "35-54", "Other") table_atbrgl6_scenario1 <- table(df_filtered_atbrgl6_scenario1$ATBRGL6, df_filtered_atbrgl6_scenario1$Age_Group) rownames(table_atbrgl6_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl6_scenario1) <- c("35-54", "Other") chi_result_atbrgl6_scenario1 <- chisq.test(table_atbrgl6_scenario1) odds_ratio_atbrgl6_scenario1 <- oddsratio(table_atbrgl6_scenario1, conf.level = 0.95)$measure print(kable(table_atbrgl6_scenario1, caption = "Contingency Table: Age vs. Antibiotic only when prescribed (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl6_scenario1) print(odds_ratio_atbrgl6_scenario1) ## Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl6_scenario2 <- df[df$ATBRGL6 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl6_scenario2$Age_Group <- ifelse(df_filtered_atbrgl6_scenario2$AGE %in% c(3, 4), "35-54", "Other") table_atbrgl6_scenario2 <- table(df_filtered_atbrgl6_scenario2$ATBRGL6, df_filtered_atbrgl6_scenario2$Age_Group) rownames(table_atbrgl6_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl6_scenario2) <- c("35-54", "Other") chi_result_atbrgl6_scenario2 <- chisq.test(table_atbrgl6_scenario2) odds_ratio_atbrgl6_scenario2 <- oddsratio(table_atbrgl6_scenario2, conf.level = 0.95)$measure print(kable(table_atbrgl6_scenario2, caption = "Contingency Table: Age vs. Antibiotic only when prescribed (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl6_scenario2) print(odds_ratio_atbrgl6_scenario2) ## Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl6_scenario3 <- df[df$ATBRGL6 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl6_scenario3$Age_Group <- ifelse(df_filtered_atbrgl6_scenario3$AGE %in% c(3, 4), "35-54", "Other") df_filtered_atbrgl6_scenario3$Disagree_Neither <- df_filtered_atbrgl6_scenario3$ATBRGL6 %in% c(1, 2) table_atbrgl6_scenario3 <- table(df_filtered_atbrgl6_scenario3$Disagree_Neither, df_filtered_atbrgl6_scenario3$Age_Group) rownames(table_atbrgl6_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl6_scenario3) <- c("35-54", "Other") chi_result_atbrgl6_scenario3 <- chisq.test(table_atbrgl6_scenario3) odds_ratio_atbrgl6_scenario3 <- oddsratio(table_atbrgl6_scenario3, conf.level = 0.95)$measure print(kable(table_atbrgl6_scenario3, caption = "Contingency Table: Age vs. Antibiotic only when prescribed (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl6_scenario3) print(odds_ratio_atbrgl6_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM1= Antibiotic resistance is one of the biggest problems the world faces Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_resdim1_scenario1 <- df[df$RESDIM1 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim1_scenario1$Age_Group <- ifelse(df_filtered_resdim1_scenario1$AGE %in% c(3, 4), "35-54", "Other") table_resdim1_scenario1 <- table(df_filtered_resdim1_scenario1$RESDIM1, df_filtered_resdim1_scenario1$Age_Group) rownames(table_resdim1_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_resdim1_scenario1) <- c("35-54", "Other") chi_result_resdim1_scenario1 <- chisq.test(table_resdim1_scenario1) odds_ratio_resdim1_scenario1 <- oddsratio(table_resdim1_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim1_scenario1, caption = "Contingency Table: Age vs. Perception of Antibiotic Resistance as a Global Problem (Strongly Agree vs. Strongly Disagree)")) print(chi_result_resdim1_scenario1) print(odds_ratio_resdim1_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim1_scenario2 <- df[df$RESDIM1 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim1_scenario2$Age_Group <- ifelse(df_filtered_resdim1_scenario2$AGE %in% c(3, 4), "35-54", "Other") table_resdim1_scenario2 <- table(df_filtered_resdim1_scenario2$RESDIM1, df_filtered_resdim1_scenario2$Age_Group) rownames(table_resdim1_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_resdim1_scenario2) <- c("35-54", "Other") chi_result_resdim1_scenario2 <- chisq.test(table_resdim1_scenario2) odds_ratio_resdim1_scenario2 <- oddsratio(table_resdim1_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim1_scenario2, caption = "Contingency Table: Age vs. Perception of Antibiotic Resistance as a Global Problem (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim1_scenario2) print(odds_ratio_resdim1_scenario2) # Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim1_scenario3 <- df[df$RESDIM1 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim1_scenario3$Age_Group <- ifelse(df_filtered_resdim1_scenario3$AGE %in% c(3, 4), "35-54", "Other") df_filtered_resdim1_scenario3$Disagree_Neither <- df_filtered_resdim1_scenario3$RESDIM1 %in% c(1, 2) table_resdim1_scenario3 <- table(df_filtered_resdim1_scenario3$Disagree_Neither, df_filtered_resdim1_scenario3$Age_Group) rownames(table_resdim1_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_resdim1_scenario3) <- c("35-54", "Other") chi_result_resdim1_scenario3 <- chisq.test(table_resdim1_scenario3) odds_ratio_resdim1_scenario3 <- oddsratio(table_resdim1_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim1_scenario3, caption = "Contingency Table: Age vs. Perception of Antibiotic Resistance as a Global Problem (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_resdim1_scenario3) print(odds_ratio_resdim1_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM2= Medical experts will solve the problem of antibiotic resistance before it becomes too serious Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Load the Database_simplified dataframe df <- read_excel("C:/Database_simplified.xlsx") # Scenario 1: Strongly Agree vs. Strongly Disagree df_filtered_resdim2_scenario1 <- df[df$RESDIM2 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim2_scenario1$Age_Group <- ifelse(df_filtered_resdim2_scenario1$AGE %in% c(3, 4), "35-54", "Other") table_resdim2_scenario1 <- table(df_filtered_resdim2_scenario1$RESDIM2, df_filtered_resdim2_scenario1$Age_Group) rownames(table_resdim2_scenario1) <- c("Strongly Agree", "Strongly Disagree") colnames(table_resdim2_scenario1) <- c("35-54", "Other") chi_result_resdim2_scenario1 <- chisq.test(table_resdim2_scenario1) odds_ratio_resdim2_scenario1 <- oddsratio(table_resdim2_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim2_scenario1, caption = "Contingency Table: Age vs. Belief in Solving Antibiotic Resistance (Strongly Disagree vs. Strongly Agree)")) print(chi_result_resdim2_scenario1) print(odds_ratio_resdim2_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim2_scenario2 <- df[df$RESDIM2 %in% c(1, 2) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim2_scenario2$Age_Group <- ifelse(df_filtered_resdim2_scenario2$AGE %in% c(3, 4), "35-54", "Other") table_resdim2_scenario2 <- table(df_filtered_resdim2_scenario2$RESDIM2, df_filtered_resdim2_scenario2$Age_Group) rownames(table_resdim2_scenario2) <- c("Strongly Disagree", "Neither Agree Nor Disagree") colnames(table_resdim2_scenario2) <- c("35-54", "Other") chi_result_resdim2_scenario2 <- chisq.test(table_resdim2_scenario2) odds_ratio_resdim2_scenario2 <- oddsratio(table_resdim2_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim2_scenario2, caption = "Contingency Table: Age vs. Belief in Solving Antibiotic Resistance (Strongly Disagree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim2_scenario2) print(odds_ratio_resdim2_scenario2) # Scenario 3: Strongly Agree + Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim2_scenario3 <- df[df$RESDIM2 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim2_scenario3$Age_Group <- ifelse(df_filtered_resdim2_scenario3$AGE %in% c(3, 4), "35-54", "Other") df_filtered_resdim2_scenario3$Agree_Neither <- df_filtered_resdim2_scenario3$RESDIM2 %in% c(2, 3) table_resdim2_scenario3 <- table(df_filtered_resdim2_scenario3$Agree_Neither, df_filtered_resdim2_scenario3$Age_Group) rownames(table_resdim2_scenario3) <- c("Strongly Disagree", "Strongly Agree + Neither") colnames(table_resdim2_scenario3) <- c("35-54", "Other") chi_result_resdim2_scenario3 <- chisq.test(table_resdim2_scenario3) odds_ratio_resdim2_scenario3 <- oddsratio(table_resdim2_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim2_scenario3, caption = "Contingency Table: Age vs. Belief in Solving Antibiotic Resistance (Strongly Disagree vs. Strongly Agree + Neither Agree Nor Disagree)")) print(chi_result_resdim2_scenario3) print(odds_ratio_resdim2_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM3= Everyone needs to use antibiotics responsibly Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_resdim3_scenario1 <- df[df$RESDIM3 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim3_scenario1$Age_Group <- ifelse(df_filtered_resdim3_scenario1$AGE %in% c(3, 4), "35-54", "Other") table_resdim3_scenario1 <- table(df_filtered_resdim3_scenario1$RESDIM3, df_filtered_resdim3_scenario1$Age_Group) rownames(table_resdim3_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_resdim3_scenario1) <- c("35-54", "Other") chi_result_resdim3_scenario1 <- chisq.test(table_resdim3_scenario1) odds_ratio_resdim3_scenario1 <- oddsratio(table_resdim3_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim3_scenario1, caption = "Contingency Table: Age vs. Everyone needs to use antibiotics responsibly (Strongly Agree vs. Strongly Disagree)")) print(chi_result_resdim3_scenario1) print(odds_ratio_resdim3_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim3_scenario2 <- df[df$RESDIM3 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim3_scenario2$Age_Group <- ifelse(df_filtered_resdim3_scenario2$AGE %in% c(3, 4), "35-54", "Other") table_resdim3_scenario2 <- table(df_filtered_resdim3_scenario2$RESDIM3, df_filtered_resdim3_scenario2$Age_Group) rownames(table_resdim3_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_resdim3_scenario2) <- c("35-54", "Other") chi_result_resdim3_scenario2 <- chisq.test(table_resdim3_scenario2) odds_ratio_resdim3_scenario2 <- oddsratio(table_resdim3_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim3_scenario2, caption = "Contingency Table: Age vs. Everyone needs to use antibiotics responsibly (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim3_scenario2) print(odds_ratio_resdim3_scenario2) # Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim3_scenario3 <- df[df$RESDIM3 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim3_scenario3$Age_Group <- ifelse(df_filtered_resdim3_scenario3$AGE %in% c(3, 4), "35-54", "Other") df_filtered_resdim3_scenario3$Disagree_Neither <- df_filtered_resdim3_scenario3$RESDIM3 %in% c(1, 2) table_resdim3_scenario3 <- table(df_filtered_resdim3_scenario3$Disagree_Neither, df_filtered_resdim3_scenario3$Age_Group) rownames(table_resdim3_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_resdim3_scenario3) <- c("35-54", "Other") chi_result_resdim3_scenario3 <- chisq.test(table_resdim3_scenario3) odds_ratio_resdim3_scenario3 <- oddsratio(table_resdim3_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim3_scenario3, caption = "Contingency Table: Age vs. Everyone needs to use antibiotics responsibly (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_resdim3_scenario3) print(odds_ratio_resdim3_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM4= People like me can't do much to stop antibiotic resistance Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Agree vs. Strongly Disagree df_filtered_resdim4_scenario1 <- df[df$RESDIM4 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim4_scenario1$Age_Group <- ifelse(df_filtered_resdim4_scenario1$AGE %in% c(3, 4), "35-54", "Other") table_resdim4_scenario1 <- table(df_filtered_resdim4_scenario1$RESDIM4, df_filtered_resdim4_scenario1$Age_Group) rownames(table_resdim4_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_resdim4_scenario1) <- c("35-54", "Other") chi_result_resdim4_scenario1 <- chisq.test(table_resdim4_scenario1) odds_ratio_resdim4_scenario1 <- oddsratio(table_resdim4_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim4_scenario1, caption = "Contingency Table: Age vs. Belief in Individual Impact on Antibiotic Resistance (Strongly Disagree vs. Strongly Agree)")) print(chi_result_resdim4_scenario1) print(odds_ratio_resdim4_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim4_scenario2 <- df[df$RESDIM4 %in% c(1, 2) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim4_scenario2$Age_Group <- ifelse(df_filtered_resdim4_scenario2$AGE %in% c(3, 4), "35-54", "Other") table_resdim4_scenario2 <- table(df_filtered_resdim4_scenario2$RESDIM4, df_filtered_resdim4_scenario2$Age_Group) rownames(table_resdim4_scenario2) <- c("Strongly Disagree", "Neither Agree Nor Disagree") colnames(table_resdim4_scenario2) <- c("35-54", "Other") chi_result_resdim4_scenario2 <- chisq.test(table_resdim4_scenario2) odds_ratio_resdim4_scenario2 <- oddsratio(table_resdim4_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim4_scenario2, caption = "Contingency Table: Age vs. Belief in Individual Impact on Antibiotic Resistance (Strongly Disagree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim4_scenario2) print(odds_ratio_resdim4_scenario2) # Scenario 3: Strongly Agree + Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim4_scenario3 <- df[df$RESDIM4 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim4_scenario3$Age_Group <- ifelse(df_filtered_resdim4_scenario3$AGE %in% c(3, 4), "35-54", "Other") df_filtered_resdim4_scenario3$Agree_Neither <- df_filtered_resdim4_scenario3$RESDIM4 %in% c(2, 3) table_resdim4_scenario3 <- table(df_filtered_resdim4_scenario3$Agree_Neither, df_filtered_resdim4_scenario3$Age_Group) rownames(table_resdim4_scenario3) <- c("Strongly Disagree", "Strongly Agree + Neither") colnames(table_resdim4_scenario3) <- c("35-54", "Other") chi_result_resdim4_scenario3 <- chisq.test(table_resdim4_scenario3) odds_ratio_resdim4_scenario3 <- oddsratio(table_resdim4_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim4_scenario3, caption = "Contingency Table: Age vs. Belief in Individual Impact on Antibiotic Resistance (Strongly Disagree vs. Strongly Agree + Neither Agree Nor Disagree)")) print(chi_result_resdim4_scenario3) print(odds_ratio_resdim4_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM5= I am worried about the impact that antibiotic resistance will have on my health and that of my family Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_resdim5_scenario1 <- df[df$RESDIM5 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim5_scenario1$Age_Group <- ifelse(df_filtered_resdim5_scenario1$AGE %in% c(3, 4), "35-54", "Other") table_resdim5_scenario1 <- table(df_filtered_resdim5_scenario1$RESDIM5, df_filtered_resdim5_scenario1$Age_Group) rownames(table_resdim5_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_resdim5_scenario1) <- c("35-54", "Other") chi_result_resdim5_scenario1 <- chisq.test(table_resdim5_scenario1) odds_ratio_resdim5_scenario1 <- oddsratio(table_resdim5_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim5_scenario1, caption = "Contingency Table: Age vs. Impact of AMR on personal health and that of their family (Strongly Agree vs. Strongly Disagree)")) print(chi_result_resdim5_scenario1) print(odds_ratio_resdim5_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim5_scenario2 <- df[df$RESDIM5 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim5_scenario2$Age_Group <- ifelse(df_filtered_resdim5_scenario2$AGE %in% c(3, 4), "35-54", "Other") table_resdim5_scenario2 <- table(df_filtered_resdim5_scenario2$RESDIM5, df_filtered_resdim5_scenario2$Age_Group) rownames(table_resdim5_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_resdim5_scenario2) <- c("35-54", "Other") chi_result_resdim5_scenario2 <- chisq.test(table_resdim5_scenario2) odds_ratio_resdim5_scenario2 <- oddsratio(table_resdim5_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim5_scenario2, caption = "Contingency Table: Age vs. Impact of AMR on personal health and that of their family (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim5_scenario2) print(odds_ratio_resdim5_scenario2) # Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim5_scenario3 <- df[df$RESDIM5 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim5_scenario3$Age_Group <- ifelse(df_filtered_resdim5_scenario3$AGE %in% c(3, 4), "35-54", "Other") df_filtered_resdim5_scenario3$Disagree_Neither <- df_filtered_resdim5_scenario3$RESDIM5 %in% c(1, 2) table_resdim5_scenario3 <- table(df_filtered_resdim5_scenario3$Disagree_Neither, df_filtered_resdim5_scenario3$Age_Group) rownames(table_resdim5_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_resdim5_scenario3) <- c("35-54", "Other") chi_result_resdim5_scenario3 <- chisq.test(table_resdim5_scenario3) odds_ratio_resdim5_scenario3 <- oddsratio(table_resdim5_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim5_scenario3, caption = "Contingency Table: Age vs. Impact of AMR on personal health and that of their family (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_resdim5_scenario3) print(odds_ratio_resdim5_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM6= I am not at risk of getting an antibiotic-resistant infection, as long as I take my antibiotics correctly Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Agree vs. Strongly Disagree df_filtered_resdim6_scenario1 <- df[df$RESDIM6 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim6_scenario1$Age_Group <- ifelse(df_filtered_resdim6_scenario1$AGE %in% c(3, 4), "35-54", "Other") table_resdim6_scenario1 <- table(df_filtered_resdim6_scenario1$RESDIM6, df_filtered_resdim6_scenario1$Age_Group) rownames(table_resdim6_scenario1) <- c("Strongly Agree", "Strongly Disagree") colnames(table_resdim6_scenario1) <- c("35-54", "Other") chi_result_resdim6_scenario1 <- chisq.test(table_resdim6_scenario1) odds_ratio_resdim6_scenario1 <- oddsratio(table_resdim6_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim6_scenario1, caption = "Contingency Table: Age vs. Perception of Risk of Antibiotic-Resistant Infection (Strongly Disagree vs. Strongly Agree)")) print(chi_result_resdim6_scenario1) print(odds_ratio_resdim6_scenario1) print(table_resdim6_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim6_scenario2 <- df[df$RESDIM6 %in% c(1, 2) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim6_scenario2$Age_Group <- ifelse(df_filtered_resdim6_scenario2$AGE %in% c(3, 4), "35-54", "Other") table_resdim6_scenario2 <- table(df_filtered_resdim6_scenario2$RESDIM6, df_filtered_resdim6_scenario2$Age_Group) rownames(table_resdim6_scenario2) <- c("Strongly Disagree", "Neither Agree Nor Disagree") colnames(table_resdim6_scenario2) <- c("35-54", "Other") chi_result_resdim6_scenario2 <- chisq.test(table_resdim6_scenario2) odds_ratio_resdim6_scenario2 <- oddsratio(table_resdim6_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim6_scenario2, caption = "Contingency Table: Age vs. Perception of Risk of Antibiotic-Resistant Infection (Strongly Disagree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim6_scenario2) print(odds_ratio_resdim6_scenario2) # Scenario 3: Strongly Agree + Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim6_scenario3 <- df[df$RESDIM6 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim6_scenario3$Age_Group <- ifelse(df_filtered_resdim6_scenario3$AGE %in% c(3, 4), "35-54", "Other") df_filtered_resdim6_scenario3$Agree_Neither <- df_filtered_resdim6_scenario3$RESDIM6 %in% c(2, 3) table_resdim6_scenario3 <- table(df_filtered_resdim6_scenario3$Agree_Neither, df_filtered_resdim6_scenario3$Age_Group) rownames(table_resdim6_scenario3) <- c("Strongly Disagree", "Strongly Agree + Neither") colnames(table_resdim6_scenario3) <- c("35-54", "Other") chi_result_resdim6_scenario3 <- chisq.test(table_resdim6_scenario3) odds_ratio_resdim6_scenario3 <- oddsratio(table_resdim6_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim6_scenario3, caption = "Contingency Table: Age vs. Perception of Risk of Antibiotic-Resistant Infection (Strongly Disagree vs. Strongly Agree + Neither Agree Nor Disagree)")) print(chi_result_resdim6_scenario3) print(odds_ratio_resdim6_scenario3) ############################################### 55+ vs. Other ############################################### ###CUSIN1 (I wash my hands before cooking (No= 9.4%)) # Load the Database_simplified dataframe Database_simplified <- read_excel("C:/Database_simplified.xlsx") # Filter the DataFrame df_filtered <- Database_simplified[Database_simplified$CUSIN1 %in% c(0, 1) & Database_simplified$AGE %in% c(1, 2, 3, 4, 5, 6), ] # Create a new variable for age categorization df_filtered$Age_Group <- ifelse(df_filtered$AGE %in% c(5, 6), "55+", "Other") # Create the Contingency Table table <- table(df_filtered$CUSIN1, df_filtered$Age_Group) # Add descriptive labels rownames(table) <- c("CUSIN1 (Yes)", "CUSIN1 (No)") colnames(table) <- c("55+", "Other") # Print the contingency table using knitr kable(table, caption = "Contingency Table: Age Group vs. Hand Washing") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) --------------------------------------------------------------------------------------------------- ##CUSIN2 (After handling raw food (meat and vegetables), I wash my hands with soap (No= 15.1%) df_filtered <- Database_simplified[Database_simplified$CUSIN2 %in% c(0, 1) & Database_simplified$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered$Age_Group <- ifelse(df_filtered$AGE %in% c(5, 6), "55+", "Other") table <- table(df_filtered$CUSIN2, df_filtered$Age_Group) rownames(table) <- c("CUSIN2 (Yes)", "CUSIN2 (No)") colnames(table) <- c("55+", "Other") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: AGE vs. After handling raw food (meat and vegetables), I wash my hands with soap") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------ ##CUSIN3 (I use the same kitchen utensils for handling raw and ready-to-eat foods (Yes=25.8%)) df_filtered <- Database_simplified[Database_simplified$CUSIN3 %in% c(0, 1) & Database_simplified$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered$Age_Group <- ifelse(df_filtered$AGE %in% c(5, 6), "55+", "Other") table <- table(df_filtered$CUSIN3, df_filtered$Age_Group) rownames(table) <- c("CUSIN3 (Yes)", "CUSIN3 (No)") colnames(table) <- c("55+", "Other") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: AGE vs. I use the same kitchen utensils for handling raw and ready-to-eat foods") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------- ##CUSIN4 (I wash kitchen utensils that have been used for raw food before using them to prepare other foods (No=16.8%)) df_filtered <- Database_simplified[Database_simplified$CUSIN4 %in% c(0, 1) & Database_simplified$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered$Age_Group <- ifelse(df_filtered$AGE %in% c(5, 6), "55+", "Other") table <- table(df_filtered$CUSIN4, df_filtered$Age_Group) rownames(table) <- c("CUSIN4 (Yes)", "CUSIN4 (No)") colnames(table) <- c("55+", "Other") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Age vs. I wash kitchen utensils that have been used for raw food before using them to prepare other foods") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------- ##CUSIN5 (I wash fruits and vegetables before eating them (No=20.7%)) df_filtered <- Database_simplified[Database_simplified$CUSIN5 %in% c(0, 1) & Database_simplified$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered$Age_Group <- ifelse(df_filtered$AGE %in% c(5, 6), "55+", "Other") table <- table(df_filtered$CUSIN5, df_filtered$Age_Group) rownames(table) <- c("CUSIN5 (Yes)", "CUSIN5 (No)") colnames(table) <- c("55+", "Other") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Age vs. I wash fruits and vegetables before eating them") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------- ##CUSIN6 (I wash my hands before eating (No=21.5)) df_filtered <- Database_simplified[Database_simplified$CUSIN6 %in% c(0, 1) & Database_simplified$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered$Age_Group <- ifelse(df_filtered$AGE %in% c(5, 6), "55+", "Other") table <- table(df_filtered$CUSIN6, df_filtered$Age_Group) rownames(table) <- c("CUSIN6 (Yes)", "CUSIN6 (No)") colnames(table) <- c("55+", "Other") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Age vs. I wash my hands before eating") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) --------------------------------------------------------------------------------------------------------------------- ##PRESCATB1 When you get a prescription for antibiotics, do you follow the recommended ##length of treatment and daily dosage? (No=4.2%) (Sometimes=9.6%) (No+Sometimes=13.8%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) df <- Database_simplified ############### 1st scenario= No df_filtered_prescatb1 <- df[df$PRESCATB1 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_prescatb1$Age_Group <- ifelse(df_filtered_prescatb1$AGE %in% c(5, 6), "55+", "Other") table_prescatb1 <- table(df_filtered_prescatb1$PRESCATB1, df_filtered_prescatb1$Age_Group) # Add descriptive labels to the rows and columns rownames(table_prescatb1) <- c("Yes", "No") # Perform the Chi-Squared test chi_result_prescatb1 <- chisq.test(table_prescatb1) # Calculate the odds ratio and confidence interval odds_ratio_prescatb1 <- oddsratio(table_prescatb1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_prescatb1, caption = "Contingency Table: Age vs. Following Prescription for Antibiotics")) # Print the results of the Chi-Squared test print(chi_result_prescatb1) # Print the odds ratio and confidence interval print(odds_ratio_prescatb1) ################## 2nd scenario= Sometimes df_filtered_prescatb1_sometimes <- df[df$PRESCATB1 %in% c(0, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_prescatb1_sometimes$Age_Group <- ifelse(df_filtered_prescatb1_sometimes$AGE %in% c(5, 6), "55+", "Other") table_prescatb1_sometimes <- table(df_filtered_prescatb1_sometimes$PRESCATB1, df_filtered_prescatb1_sometimes$Age_Group) # Add descriptive labels to the rows and columns rownames(table_prescatb1_sometimes) <- c("Yes", "No") # Perform the Chi-Squared test chi_result_prescatb1_sometimes <- chisq.test(table_prescatb1_sometimes) # Calculate the odds ratio and confidence interval odds_ratio_prescatb1_sometimes <- oddsratio(table_prescatb1_sometimes, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_prescatb1_sometimes, caption = "Contingency Table: Age vs. Following Prescription for Antibiotics Sometimes")) # Print the results of the Chi-Squared test print(chi_result_prescatb1_sometimes) # Print the odds ratio and confidence interval print(odds_ratio_prescatb1_sometimes) ################## 3rd scenario= No+Sometimes # Filter for 'Yes', 'No', and 'Sometimes' responses for PRESCATB1 and genders 'Female' and 'Male' df_filtered_prescatb1_combined <- df[df$PRESCATB1 %in% c(0, 1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_prescatb1_combined$Age_Group <- ifelse(df_filtered_prescatb1_combined$AGE %in% c(5, 6), "55+", "Other") df_filtered_prescatb1_combined$No_Sometimes <- df_filtered_prescatb1_combined$PRESCATB1 %in% c(1, 3) table_prescatb1_combined <- table(df_filtered_prescatb1_combined$No_Sometimes, df_filtered_prescatb1_combined$Age_Group) # Adjust the table to have 'Yes' and 'No+Sometimes' as row names rownames(table_prescatb1_combined) <- c("Yes", "No_Sometimes") # Perform the Chi-Squared test chi_result_prescatb1_combined <- chisq.test(table_prescatb1_combined) # Calculate the odds ratio and confidence interval odds_ratio_prescatb1_combined <- oddsratio(table_prescatb1_combined, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_prescatb1_combined, caption = "Contingency Table: Age vs. Following Prescription for Antibiotics (Yes vs. No+Sometimes)")) # Print the results of the Chi-Squared test print(chi_result_prescatb1_combined) # Print the odds ratio and confidence interval print(odds_ratio_prescatb1_combined) --------------------------------------------------------------------------------------------------------------------- ##ARRETATB Do you stop taking antibiotics when symptoms start to disappear? ##(Always=7.3%) (Sometimes=20.4%) (Always+Sometimes=27.7%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) df <- Database_simplified ############### 1st scenario= Always df_filtered_arretatb <- df[df$ARRETATB %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_arretatb$Age_Group <- ifelse(df_filtered_arretatb$AGE %in% c(5, 6), "55+", "Other") table_arretatb <- table(df_filtered_arretatb$ARRETATB, df_filtered_arretatb$Age_Group) # (Restante do script permanece o mesmo, substituindo 'GENRE' por 'Age_Group') # Add descriptive labels to the rows and columns rownames(table_arretatb) <- c("Always", "Never") # Perform the Chi-Squared test chi_result_arretatb <- chisq.test(table_arretatb) # Calculate the odds ratio and confidence interval odds_ratio_arretatb <- oddsratio(table_arretatb, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_arretatb, caption = "Contingency Table: Age vs. Stopping Antibiotics Always vs. Never")) # Print the results of the Chi-Squared test print(chi_result_arretatb) # Print the odds ratio and confidence interval print(odds_ratio_arretatb) ################# 2nd Cenario: Sometimes df_filtered_arretatb_sometimes <- df[df$ARRETATB %in% c(1, 2) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_arretatb_sometimes$Age_Group <- ifelse(df_filtered_arretatb_sometimes$AGE %in% c(5, 6), "55+", "Other") table_arretatb_sometimes <- table(df_filtered_arretatb_sometimes$ARRETATB == 2, df_filtered_arretatb_sometimes$Age_Group) # Add descriptive labels to the rows and columns rownames(table_arretatb_sometimes) <- c("Never", "Sometimes") # Perform the Chi-Squared test chi_result_arretatb_sometimes <- chisq.test(table_arretatb_sometimes) # Calculate the odds ratio and confidence interval odds_ratio_arretatb_sometimes <- oddsratio(table_arretatb_sometimes, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_arretatb_sometimes, caption = "Contingency Table: Age vs. Stopping Antibiotics Sometimes vs. Never")) # Print the results of the Chi-Squared test print(chi_result_arretatb_sometimes) # Print the odds ratio and confidence interval print(odds_ratio_arretatb_sometimes) ############### #3rd scenario= Sometimes+Always df_filtered_arretatb_combined <- df[df$ARRETATB %in% c(0, 1, 2) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_arretatb_combined$Age_Group <- ifelse(df_filtered_arretatb_combined$AGE %in% c(5, 6), "55+", "Other") df_filtered_arretatb_combined$Sometimes_Always <- df_filtered_arretatb_combined$ARRETATB %in% c(0, 2) table_arretatb_combined <- table(df_filtered_arretatb_combined$Sometimes_Always, df_filtered_arretatb_combined$Age_Group) # Add descriptive labels to the rows and columns rownames(table_arretatb_combined) <- c("Never", "Sometimes_Always") # Perform the Chi-Squared test chi_result_arretatb_combined <- chisq.test(table_arretatb_combined) # Calculate the odds ratio and confidence interval odds_ratio_arretatb_combined <- oddsratio(table_arretatb_combined, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_arretatb_combined, caption = "Contingency Table: Age vs. Stopping Antibiotics (Sometimes+Always vs. Never)")) # Print the results of the Chi-Squared test print(chi_result_arretatb_combined) # Print the odds ratio and confidence interval print(odds_ratio_arretatb_combined) --------------------------------------------------------------------------------------------------------------------- ##ATBORAL1 Have you ever taken an oral antibiotic treatment (by mouth) without a medical prescription? (Yes=12.3%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) df <- Database_simplified df_filtered_atboral <- df[df$ATBORAL1 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atboral$Age_Group <- ifelse(df_filtered_atboral$AGE %in% c(5, 6), "55+", "Other") table_atboral <- table(df_filtered_atboral$ATBORAL1, df_filtered_atboral$Age_Group) # Add descriptive labels to the rows and columns rownames(table_atboral) <- c("Yes", "No") # Perform the Chi-Squared test chi_result_atboral <- chisq.test(table_atboral) # Calculate the odds ratio and confidence interval odds_ratio_atboral <- oddsratio(table_atboral, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atboral, caption = "Contingency Table: Age vs. Taking Oral Antibiotics Without Prescription (Yes vs. No)")) # Print the results of the Chi-Squared test print(chi_result_atboral) # Print the odds ratio and confidence interval print(odds_ratio_atboral) -------------------------------------------------------------------------------------------------------- ### ATBANI1 I can exchange resistant bacteria with my pet (False=23.2%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) df <- Database_simplified df_filtered_atbani1 <- df[df$ATBANI1 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbani1$Age_Group <- ifelse(df_filtered_atbani1$AGE %in% c(5, 6), "55+", "Other") table_atbani1 <- table(df_filtered_atbani1$ATBANI1, df_filtered_atbani1$Age_Group) rownames(table_atbani1) <- c("True", "False") colnames(table_atbani1) <- c("55+", "Other") # Perform the Chi-Squared test chi_result_atbani1 <- chisq.test(table_atbani1) # Calculate the odds ratio and confidence interval odds_ratio_atbani1 <- oddsratio(table_atbani1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani1, caption = "Contingency Table: Age vs. Exchanging Resistant Bacteria with Pets (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani1) # Print the odds ratio and confidence interval print(odds_ratio_atbani1) --------------------------------------------------------------------------------------------------------------------- ### ATBANI2=The use of antibiotics in livestock and crops can increase the #presence of resistant bacteria in the environment (False=14.7%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) df <- Database_simplified df_filtered_atbani2 <- df[df$ATBANI2 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbani2$Age_Group <- ifelse(df_filtered_atbani2$AGE %in% c(5, 6), "55+", "Other") table_atbani2 <- table(df_filtered_atbani2$ATBANI2, df_filtered_atbani2$Age_Group) rownames(table_atbani2) <- c("True", "False") colnames(table_atbani2) <- c("55+", "Other") # Perform the Chi-Squared test chi_result_atbani2 <- chisq.test(table_atbani2) # Calculate the odds ratio and confidence interval odds_ratio_atbani2 <- oddsratio(table_atbani2, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani2, caption = "Contingency Table: Age vs. Antibiotics in Livestock and Crops Affecting Environment (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani2) # Print the odds ratio and confidence interval print(odds_ratio_atbani2) -------------------------------------------------------------------------------------------------------------------- ##### ATBANI3 The use of antibiotics in livestock and crops can affect me directly ##(I can get resistant bacteria in my body) (False=26.3%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) df <- Database_simplified df_filtered_atbani3 <- df[df$ATBANI3 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbani3$Age_Group <- ifelse(df_filtered_atbani3$AGE %in% c(5, 6), "55+", "Other") table_atbani3 <- table(df_filtered_atbani3$ATBANI3, df_filtered_atbani3$Age_Group) rownames(table_atbani3) <- c("True", "False") colnames(table_atbani3) <- c("55+", "Other") # Perform the Chi-Squared test chi_result_atbani3 <- chisq.test(table_atbani3) # Calculate the odds ratio and confidence interval odds_ratio_atbani3 <- oddsratio(table_atbani3, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani3, caption = "Contingency Table: Age vs. Antibiotics in Livestock and Crops Affecting Humans Directly (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani3) # Print the odds ratio and confidence interval print(odds_ratio_atbani3) ------------------------------------------------------------------------------------------------------------------- ##### ATBANI4 Resistant bacteria are only found in hospitals (True=10.8%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) df <- Database_simplified df_filtered_atbani4 <- df[df$ATBANI4 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbani4$Age_Group <- ifelse(df_filtered_atbani4$AGE %in% c(5, 6), "55+", "Other") table_atbani4 <- table(df_filtered_atbani4$ATBANI4, df_filtered_atbani4$Age_Group) rownames(table_atbani4) <- c("True", "False") colnames(table_atbani4) <- c("55+", "Other") # Perform the Chi-Squared test chi_result_atbani4 <- chisq.test(table_atbani4) # Calculate the odds ratio and confidence interval odds_ratio_atbani4 <- oddsratio(table_atbani4, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani4, caption = "Contingency Table: Age vs. Resistant Bacteria Found Only in Hospitals (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani4) # Print the odds ratio and confidence interval print(odds_ratio_atbani4) ---------------------------------------------------------------------------------------------------------------------- #####RESATB1 Antibiotic resistance occurs when your body becomes resistant to antibiotics and they ##no longer work as well (True=58.3%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) df <- Database_simplified df_filtered_resatb1 <- df[df$RESATB1 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resatb1$Age_Group <- ifelse(df_filtered_resatb1$AGE %in% c(5, 6), "55+", "Other") table_resatb1 <- table(df_filtered_resatb1$RESATB1, df_filtered_resatb1$Age_Group) rownames(table_resatb1) <- c("True", "False") colnames(table_resatb1) <- c("55+", "Other") # Perform the Chi-Squared test chi_result_resatb1 <- chisq.test(table_resatb1) # Calculate the odds ratio and confidence interval odds_ratio_resatb1 <- oddsratio(table_resatb1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb1, caption = "Contingency Table: Age vs. Understanding of Antibiotic Resistance (RESATB1: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb1) print(odds_ratio_resatb1) ------------------------------------------------------------------------------------------------------------------- #####RESATB2 Many infections are becoming increasingly resistant to antibiotic treatment (False=12.5%) # Load the database df <- Database_simplified df_filtered_resatb2 <- df[df$RESATB2 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resatb2$Age_Group <- ifelse(df_filtered_resatb2$AGE %in% c(5, 6), "55+", "Other") table_resatb2 <- table(df_filtered_resatb2$RESATB2, df_filtered_resatb2$Age_Group) rownames(table_resatb2) <- c("True", "False") colnames(table_resatb2) <- c("55+", "Other") # Perform the Chi-Squared test chi_result_resatb2 <- chisq.test(table_resatb2) # Calculate the odds ratio and confidence interval odds_ratio_resatb2 <- oddsratio(table_resatb2, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb2, caption = "Contingency Table: Age vs. Perception of Increasing Infection Resistance (RESATB2: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb2) print(odds_ratio_resatb2) --------------------------------------------------------------------------------------------------------------------- #####RESATB3 If bacteria are resistant to antibiotics, it can be very difficult or impossible to treat the infections they cause (False=16.7%) # Load the database df <- Database_simplified df_filtered_resatb3 <- df[df$RESATB3 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resatb3$Age_Group <- ifelse(df_filtered_resatb3$AGE %in% c(5, 6), "55+", "Other") table_resatb3 <- table(df_filtered_resatb3$RESATB3, df_filtered_resatb3$Age_Group) rownames(table_resatb3) <- c("True", "False") colnames(table_resatb3) <- c("55+", "Other") # Perform the Chi-Squared test chi_result_resatb3 <- chisq.test(table_resatb3) # Calculate the odds ratio and confidence interval odds_ratio_resatb3 <- oddsratio(table_resatb3, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb3, caption = "Contingency Table: Age vs. Perception of Difficulty Treating Infections (RESATB3: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb3) print(odds_ratio_resatb3) ---------------------------------------------------------------------------------------------------------------------- #####RESATB4 Antibiotic resistance is an issue that could affect me or my family (False=11.8%) # Load the database df <- Database_simplified df_filtered_resatb4 <- df[df$RESATB4 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resatb4$Age_Group <- ifelse(df_filtered_resatb4$AGE %in% c(5, 6), "55+", "Other") table_resatb4 <- table(df_filtered_resatb4$RESATB4, df_filtered_resatb4$Age_Group) rownames(table_resatb4) <- c("True", "False") colnames(table_resatb4) <- c("55+", "Other") # Perform the Chi-Squared test chi_result_resatb4 <- chisq.test(table_resatb4) # Calculate the odds ratio and confidence interval odds_ratio_resatb4 <- oddsratio(table_resatb4, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb4, caption = "Contingency Table: Age vs. Perception of Antibiotic Resistance Affecting One's Family (RESATB4: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb4) print(odds_ratio_resatb4) --------------------------------------------------------------------------------------------------------------------- #####RESATB5 Antibiotic resistance is an issue in other countries but not here (True=9.9%) # Load the database df <- Database_simplified df_filtered_resatb5 <- df[df$RESATB5 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resatb5$Age_Group <- ifelse(df_filtered_resatb5$AGE %in% c(5, 6), "55+", "Other") table_resatb5 <- table(df_filtered_resatb5$RESATB5, df_filtered_resatb5$Age_Group) rownames(table_resatb5) <- c("True", "False") colnames(table_resatb5) <- c("55+", "Other") # Perform the Chi-Squared test chi_result_resatb5 <- chisq.test(table_resatb5) # Calculate the odds ratio and confidence interval odds_ratio_resatb5 <- oddsratio(table_resatb5, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb5, caption = "Contingency Table: Age vs. Perception of Antibiotic Resistance as an Issue Only in Other Countries (RESATB5: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb5) print(odds_ratio_resatb5) --------------------------------------------------------------------------------------------------------------------- #####RESATB6 Antibiotic resistance is only a problem for people who take antibiotics regularly (True=17.5%) # Load the database df <- Database_simplified df_filtered_resatb6 <- df[df$RESATB6 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resatb6$Age_Group <- ifelse(df_filtered_resatb6$AGE %in% c(5, 6), "55+", "Other") table_resatb6 <- table(df_filtered_resatb6$RESATB6, df_filtered_resatb6$Age_Group) rownames(table_resatb6) <- c("True", "False") colnames(table_resatb6) <- c("55+", "Other") # Perform the Chi-Squared test chi_result_resatb6 <- chisq.test(table_resatb6) # Calculate the odds ratio and confidence interval odds_ratio_resatb6 <- oddsratio(table_resatb6, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb6, caption = "Contingency Table: Age vs. Perception of Antibiotic Resistance as a Problem Only for Regular Antibiotic Users (RESATB6: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb6) print(odds_ratio_resatb6) --------------------------------------------------------------------------------------------------------------------- #####RESATB7 Bacteria that are resistant to antibiotics can be spread from person to person (False=20.2%) # Load the database df <- Database_simplified df_filtered_resatb7 <- df[df$RESATB7 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resatb7$Age_Group <- ifelse(df_filtered_resatb7$AGE %in% c(5, 6), "55+", "Other") table_resatb7 <- table(df_filtered_resatb7$RESATB7, df_filtered_resatb7$Age_Group) rownames(table_resatb7) <- c("True", "False") colnames(table_resatb7) <- c("55+", "Other") # Perform the Chi-Squared test chi_result_resatb7 <- chisq.test(table_resatb7) # Calculate the odds ratio and confidence interval odds_ratio_resatb7 <- oddsratio(table_resatb7, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb7, caption = "Contingency Table: Age vs. Perception of Bacteria Transmission Person to Person (RESATB7: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb7) print(odds_ratio_resatb7) -------------------------------------------------------------------------------------------------------------------- #####RESATB8 Antibiotic-resistant infections could make medical procedures like surgery, organ transplants, ##and cancer treatment much more dangerous (False=12.0%) # Load the database df <- Database_simplified df_filtered_resatb8 <- df[df$RESATB8 %in% c(0, 1) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resatb8$Age_Group <- ifelse(df_filtered_resatb8$AGE %in% c(5, 6), "55+", "Other") table_resatb8 <- table(df_filtered_resatb8$RESATB8, df_filtered_resatb8$Age_Group) rownames(table_resatb8) <- c("True", "False") colnames(table_resatb8) <- c("55+", "Other") # Perform the Chi-Squared test chi_result_resatb8 <- chisq.test(table_resatb8) # Calculate the odds ratio and confidence interval odds_ratio_resatb8 <- oddsratio(table_resatb8, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb8, caption = "Contingency Table: Age vs. Perception of Antibiotic-Resistant Infections and Medical Procedures (RESATB8: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb8) print(odds_ratio_resatb8) -------------------------------------------------------------------------------------------------------------------- # ATBRGL1 Farmers should give fewer antibiotics to food-producing animals ##################### 1st scenario (Strongly desagree=8.68%) vs. Strongly Agree Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load dataframe df <- Database_simplified df_filtered_atbrgl1_scenario1 <- df[df$ATBRGL1 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl1_scenario1$Age_Group <- ifelse(df_filtered_atbrgl1_scenario1$AGE %in% c(5, 6), "55+", "Other") table_atbrgl1_scenario1 <- table(df_filtered_atbrgl1_scenario1$ATBRGL1, df_filtered_atbrgl1_scenario1$Age_Group) rownames(table_atbrgl1_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl1_scenario1) <- c("55+", "Other") # Perform the Chi-Squared test chi_result_atbrgl1_scenario1 <- chisq.test(table_atbrgl1_scenario1) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl1_scenario1 <- oddsratio(table_atbrgl1_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl1_scenario1, caption = "Contingency Table: Age vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Strongly Disagree)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_atbrgl1_scenario1) print(odds_ratio_atbrgl1_scenario1) ############################# 2nd scenario Farmers should give fewer antibiotics to ##food-producing animals (Neither agree nor desagree=22.6%) vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_atbrgl1_scenario2 <- df[df$ATBRGL1 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl1_scenario2$Age_Group <- ifelse(df_filtered_atbrgl1_scenario2$AGE %in% c(5, 6), "55+", "Other") table_atbrgl1_scenario2 <- table(df_filtered_atbrgl1_scenario2$ATBRGL1, df_filtered_atbrgl1_scenario2$Age_Group) rownames(table_atbrgl1_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl1_scenario2) <- c("55+", "Other") # Perform the Chi-Squared test chi_result_atbrgl1_scenario2 <- chisq.test(table_atbrgl1_scenario2) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl1_scenario2 <- oddsratio(table_atbrgl1_scenario2, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl1_scenario2, caption = "Contingency Table: Age vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Neither Agree Nor Disagree)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_atbrgl1_scenario2) print(odds_ratio_atbrgl1_scenario2) ############################# 3rd scenario (Strongly desagree + Neither agree nor desagree=31.28%) vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_atbrgl1_scenario3 <- df[df$ATBRGL1 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl1_scenario3$Age_Group <- ifelse(df_filtered_atbrgl1_scenario3$AGE %in% c(5, 6), "55+", "Other") df_filtered_atbrgl1_scenario3$Disagree_Neither <- df_filtered_atbrgl1_scenario3$ATBRGL1 %in% c(1, 2) table_atbrgl1_scenario3 <- table(df_filtered_atbrgl1_scenario3$Disagree_Neither, df_filtered_atbrgl1_scenario3$Age_Group) rownames(table_atbrgl1_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl1_scenario3) <- c("55+", "Other") # Perform the Chi-Squared test chi_result_atbrgl1_scenario3 <- chisq.test(table_atbrgl1_scenario3) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl1_scenario3 <- oddsratio(table_atbrgl1_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl1_scenario3, caption = "Contingency Table: Age vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Strongly Disagree + Neither)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_atbrgl1_scenario3) print(odds_ratio_atbrgl1_scenario3) -------------------------------------------------------------------------------------------------------------------- # ATBRGL2 People should not keep antibiotics and use them later for other illnesses ############################# 1st scenario Strongly desagree vs. Strongly Agree Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the database df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_atbrgl2_scenario1 <- df[df$ATBRGL2 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl2_scenario1$Age_Group <- ifelse(df_filtered_atbrgl2_scenario1$AGE %in% c(5, 6), "55+", "Other") table_atbrgl2_scenario1 <- table(df_filtered_atbrgl2_scenario1$ATBRGL2, df_filtered_atbrgl2_scenario1$Age_Group) rownames(table_atbrgl2_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl2_scenario1) <- c("55+", "Other") # Perform Chi-Squared test chi_result_atbrgl2_scenario1 <- chisq.test(table_atbrgl2_scenario1) # Calculate odds ratio and confidence interval odds_ratio_atbrgl2_scenario1 <- oddsratio(table_atbrgl2_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl2_scenario1, caption = "Contingency Table: Age vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl2_scenario1) print(odds_ratio_atbrgl2_scenario1) ############################# 2nd scenario Neither agree nor desagree vs. Strongly Agree # Filter for 'Strongly Agree' (3) and 'Neither Agree Nor Disagree' (2) responses for ATBRGL2 df_filtered_atbrgl2_scenario2 <- df[df$ATBRGL2 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl2_scenario2$Age_Group <- ifelse(df_filtered_atbrgl2_scenario2$AGE %in% c(5, 6), "55+", "Other") table_atbrgl2_scenario2 <- table(df_filtered_atbrgl2_scenario2$ATBRGL2, df_filtered_atbrgl2_scenario2$Age_Group) rownames(table_atbrgl2_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl2_scenario2) <- c("55+", "Other") # Perform Chi-Squared test chi_result_atbrgl2_scenario2 <- chisq.test(table_atbrgl2_scenario2) # Calculate odds ratio and confidence interval odds_ratio_atbrgl2_scenario2 <- oddsratio(table_atbrgl2_scenario2, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl2_scenario2, caption = "Contingency Table: Age vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl2_scenario2) print(odds_ratio_atbrgl2_scenario2) ############################# 3rd scenario Neither agree nor desagree + Stringly Disagree vs. Strongly Agree df_filtered_atbrgl2_scenario3 <- df[df$ATBRGL2 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl2_scenario3$Age_Group <- ifelse(df_filtered_atbrgl2_scenario3$AGE %in% c(5, 6), "55+", "Other") df_filtered_atbrgl2_scenario3$Disagree_Neither <- df_filtered_atbrgl2_scenario3$ATBRGL2 %in% c(1, 2) table_atbrgl2_scenario3 <- table(df_filtered_atbrgl2_scenario3$Disagree_Neither, df_filtered_atbrgl2_scenario3$Age_Group) rownames(table_atbrgl2_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl2_scenario3) <- c("55+", "Other") # Perform the Chi-Squared test chi_result_atbrgl2_scenario3 <- chisq.test(table_atbrgl2_scenario3) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl2_scenario3 <- oddsratio(table_atbrgl2_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl2_scenario3, caption = "Contingency Table: Age vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl2_scenario3) print(odds_ratio_atbrgl2_scenario3) -------------------------------------------------------------------------------------------------------------------- # ATBRGL3 Parents should make sure all of their children’s vaccinations are up-to-date Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) ####1st scenario # Load dataframe df <- Database_simplified df_filtered_atbrgl3_scenario1 <- df[df$ATBRGL3 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl3_scenario1$Age_Group <- ifelse(df_filtered_atbrgl3_scenario1$AGE %in% c(5, 6), "55+", "Other") table_atbrgl3_scenario1 <- table(df_filtered_atbrgl3_scenario1$ATBRGL3, df_filtered_atbrgl3_scenario1$Age_Group) rownames(table_atbrgl3_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl3_scenario1) <- c("55+", "Other") # Perform Chi-Squared test chi_result_atbrgl3_scenario1 <- chisq.test(table_atbrgl3_scenario1) # Calculate odds ratio and confidence interval odds_ratio_atbrgl3_scenario1 <- oddsratio(table_atbrgl3_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl3_scenario1, caption = "Contingency Table: Age vs. Opinion on Children's Vaccinations (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl3_scenario1) print(odds_ratio_atbrgl3_scenario1) ### 2nd Scenario df_filtered_atbrgl3_scenario2 <- df[df$ATBRGL3 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl3_scenario2$Age_Group <- ifelse(df_filtered_atbrgl3_scenario2$AGE %in% c(5, 6), "55+", "Other") table_atbrgl3_scenario2 <- table(df_filtered_atbrgl3_scenario2$ATBRGL3, df_filtered_atbrgl3_scenario2$Age_Group) rownames(table_atbrgl3_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl3_scenario2) <- c("55+", "Other") # Perform Chi-Squared test chi_result_atbrgl3_scenario2 <- chisq.test(table_atbrgl3_scenario2) # Calculate odds ratio and confidence interval odds_ratio_atbrgl3_scenario2 <- oddsratio(table_atbrgl3_scenario2, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl3_scenario2, caption = "Contingency Table: Age vs. Opinion on Children's Vaccinations (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl3_scenario2) print(odds_ratio_atbrgl3_scenario2) ## 3rd scenario df_filtered_atbrgl3_scenario3 <- df[df$ATBRGL3 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl3_scenario3$Age_Group <- ifelse(df_filtered_atbrgl3_scenario3$AGE %in% c(5, 6), "55+", "Other") df_filtered_atbrgl3_scenario3$Disagree_Neither <- df_filtered_atbrgl3_scenario3$ATBRGL3 %in% c(1, 2) table_atbrgl3_scenario3 <- table(df_filtered_atbrgl3_scenario3$Disagree_Neither, df_filtered_atbrgl3_scenario3$Age_Group) rownames(table_atbrgl3_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl3_scenario3) <- c("55+", "Other") # Perform the Chi-Squared test chi_result_atbrgl3_scenario3 <- chisq.test(table_atbrgl3_scenario3) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl3_scenario3 <- oddsratio(table_atbrgl3_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl3_scenario3, caption = "Contingency Table: Age vs. Opinion on Children's Vaccinations (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl3_scenario3) print(odds_ratio_atbrgl3_scenario3) --------------------------------------------------------------------------------------------------------------------- # ATBRGL4 People should wash their hands regularly Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_atbrgl4_scenario1 <- df[df$ATBRGL4 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl4_scenario1$Age_Group <- ifelse(df_filtered_atbrgl4_scenario1$AGE %in% c(5, 6), "55+", "Other") table_atbrgl4_scenario1 <- table(df_filtered_atbrgl4_scenario1$ATBRGL4, df_filtered_atbrgl4_scenario1$Age_Group) rownames(table_atbrgl4_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl4_scenario1) <- c("55+", "Other") chi_result_atbrgl4_scenario1 <- chisq.test(table_atbrgl4_scenario1) odds_ratio_atbrgl4_scenario1 <- oddsratio(table_atbrgl4_scenario1, conf.level = 0.95)$measure print(kable(table_atbrgl4_scenario1, caption = "Contingency Table: Age vs. Hand Washing Importance (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl4_scenario1) print(odds_ratio_atbrgl4_scenario1) ## Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl4_scenario2 <- df[df$ATBRGL4 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl4_scenario2$Age_Group <- ifelse(df_filtered_atbrgl4_scenario2$AGE %in% c(5, 6), "55+", "Other") table_atbrgl4_scenario2 <- table(df_filtered_atbrgl4_scenario2$ATBRGL4, df_filtered_atbrgl4_scenario2$Age_Group) rownames(table_atbrgl4_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl4_scenario2) <- c("55+", "Other") chi_result_atbrgl4_scenario2 <- chisq.test(table_atbrgl4_scenario2) odds_ratio_atbrgl4_scenario2 <- oddsratio(table_atbrgl4_scenario2, conf.level = 0.95)$measure print(kable(table_atbrgl4_scenario2, caption = "Contingency Table: Age vs. Hand Washing Importance (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl4_scenario2) print(odds_ratio_atbrgl4_scenario2) ## Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl4_scenario3 <- df[df$ATBRGL4 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl4_scenario3$Age_Group <- ifelse(df_filtered_atbrgl4_scenario3$AGE %in% c(5, 6), "55+", "Other") df_filtered_atbrgl4_scenario3$Disagree_Neither <- df_filtered_atbrgl4_scenario3$ATBRGL4 %in% c(1, 2) table_atbrgl4_scenario3 <- table(df_filtered_atbrgl4_scenario3$Disagree_Neither, df_filtered_atbrgl4_scenario3$Age_Group) rownames(table_atbrgl4_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl4_scenario3) <- c("18-34", "35+") chi_result_atbrgl4_scenario3 <- chisq.test(table_atbrgl4_scenario3) odds_ratio_atbrgl4_scenario3 <- oddsratio(table_atbrgl4_scenario3, conf.level = 0.95)$measure print(kable(table_atbrgl4_scenario3, caption = "Contingency Table: Age vs. Hand Washing Importance (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl4_scenario3) print(odds_ratio_atbrgl4_scenario3) --------------------------------------------------------------------------------------------------------------------- #ATBRGL5 Doctors should only prescribe antibiotics when they are needed Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_atbrgl5_scenario1 <- df[df$ATBRGL5 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl5_scenario1$Age_Group <- ifelse(df_filtered_atbrgl5_scenario1$AGE %in% c(5, 6), "55+", "Other") table_atbrgl5_scenario1 <- table(df_filtered_atbrgl5_scenario1$ATBRGL5, df_filtered_atbrgl5_scenario1$Age_Group) rownames(table_atbrgl5_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl5_scenario1) <- c("55+", "Other") chi_result_atbrgl5_scenario1 <- chisq.test(table_atbrgl5_scenario1) odds_ratio_atbrgl5_scenario1 <- oddsratio(table_atbrgl5_scenario1, conf.level = 0.95)$measure print(kable(table_atbrgl5_scenario1, caption = "Contingency Table: Age vs. Antibiotic Prescription Necessity (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl5_scenario1) print(odds_ratio_atbrgl5_scenario1) ## Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl5_scenario2 <- df[df$ATBRGL5 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl5_scenario2$Age_Group <- ifelse(df_filtered_atbrgl5_scenario2$AGE %in% c(5, 6), "55+", "Other") table_atbrgl5_scenario2 <- table(df_filtered_atbrgl5_scenario2$ATBRGL5, df_filtered_atbrgl5_scenario2$Age_Group) rownames(table_atbrgl5_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl5_scenario2) <- c("55+", "Other") chi_result_atbrgl5_scenario2 <- chisq.test(table_atbrgl5_scenario2) odds_ratio_atbrgl5_scenario2 <- oddsratio(table_atbrgl5_scenario2, conf.level = 0.95)$measure print(kable(table_atbrgl5_scenario2, caption = "Contingency Table: Age vs. Antibiotic Prescription Necessity (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl5_scenario2) print(odds_ratio_atbrgl5_scenario2) ## Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl5_scenario3 <- df[df$ATBRGL5 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl5_scenario3$Age_Group <- ifelse(df_filtered_atbrgl5_scenario3$AGE %in% c(5, 6), "55+", "Other") df_filtered_atbrgl5_scenario3$Disagree_Neither <- df_filtered_atbrgl5_scenario3$ATBRGL5 %in% c(1, 2) table_atbrgl5_scenario3 <- table(df_filtered_atbrgl5_scenario3$Disagree_Neither, df_filtered_atbrgl5_scenario3$Age_Group) rownames(table_atbrgl5_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl5_scenario3) <- c("55+", "Other") chi_result_atbrgl5_scenario3 <- chisq.test(table_atbrgl5_scenario3) odds_ratio_atbrgl5_scenario3 <- oddsratio(table_atbrgl5_scenario3, conf.level = 0.95)$measure print(kable(table_atbrgl5_scenario3, caption = "Contingency Table: Age vs. Antibiotic Prescription Necessity (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl5_scenario3) print(odds_ratio_atbrgl5_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##ATBRGL6= People should only use antibiotics when prescribed by a doctor or nurse Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_atbrgl6_scenario1 <- df[df$ATBRGL6 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl6_scenario1$Age_Group <- ifelse(df_filtered_atbrgl6_scenario1$AGE %in% c(5, 6), "55+", "Other") table_atbrgl6_scenario1 <- table(df_filtered_atbrgl6_scenario1$ATBRGL6, df_filtered_atbrgl6_scenario1$Age_Group) rownames(table_atbrgl6_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_atbrgl6_scenario1) <- c("55+", "Other") chi_result_atbrgl6_scenario1 <- chisq.test(table_atbrgl6_scenario1) odds_ratio_atbrgl6_scenario1 <- oddsratio(table_atbrgl6_scenario1, conf.level = 0.95)$measure print(kable(table_atbrgl6_scenario1, caption = "Contingency Table: Age vs. Antibiotic only when prescribed (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl6_scenario1) print(odds_ratio_atbrgl6_scenario1) ## Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl6_scenario2 <- df[df$ATBRGL6 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl6_scenario2$Age_Group <- ifelse(df_filtered_atbrgl6_scenario2$AGE %in% c(5, 6), "55+", "Other") table_atbrgl6_scenario2 <- table(df_filtered_atbrgl6_scenario2$ATBRGL6, df_filtered_atbrgl6_scenario2$Age_Group) rownames(table_atbrgl6_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_atbrgl6_scenario2) <- c("55+", "Other") chi_result_atbrgl6_scenario2 <- chisq.test(table_atbrgl6_scenario2) odds_ratio_atbrgl6_scenario2 <- oddsratio(table_atbrgl6_scenario2, conf.level = 0.95)$measure print(kable(table_atbrgl6_scenario2, caption = "Contingency Table: Age vs. Antibiotic only when prescribed (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl6_scenario2) print(odds_ratio_atbrgl6_scenario2) ## Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl6_scenario3 <- df[df$ATBRGL6 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl6_scenario3$Age_Group <- ifelse(df_filtered_atbrgl6_scenario3$AGE %in% c(5, 6), "55+", "Other") df_filtered_atbrgl6_scenario3$Disagree_Neither <- df_filtered_atbrgl6_scenario3$ATBRGL6 %in% c(1, 2) table_atbrgl6_scenario3 <- table(df_filtered_atbrgl6_scenario3$Disagree_Neither, df_filtered_atbrgl6_scenario3$Age_Group) rownames(table_atbrgl6_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_atbrgl6_scenario3) <- c("55+", "Other") chi_result_atbrgl6_scenario3 <- chisq.test(table_atbrgl6_scenario3) odds_ratio_atbrgl6_scenario3 <- oddsratio(table_atbrgl6_scenario3, conf.level = 0.95)$measure print(kable(table_atbrgl6_scenario3, caption = "Contingency Table: Age vs. Antibiotic only when prescribed (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl6_scenario3) print(odds_ratio_atbrgl6_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM1= Antibiotic resistance is one of the biggest problems the world faces Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_resdim1_scenario1 <- df[df$RESDIM1 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim1_scenario1$Age_Group <- ifelse(df_filtered_resdim1_scenario1$AGE %in% c(5, 6), "55+", "Other") table_resdim1_scenario1 <- table(df_filtered_resdim1_scenario1$RESDIM1, df_filtered_resdim1_scenario1$Age_Group) rownames(table_resdim1_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_resdim1_scenario1) <- c("55+", "Other") chi_result_resdim1_scenario1 <- chisq.test(table_resdim1_scenario1) odds_ratio_resdim1_scenario1 <- oddsratio(table_resdim1_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim1_scenario1, caption = "Contingency Table: Age vs. Perception of Antibiotic Resistance as a Global Problem (Strongly Agree vs. Strongly Disagree)")) print(chi_result_resdim1_scenario1) print(odds_ratio_resdim1_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim1_scenario2 <- df[df$RESDIM1 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim1_scenario2$Age_Group <- ifelse(df_filtered_resdim1_scenario2$AGE %in% c(5, 6), "55+", "Other") table_resdim1_scenario2 <- table(df_filtered_resdim1_scenario2$RESDIM1, df_filtered_resdim1_scenario2$Age_Group) rownames(table_resdim1_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_resdim1_scenario2) <- c("55+", "Other") chi_result_resdim1_scenario2 <- chisq.test(table_resdim1_scenario2) odds_ratio_resdim1_scenario2 <- oddsratio(table_resdim1_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim1_scenario2, caption = "Contingency Table: Age vs. Perception of Antibiotic Resistance as a Global Problem (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim1_scenario2) print(odds_ratio_resdim1_scenario2) # Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim1_scenario3 <- df[df$RESDIM1 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim1_scenario3$Age_Group <- ifelse(df_filtered_resdim1_scenario3$AGE %in% c(5, 6), "55+", "Other") df_filtered_resdim1_scenario3$Disagree_Neither <- df_filtered_resdim1_scenario3$RESDIM1 %in% c(1, 2) table_resdim1_scenario3 <- table(df_filtered_resdim1_scenario3$Disagree_Neither, df_filtered_resdim1_scenario3$Age_Group) rownames(table_resdim1_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_resdim1_scenario3) <- c("55+", "Other") chi_result_resdim1_scenario3 <- chisq.test(table_resdim1_scenario3) odds_ratio_resdim1_scenario3 <- oddsratio(table_resdim1_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim1_scenario3, caption = "Contingency Table: Age vs. Perception of Antibiotic Resistance as a Global Problem (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_resdim1_scenario3) print(odds_ratio_resdim1_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM2= Medical experts will solve the problem of antibiotic resistance before it becomes too serious Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Load the Database_simplified dataframe df <- read_excel("C:/Database_simplified.xlsx") # Scenario 1: Strongly Agree vs. Strongly Disagree df_filtered_resdim2_scenario1 <- df[df$RESDIM2 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim2_scenario1$Age_Group <- ifelse(df_filtered_resdim2_scenario1$AGE %in% c(5, 6), "55+", "Other") table_resdim2_scenario1 <- table(df_filtered_resdim2_scenario1$RESDIM2, df_filtered_resdim2_scenario1$Age_Group) rownames(table_resdim2_scenario1) <- c("Strongly Agree", "Strongly Disagree") colnames(table_resdim2_scenario1) <- c("55+", "Other") chi_result_resdim2_scenario1 <- chisq.test(table_resdim2_scenario1) odds_ratio_resdim2_scenario1 <- oddsratio(table_resdim2_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim2_scenario1, caption = "Contingency Table: Age vs. Belief in Solving Antibiotic Resistance (Strongly Disagree vs. Strongly Agree)")) print(chi_result_resdim2_scenario1) print(odds_ratio_resdim2_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim2_scenario2 <- df[df$RESDIM2 %in% c(1, 2) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim2_scenario2$Age_Group <- ifelse(df_filtered_resdim2_scenario2$AGE %in% c(5, 6), "55+", "Other") table_resdim2_scenario2 <- table(df_filtered_resdim2_scenario2$RESDIM2, df_filtered_resdim2_scenario2$Age_Group) rownames(table_resdim2_scenario2) <- c("Strongly Disagree", "Neither Agree Nor Disagree") colnames(table_resdim2_scenario2) <- c("55+", "Other") chi_result_resdim2_scenario2 <- chisq.test(table_resdim2_scenario2) odds_ratio_resdim2_scenario2 <- oddsratio(table_resdim2_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim2_scenario2, caption = "Contingency Table: Age vs. Belief in Solving Antibiotic Resistance (Strongly Disagree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim2_scenario2) print(odds_ratio_resdim2_scenario2) # Scenario 3: Strongly Agree + Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim2_scenario3 <- df[df$RESDIM2 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim2_scenario3$Age_Group <- ifelse(df_filtered_resdim2_scenario3$AGE %in% c(5, 6), "55+", "Other") df_filtered_resdim2_scenario3$Agree_Neither <- df_filtered_resdim2_scenario3$RESDIM2 %in% c(2, 3) table_resdim2_scenario3 <- table(df_filtered_resdim2_scenario3$Agree_Neither, df_filtered_resdim2_scenario3$Age_Group) rownames(table_resdim2_scenario3) <- c("Strongly Disagree", "Strongly Agree + Neither") colnames(table_resdim2_scenario3) <- c("55+", "Other") chi_result_resdim2_scenario3 <- chisq.test(table_resdim2_scenario3) odds_ratio_resdim2_scenario3 <- oddsratio(table_resdim2_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim2_scenario3, caption = "Contingency Table: Age vs. Belief in Solving Antibiotic Resistance (Strongly Disagree vs. Strongly Agree + Neither Agree Nor Disagree)")) print(chi_result_resdim2_scenario3) print(odds_ratio_resdim2_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM3= Everyone needs to use antibiotics responsibly Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_resdim3_scenario1 <- df[df$RESDIM3 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim3_scenario1$Age_Group <- ifelse(df_filtered_resdim3_scenario1$AGE %in% c(5, 6), "55+", "Other") table_resdim3_scenario1 <- table(df_filtered_resdim3_scenario1$RESDIM3, df_filtered_resdim3_scenario1$Age_Group) rownames(table_resdim3_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_resdim3_scenario1) <- c("55+", "Other") chi_result_resdim3_scenario1 <- chisq.test(table_resdim3_scenario1) odds_ratio_resdim3_scenario1 <- oddsratio(table_resdim3_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim3_scenario1, caption = "Contingency Table: Age vs. Everyone needs to use antibiotics responsibly (Strongly Agree vs. Strongly Disagree)")) print(chi_result_resdim3_scenario1) print(odds_ratio_resdim3_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim3_scenario2 <- df[df$RESDIM3 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim3_scenario2$Age_Group <- ifelse(df_filtered_resdim3_scenario2$AGE %in% c(5, 6), "55+", "Other") table_resdim3_scenario2 <- table(df_filtered_resdim3_scenario2$RESDIM3, df_filtered_resdim3_scenario2$Age_Group) rownames(table_resdim3_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_resdim3_scenario2) <- c("55+", "Other") chi_result_resdim3_scenario2 <- chisq.test(table_resdim3_scenario2) odds_ratio_resdim3_scenario2 <- oddsratio(table_resdim3_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim3_scenario2, caption = "Contingency Table: Age vs. Everyone needs to use antibiotics responsibly (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim3_scenario2) print(odds_ratio_resdim3_scenario2) # Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim3_scenario3 <- df[df$RESDIM3 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim3_scenario3$Age_Group <- ifelse(df_filtered_resdim3_scenario3$AGE %in% c(5, 6), "55+", "Other") df_filtered_resdim3_scenario3$Disagree_Neither <- df_filtered_resdim3_scenario3$RESDIM3 %in% c(1, 2) table_resdim3_scenario3 <- table(df_filtered_resdim3_scenario3$Disagree_Neither, df_filtered_resdim3_scenario3$Age_Group) rownames(table_resdim3_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_resdim3_scenario3) <- c("55+", "Other") chi_result_resdim3_scenario3 <- chisq.test(table_resdim3_scenario3) odds_ratio_resdim3_scenario3 <- oddsratio(table_resdim3_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim3_scenario3, caption = "Contingency Table: Age vs. Everyone needs to use antibiotics responsibly (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_resdim3_scenario3) print(odds_ratio_resdim3_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM4= People like me can't do much to stop antibiotic resistance Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Agree vs. Strongly Disagree df_filtered_resdim4_scenario1 <- df[df$RESDIM4 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim4_scenario1$Age_Group <- ifelse(df_filtered_resdim4_scenario1$AGE %in% c(5, 6), "55+", "Other") table_resdim4_scenario1 <- table(df_filtered_resdim4_scenario1$RESDIM4, df_filtered_resdim4_scenario1$Age_Group) rownames(table_resdim4_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_resdim4_scenario1) <- c("55+", "Other") chi_result_resdim4_scenario1 <- chisq.test(table_resdim4_scenario1) odds_ratio_resdim4_scenario1 <- oddsratio(table_resdim4_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim4_scenario1, caption = "Contingency Table: Age vs. Belief in Individual Impact on Antibiotic Resistance (Strongly Disagree vs. Strongly Agree)")) print(chi_result_resdim4_scenario1) print(odds_ratio_resdim4_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim4_scenario2 <- df[df$RESDIM4 %in% c(1, 2) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim4_scenario2$Age_Group <- ifelse(df_filtered_resdim4_scenario2$AGE %in% c(5, 6), "55+", "Other") table_resdim4_scenario2 <- table(df_filtered_resdim4_scenario2$RESDIM4, df_filtered_resdim4_scenario2$Age_Group) rownames(table_resdim4_scenario2) <- c("Strongly Disagree", "Neither Agree Nor Disagree") colnames(table_resdim4_scenario2) <- c("55+", "Other") chi_result_resdim4_scenario2 <- chisq.test(table_resdim4_scenario2) odds_ratio_resdim4_scenario2 <- oddsratio(table_resdim4_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim4_scenario2, caption = "Contingency Table: Age vs. Belief in Individual Impact on Antibiotic Resistance (Strongly Disagree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim4_scenario2) print(odds_ratio_resdim4_scenario2) # Scenario 3: Strongly Agree + Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim4_scenario3 <- df[df$RESDIM4 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim4_scenario3$Age_Group <- ifelse(df_filtered_resdim4_scenario3$AGE %in% c(5, 6), "55+", "Other") df_filtered_resdim4_scenario3$Agree_Neither <- df_filtered_resdim4_scenario3$RESDIM4 %in% c(2, 3) table_resdim4_scenario3 <- table(df_filtered_resdim4_scenario3$Agree_Neither, df_filtered_resdim4_scenario3$Age_Group) rownames(table_resdim4_scenario3) <- c("Strongly Disagree", "Strongly Agree + Neither") colnames(table_resdim4_scenario3) <- c("55+", "Other") chi_result_resdim4_scenario3 <- chisq.test(table_resdim4_scenario3) odds_ratio_resdim4_scenario3 <- oddsratio(table_resdim4_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim4_scenario3, caption = "Contingency Table: Age vs. Belief in Individual Impact on Antibiotic Resistance (Strongly Disagree vs. Strongly Agree + Neither Agree Nor Disagree)")) print(chi_result_resdim4_scenario3) print(odds_ratio_resdim4_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM5= I am worried about the impact that antibiotic resistance will have on my health and that of my family Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_resdim5_scenario1 <- df[df$RESDIM5 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim5_scenario1$Age_Group <- ifelse(df_filtered_resdim5_scenario1$AGE %in% c(5, 6), "55+", "Other") table_resdim5_scenario1 <- table(df_filtered_resdim5_scenario1$RESDIM5, df_filtered_resdim5_scenario1$Age_Group) rownames(table_resdim5_scenario1) <- c("Strongly Disagree", "Strongly Agree") colnames(table_resdim5_scenario1) <- c("55+", "Other") chi_result_resdim5_scenario1 <- chisq.test(table_resdim5_scenario1) odds_ratio_resdim5_scenario1 <- oddsratio(table_resdim5_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim5_scenario1, caption = "Contingency Table: Age vs. Impact of AMR on personal health and that of their family (Strongly Agree vs. Strongly Disagree)")) print(chi_result_resdim5_scenario1) print(odds_ratio_resdim5_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim5_scenario2 <- df[df$RESDIM5 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim5_scenario2$Age_Group <- ifelse(df_filtered_resdim5_scenario2$AGE %in% c(5, 6), "55+", "Other") table_resdim5_scenario2 <- table(df_filtered_resdim5_scenario2$RESDIM5, df_filtered_resdim5_scenario2$Age_Group) rownames(table_resdim5_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") colnames(table_resdim5_scenario2) <- c("55+", "Other") chi_result_resdim5_scenario2 <- chisq.test(table_resdim5_scenario2) odds_ratio_resdim5_scenario2 <- oddsratio(table_resdim5_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim5_scenario2, caption = "Contingency Table: Age vs. Impact of AMR on personal health and that of their family (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim5_scenario2) print(odds_ratio_resdim5_scenario2) # Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim5_scenario3 <- df[df$RESDIM5 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim5_scenario3$Age_Group <- ifelse(df_filtered_resdim5_scenario3$AGE %in% c(5, 6), "55+", "Other") df_filtered_resdim5_scenario3$Disagree_Neither <- df_filtered_resdim5_scenario3$RESDIM5 %in% c(1, 2) table_resdim5_scenario3 <- table(df_filtered_resdim5_scenario3$Disagree_Neither, df_filtered_resdim5_scenario3$Age_Group) rownames(table_resdim5_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") colnames(table_resdim5_scenario3) <- c("55+", "Other") chi_result_resdim5_scenario3 <- chisq.test(table_resdim5_scenario3) odds_ratio_resdim5_scenario3 <- oddsratio(table_resdim5_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim5_scenario3, caption = "Contingency Table: Age vs. Impact of AMR on personal health and that of their family (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_resdim5_scenario3) print(odds_ratio_resdim5_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM6= I am not at risk of getting an antibiotic-resistant infection, as long as I take my antibiotics correctly Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Agree vs. Strongly Disagree df_filtered_resdim6_scenario1 <- df[df$RESDIM6 %in% c(1, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim6_scenario1$Age_Group <- ifelse(df_filtered_resdim6_scenario1$AGE %in% c(5, 6), "55+", "Other") table_resdim6_scenario1 <- table(df_filtered_resdim6_scenario1$RESDIM6, df_filtered_resdim6_scenario1$Age_Group) rownames(table_resdim6_scenario1) <- c("Strongly Agree", "Strongly Disagree") colnames(table_resdim6_scenario1) <- c("55+", "Other") chi_result_resdim6_scenario1 <- chisq.test(table_resdim6_scenario1) odds_ratio_resdim6_scenario1 <- oddsratio(table_resdim6_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim6_scenario1, caption = "Contingency Table: Age vs. Perception of Risk of Antibiotic-Resistant Infection (Strongly Disagree vs. Strongly Agree)")) print(chi_result_resdim6_scenario1) print(odds_ratio_resdim6_scenario1) print(table_resdim6_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim6_scenario2 <- df[df$RESDIM6 %in% c(1, 2) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim6_scenario2$Age_Group <- ifelse(df_filtered_resdim6_scenario2$AGE %in% c(5, 6), "55+", "Other") table_resdim6_scenario2 <- table(df_filtered_resdim6_scenario2$RESDIM6, df_filtered_resdim6_scenario2$Age_Group) rownames(table_resdim6_scenario2) <- c("Strongly Disagree", "Neither Agree Nor Disagree") colnames(table_resdim6_scenario2) <- c("55+", "Other") chi_result_resdim6_scenario2 <- chisq.test(table_resdim6_scenario2) odds_ratio_resdim6_scenario2 <- oddsratio(table_resdim6_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim6_scenario2, caption = "Contingency Table: Age vs. Perception of Risk of Antibiotic-Resistant Infection (Strongly Disagree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim6_scenario2) print(odds_ratio_resdim6_scenario2) # Scenario 3: Strongly Agree + Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim6_scenario3 <- df[df$RESDIM6 %in% c(1, 2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_resdim6_scenario3$Age_Group <- ifelse(df_filtered_resdim6_scenario3$AGE %in% c(5, 6), "55+", "Other") df_filtered_resdim6_scenario3$Agree_Neither <- df_filtered_resdim6_scenario3$RESDIM6 %in% c(2, 3) table_resdim6_scenario3 <- table(df_filtered_resdim6_scenario3$Agree_Neither, df_filtered_resdim6_scenario3$Age_Group) rownames(table_resdim6_scenario3) <- c("Strongly Disagree", "Strongly Agree + Neither") colnames(table_resdim6_scenario3) <- c("55+", "Other") chi_result_resdim6_scenario3 <- chisq.test(table_resdim6_scenario3) odds_ratio_resdim6_scenario3 <- oddsratio(table_resdim6_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim6_scenario3, caption = "Contingency Table: Age vs. Perception of Risk of Antibiotic-Resistant Infection (Strongly Disagree vs. Strongly Agree + Neither Agree Nor Disagree)")) print(chi_result_resdim6_scenario3) print(odds_ratio_resdim6_scenario3) ############################################### Comparasions by Level of education (Higher education vs Other) ####################################### ###CUSIN1 (I wash my hands before cooking (No= 9.4%)) # Load the Database_simplified dataframe Database_simplified <- read_excel("C:/Database_simplified.xlsx") # Filter DataFrame to include only the relevant education levels and the CUSIN1 variable df_filtered <- Database_simplified[Database_simplified$CUSIN1 %in% c(0, 1) & Database_simplified$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] # Create a binary variable for NIVSCOL df_filtered$Education_Level <- ifelse(df_filtered$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") # Create the Contingency Table table <- table(df_filtered$CUSIN1, df_filtered$Education_Level) # Rename rows and columns of the table rownames(table) <- c("CUSIN1 (Yes)", "CUSIN1 (No)") # Print the contingency table using knitr kable(table, caption = "Contingency Table: Education vs. Hand Washing") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) --------------------------------------------------------------------------------------------------- ##CUSIN2 (After handling raw food (meat and vegetables), I wash my hands with soap (No= 15.1%) # Filter DataFrame to include only the relevant education levels and the CUSIN2 variable df_filtered <- Database_simplified[Database_simplified$CUSIN2 %in% c(0, 1) & Database_simplified$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] # Create a binary variable for NIVSCOL df_filtered$Education_Level <- ifelse(df_filtered$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") # Create the Contingency Table table <- table(df_filtered$CUSIN2, df_filtered$Education_Level) # Rename rows and columns of the table rownames(table) <- c("CUSIN2 (Yes)", "CUSIN2 (No)") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Education vs. After handling raw food (meat and vegetables), I wash my hands with soap") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------ ##CUSIN3 (I use the same kitchen utensils for handling raw and ready-to-eat foods (Yes=25.8%)) # Filter DataFrame to include only the relevant education levels and the CUSIN3 variable df_filtered <- Database_simplified[Database_simplified$CUSIN3 %in% c(0, 1) & Database_simplified$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] # Create a binary variable for NIVSCOL df_filtered$Education_Level <- ifelse(df_filtered$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") # Create the Contingency Table table <- table(df_filtered$CUSIN3, df_filtered$Education_Level) # Rename rows and columns of the table rownames(table) <- c("CUSIN3 (Yes)", "CUSIN3 (No)") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Education vs. I use the same kitchen utensils for handling raw and ready-to-eat foods") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------- ##CUSIN4 (I wash kitchen utensils that have been used for raw food before using them to prepare other foods (No=16.8%)) # Filter DataFrame to include only the relevant education levels and the CUSIN4 variable df_filtered <- Database_simplified[Database_simplified$CUSIN4 %in% c(0, 1) & Database_simplified$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] # Create a binary variable for NIVSCOL df_filtered$Education_Level <- ifelse(df_filtered$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") # Create the Contingency Table table <- table(df_filtered$CUSIN4, df_filtered$Education_Level) # Rename rows and columns of the table rownames(table) <- c("CUSIN4 (Yes)", "CUSIN4 (No)") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Education Level vs. Washing Kitchen Utensils Used for Raw Food Before Using Them for Other Foods") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------- ##CUSIN5 (I wash fruits and vegetables before eating them (No=20.7%)) # Filter DataFrame to include only the relevant education levels and the CUSIN5 variable df_filtered <- Database_simplified[Database_simplified$CUSIN5 %in% c(0, 1) & Database_simplified$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] # Create a binary variable for NIVSCOL df_filtered$Education_Level <- ifelse(df_filtered$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") # Create the Contingency Table table <- table(df_filtered$CUSIN5, df_filtered$Education_Level) # Rename rows and columns of the table rownames(table) <- c("CUSIN5 (Yes)", "CUSIN5 (No)") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Education Level vs. Washing Fruits and Vegetables Before Eating Them") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------- ##CUSIN6 (I wash my hands before eating (No=21.5)) # Filter DataFrame to include only the relevant education levels and the CUSIN6 variable df_filtered <- Database_simplified[Database_simplified$CUSIN6 %in% c(0, 1) & Database_simplified$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] # Create a binary variable for NIVSCOL df_filtered$Education_Level <- ifelse(df_filtered$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") # Create the Contingency Table table <- table(df_filtered$CUSIN6, df_filtered$Education_Level) # Rename rows and columns of the table rownames(table) <- c("CUSIN6 (Yes)", "CUSIN6 (No)") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Education Level vs. Washing Hands Before Eating") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) --------------------------------------------------------------------------------------------------------------------- ##PRESCATB1 When you get a prescription for antibiotics, do you follow the recommended ##length of treatment and daily dosage? (No=4.2%) (Sometimes=9.6%) (No+Sometimes=13.8%) # Read the database Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) df <- Database_simplified ############### 1st scenario= No df_filtered_prescatb1 <- df[df$PRESCATB1 %in% c(0, 1) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_prescatb1$Education_Level <- ifelse(df_filtered_prescatb1$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_prescatb1 <- table(df_filtered_prescatb1$PRESCATB1, df_filtered_prescatb1$Education_Level) # Add descriptive labels to the rows and columns rownames(table_prescatb1) <- c("Yes", "No") # Perform the Chi-Squared test chi_result_prescatb1 <- chisq.test(table_prescatb1) # Calculate the odds ratio and confidence interval odds_ratio_prescatb1 <- oddsratio(table_prescatb1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_prescatb1, caption = "Contingency Table: Age vs. Following Prescription for Antibiotics")) # Print the results of the Chi-Squared test print(chi_result_prescatb1) # Print the odds ratio and confidence interval print(odds_ratio_prescatb1) ################## 2nd scenario= Sometimes df_filtered_prescatb1_sometimes <- df[df$PRESCATB1 %in% c(0, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_prescatb1_sometimes$Education_Level <- ifelse(df_filtered_prescatb1_sometimes$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_prescatb1_sometimes <- table(df_filtered_prescatb1_sometimes$PRESCATB1, df_filtered_prescatb1_sometimes$Education_Level) # Add descriptive labels to the rows and columns rownames(table_prescatb1_sometimes) <- c("Yes", "Sometimes") # Perform the Chi-Squared test chi_result_prescatb1_sometimes <- chisq.test(table_prescatb1_sometimes) # Calculate the odds ratio and confidence interval odds_ratio_prescatb1_sometimes <- oddsratio(table_prescatb1_sometimes, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_prescatb1_sometimes, caption = "Contingency Table: Age vs. Following Prescription for Antibiotics Sometimes")) # Print the results of the Chi-Squared test print(chi_result_prescatb1_sometimes) # Print the odds ratio and confidence interval print(odds_ratio_prescatb1_sometimes) ################## 3rd scenario= No+Sometimes df_filtered_prescatb1_combined <- df[df$PRESCATB1 %in% c(0, 1, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_prescatb1_combined$Education_Level <- ifelse(df_filtered_prescatb1_combined$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") df_filtered_prescatb1_combined$No_Sometimes <- df_filtered_prescatb1_combined$PRESCATB1 %in% c(1, 3) table_prescatb1_combined <- table(df_filtered_prescatb1_combined$No_Sometimes, df_filtered_prescatb1_combined$Education_Level) # Adjust the table to have 'Yes' and 'No+Sometimes' as row names rownames(table_prescatb1_combined) <- c("Yes", "No_Sometimes") # Perform the Chi-Squared test chi_result_prescatb1_combined <- chisq.test(table_prescatb1_combined) # Calculate the odds ratio and confidence interval odds_ratio_prescatb1_combined <- oddsratio(table_prescatb1_combined, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_prescatb1_combined, caption = "Contingency Table: Age vs. Following Prescription for Antibiotics (Yes vs. No+Sometimes)")) # Print the results of the Chi-Squared test print(chi_result_prescatb1_combined) # Print the odds ratio and confidence interval print(odds_ratio_prescatb1_combined) --------------------------------------------------------------------------------------------------------------------- ##ARRETATB Do you stop taking antibiotics when symptoms start to disappear? ##(Always=7.3%) (Sometimes=20.4%) (Always+Sometimes=27.7%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) df <- Database_simplified ############### 1st scenario= Always df_filtered_arretatb <- df[df$ARRETATB %in% c(0, 1) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_arretatb$Education_Level <- ifelse(df_filtered_arretatb$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_arretatb <- table(df_filtered_arretatb$ARRETATB, df_filtered_arretatb$Education_Level) # Add descriptive labels to the rows and columns rownames(table_arretatb) <- c("Always", "Never") # Perform the Chi-Squared test chi_result_arretatb <- chisq.test(table_arretatb) # Calculate the odds ratio and confidence interval odds_ratio_arretatb <- oddsratio(table_arretatb, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_arretatb, caption = "Contingency Table: Age vs. Stopping Antibiotics Always vs. Never")) # Print the results of the Chi-Squared test print(chi_result_arretatb) # Print the odds ratio and confidence interval print(odds_ratio_arretatb) ################# 2nd scenario: Sometimes df_filtered_arretatb_sometimes <- df[df$ARRETATB %in% c(1, 2) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_arretatb_sometimes$Education_Level <- ifelse(df_filtered_arretatb_sometimes$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_arretatb_sometimes <- table(df_filtered_arretatb_sometimes$ARRETATB == 2, df_filtered_arretatb_sometimes$Education_Level) # Add descriptive labels to the rows and columns rownames(table_arretatb_sometimes) <- c("Never", "Sometimes") # Perform the Chi-Squared test chi_result_arretatb_sometimes <- chisq.test(table_arretatb_sometimes) # Calculate the odds ratio and confidence interval odds_ratio_arretatb_sometimes <- oddsratio(table_arretatb_sometimes, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_arretatb_sometimes, caption = "Contingency Table: Age vs. Stopping Antibiotics Sometimes vs. Never")) # Print the results of the Chi-Squared test print(chi_result_arretatb_sometimes) # Print the odds ratio and confidence interval print(odds_ratio_arretatb_sometimes) ############### #3rd scenario= Sometimes+Always df_filtered_arretatb_combined <- df[df$ARRETATB %in% c(0, 1, 2) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_arretatb_combined$Education_Level <- ifelse(df_filtered_arretatb_combined$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") df_filtered_arretatb_combined$Sometimes_Always <- df_filtered_arretatb_combined$ARRETATB %in% c(0, 2) table_arretatb_combined <- table(df_filtered_arretatb_combined$Sometimes_Always, df_filtered_arretatb_combined$Education_Level) # Add descriptive labels to the rows and columns rownames(table_arretatb_combined) <- c("Never", "Sometimes_Always") # Perform the Chi-Squared test chi_result_arretatb_combined <- chisq.test(table_arretatb_combined) # Calculate the odds ratio and confidence interval odds_ratio_arretatb_combined <- oddsratio(table_arretatb_combined, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_arretatb_combined, caption = "Contingency Table: Age vs. Stopping Antibiotics (Sometimes+Always vs. Never)")) # Print the results of the Chi-Squared test print(chi_result_arretatb_combined) # Print the odds ratio and confidence interval print(odds_ratio_arretatb_combined) --------------------------------------------------------------------------------------------------------------------- ##ATBORAL1 Have you ever taken an oral antibiotic treatment (by mouth) without a medical prescription? (Yes=12.3%) # Filter DataFrame for the relevant education levels and ATBORAL1 variable df_filtered_atboral <- df[df$ATBORAL1 %in% c(0, 1) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_atboral$Education_Level <- ifelse(df_filtered_atboral$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_atboral <- table(df_filtered_atboral$ATBORAL1, df_filtered_atboral$Education_Level) # Add descriptive labels to the rows and columns rownames(table_atboral) <- c("Yes", "No") # Perform the Chi-Squared test chi_result_atboral <- chisq.test(table_atboral) # Calculate the odds ratio and confidence interval odds_ratio_atboral <- oddsratio(table_atboral, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atboral, caption = "Contingency Table: Education Level vs. Taking Oral Antibiotics Without Prescription (Yes vs. No)")) # Print the results of the Chi-Squared test print(chi_result_atboral) # Print the odds ratio and confidence interval print(odds_ratio_atboral) -------------------------------------------------------------------------------------------------------- ### ATBANI1 I can exchange resistant bacteria with my pet (False=23.2%) # Filter DataFrame for the relevant education levels and ATBANI1 variable df_filtered_atbani1 <- df[df$ATBANI1 %in% c(0, 1) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_atbani1$Education_Level <- ifelse(df_filtered_atbani1$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_atbani1 <- table(df_filtered_atbani1$ATBANI1, df_filtered_atbani1$Education_Level) # Add descriptive labels to the rows and columns rownames(table_atbani1) <- c("True", "False") # Perform the Chi-Squared test chi_result_atbani1 <- chisq.test(table_atbani1) # Calculate the odds ratio and confidence interval odds_ratio_atbani1 <- oddsratio(table_atbani1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani1, caption = "Contingency Table: Education Level vs. Exchanging Resistant Bacteria with Pets (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani1) # Print the odds ratio and confidence interval print(odds_ratio_atbani1) --------------------------------------------------------------------------------------------------------------------- ### ATBANI2=The use of antibiotics in livestock and crops can increase the #presence of resistant bacteria in the environment (False=14.7%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Filter DataFrame for the relevant education levels and ATBANI2 variable df_filtered_atbani2 <- df[df$ATBANI2 %in% c(0, 1) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_atbani2$Education_Level <- ifelse(df_filtered_atbani2$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_atbani2 <- table(df_filtered_atbani2$ATBANI2, df_filtered_atbani2$Education_Level) # Add descriptive labels to the rows and columns rownames(table_atbani2) <- c("True", "False") # Perform the Chi-Squared test chi_result_atbani2 <- chisq.test(table_atbani2) # Calculate the odds ratio and confidence interval odds_ratio_atbani2 <- oddsratio(table_atbani2, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani2, caption = "Contingency Table: Education Level vs. Antibiotics in Livestock and Crops Affecting Environment (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani2) # Print the odds ratio and confidence interval print(odds_ratio_atbani2) -------------------------------------------------------------------------------------------------------------------- ##### ATBANI3 The use of antibiotics in livestock and crops can affect me directly ##(I can get resistant bacteria in my body) (False=26.3%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) df <- Database_simplified # Filter DataFrame for the relevant education levels and ATBANI3 variable df_filtered_atbani3 <- df[df$ATBANI3 %in% c(0, 1) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_atbani3$Education_Level <- ifelse(df_filtered_atbani3$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_atbani3 <- table(df_filtered_atbani3$ATBANI3, df_filtered_atbani3$Education_Level) # Add descriptive labels to the rows and columns rownames(table_atbani3) <- c("True", "False") # Perform the Chi-Squared test chi_result_atbani3 <- chisq.test(table_atbani3) # Calculate the odds ratio and confidence interval odds_ratio_atbani3 <- oddsratio(table_atbani3, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani3, caption = "Contingency Table: Education Level vs. Antibiotics in Livestock and Crops Affecting Humans Directly (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani3) # Print the odds ratio and confidence interval print(odds_ratio_atbani3) ------------------------------------------------------------------------------------------------------------------- ##### ATBANI4 Resistant bacteria are only found in hospitals (True=10.8%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) df <- Database_simplified df_filtered_atbani4 <- df[df$ATBANI4 %in% c(0, 1) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_atbani4$Education_Level <- ifelse(df_filtered_atbani4$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_atbani4 <- table(df_filtered_atbani4$ATBANI4, df_filtered_atbani4$Education_Level) rownames(table_atbani4) <- c("True", "False") # Perform the Chi-Squared test chi_result_atbani4 <- chisq.test(table_atbani4) # Calculate the odds ratio and confidence interval odds_ratio_atbani4 <- oddsratio(table_atbani4, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani4, caption = "Contingency Table: Education Level vs. Resistant Bacteria Found Only in Hospitals (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani4) # Print the odds ratio and confidence interval print(odds_ratio_atbani4) ---------------------------------------------------------------------------------------------------------------------- #####RESATB1 Antibiotic resistance occurs when your body becomes resistant to antibiotics and they ##no longer work as well (True=58.3%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) df <- Database_simplified df_filtered_resatb1 <- df[df$RESATB1 %in% c(0, 1) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resatb1$Education_Level <- ifelse(df_filtered_resatb1$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_resatb1 <- table(df_filtered_resatb1$RESATB1, df_filtered_resatb1$Education_Level) rownames(table_resatb1) <- c("True", "False") # Perform the Chi-Squared test chi_result_resatb1 <- chisq.test(table_resatb1) # Calculate the odds ratio and confidence interval odds_ratio_resatb1 <- oddsratio(table_resatb1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb1, caption = "Contingency Table: Education Level vs. Understanding of Antibiotic Resistance (RESATB1: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb1) print(odds_ratio_resatb1) ------------------------------------------------------------------------------------------------------------------- #####RESATB2 Many infections are becoming increasingly resistant to antibiotic treatment (False=12.5%) # Load the database df <- Database_simplified df_filtered_resatb2 <- df[df$RESATB2 %in% c(0, 1) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resatb2$Education_Level <- ifelse(df_filtered_resatb2$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_resatb2 <- table(df_filtered_resatb2$RESATB2, df_filtered_resatb2$Education_Level) rownames(table_resatb2) <- c("True", "False") # Perform the Chi-Squared test chi_result_resatb2 <- chisq.test(table_resatb2) # Calculate the odds ratio and confidence interval odds_ratio_resatb2 <- oddsratio(table_resatb2, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb2, caption = "Contingency Table: Education Level vs. Perception of Increasing Infection Resistance (RESATB2: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb2) print(odds_ratio_resatb2) --------------------------------------------------------------------------------------------------------------------- #####RESATB3 If bacteria are resistant to antibiotics, it can be very difficult or impossible to treat the infections they cause (False=16.7%) # Load the database df <- Database_simplified df_filtered_resatb3 <- df[df$RESATB3 %in% c(0, 1) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resatb3$Education_Level <- ifelse(df_filtered_resatb3$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_resatb3 <- table(df_filtered_resatb3$RESATB3, df_filtered_resatb3$Education_Level) rownames(table_resatb3) <- c("True", "False") # Perform the Chi-Squared test chi_result_resatb3 <- chisq.test(table_resatb3) # Calculate the odds ratio and confidence interval odds_ratio_resatb3 <- oddsratio(table_resatb3, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb3, caption = "Contingency Table: Education Level vs. Perception of Difficulty Treating Infections (RESATB3: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb3) print(odds_ratio_resatb3) ---------------------------------------------------------------------------------------------------------------------- #####RESATB4 Antibiotic resistance is an issue that could affect me or my family (False=11.8%) # Load the database df <- Database_simplified df_filtered_resatb4 <- df[df$RESATB4 %in% c(0, 1) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resatb4$Education_Level <- ifelse(df_filtered_resatb4$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_resatb4 <- table(df_filtered_resatb4$RESATB4, df_filtered_resatb4$Education_Level) rownames(table_resatb4) <- c("True", "False") # Perform the Chi-Squared test chi_result_resatb4 <- chisq.test(table_resatb4) # Calculate the odds ratio and confidence interval odds_ratio_resatb4 <- oddsratio(table_resatb4, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb4, caption = "Contingency Table: Education Level vs. Perception of Antibiotic Resistance Affecting One's Family (RESATB4: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb4) print(odds_ratio_resatb4) --------------------------------------------------------------------------------------------------------------------- #####RESATB5 Antibiotic resistance is an issue in other countries but not here (True=9.9%) # Load the database df <- Database_simplified df_filtered_resatb5 <- df[df$RESATB5 %in% c(0, 1) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resatb5$Education_Level <- ifelse(df_filtered_resatb5$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_resatb5 <- table(df_filtered_resatb5$RESATB5, df_filtered_resatb5$Education_Level) rownames(table_resatb5) <- c("True", "False") # Perform the Chi-Squared test chi_result_resatb5 <- chisq.test(table_resatb5) # Calculate the odds ratio and confidence interval odds_ratio_resatb5 <- oddsratio(table_resatb5, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb5, caption = "Contingency Table: Education Level vs. Perception of Antibiotic Resistance as an Issue Only in Other Countries (RESATB5: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb5) print(odds_ratio_resatb5) --------------------------------------------------------------------------------------------------------------------- #####RESATB6 Antibiotic resistance is only a problem for people who take antibiotics regularly (True=17.5%) # Load the database df <- Database_simplified df_filtered_resatb6 <- df[df$RESATB6 %in% c(0, 1) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resatb6$Education_Level <- ifelse(df_filtered_resatb6$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_resatb6 <- table(df_filtered_resatb6$RESATB6, df_filtered_resatb6$Education_Level) rownames(table_resatb6) <- c("True", "False") # Perform the Chi-Squared test chi_result_resatb6 <- chisq.test(table_resatb6) # Calculate the odds ratio and confidence interval odds_ratio_resatb6 <- oddsratio(table_resatb6, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb6, caption = "Contingency Table: Education Level vs. Perception of Antibiotic Resistance as a Problem Only for Regular Antibiotic Users (RESATB6: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb6) print(odds_ratio_resatb6) --------------------------------------------------------------------------------------------------------------------- #####RESATB7 Bacteria that are resistant to antibiotics can be spread from person to person (False=20.2%) # Load the database df <- Database_simplified df_filtered_resatb7 <- df[df$RESATB7 %in% c(0, 1) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resatb7$Education_Level <- ifelse(df_filtered_resatb7$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_resatb7 <- table(df_filtered_resatb7$RESATB7, df_filtered_resatb7$Education_Level) rownames(table_resatb7) <- c("True", "False") # Perform the Chi-Squared test chi_result_resatb7 <- chisq.test(table_resatb7) # Calculate the odds ratio and confidence interval odds_ratio_resatb7 <- oddsratio(table_resatb7, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb7, caption = "Contingency Table: Education Level vs. Perception of Bacteria Transmission Person to Person (RESATB7: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb7) print(odds_ratio_resatb7) -------------------------------------------------------------------------------------------------------------------- #####RESATB8 Antibiotic-resistant infections could make medical procedures like surgery, organ transplants, ##and cancer treatment much more dangerous (False=12.0%) # Load the database df <- Database_simplified df_filtered_resatb8 <- df[df$RESATB8 %in% c(0, 1) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resatb8$Education_Level <- ifelse(df_filtered_resatb8$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_resatb8 <- table(df_filtered_resatb8$RESATB8, df_filtered_resatb8$Education_Level) rownames(table_resatb8) <- c("True", "False") # Perform the Chi-Squared test chi_result_resatb8 <- chisq.test(table_resatb8) # Calculate the odds ratio and confidence interval odds_ratio_resatb8 <- oddsratio(table_resatb8, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb8, caption = "Contingency Table: Education Level vs. Perception of Antibiotic-Resistant Infections and Medical Procedures (RESATB8: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb8) print(odds_ratio_resatb8) -------------------------------------------------------------------------------------------------------------------- # ATBRGL1 Farmers should give fewer antibiotics to food-producing animals ##################### 1st scenario (Strongly desagree=8.68%) vs. Strongly Agree Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load dataframe df <- Database_simplified df_filtered_atbrgl1_scenario1 <- df[df$ATBRGL1 %in% c(1, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_atbrgl1_scenario1$Education_Level <- ifelse(df_filtered_atbrgl1_scenario1$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_atbrgl1_scenario1 <- table(df_filtered_atbrgl1_scenario1$ATBRGL1, df_filtered_atbrgl1_scenario1$Education_Level) rownames(table_atbrgl1_scenario1) <- c("Strongly Disagree", "Strongly Agree") # Perform the Chi-Squared test chi_result_atbrgl1_scenario1 <- chisq.test(table_atbrgl1_scenario1) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl1_scenario1 <- oddsratio(table_atbrgl1_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl1_scenario1, caption = "Contingency Table: Education Level vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Strongly Disagree)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_atbrgl1_scenario1) print(odds_ratio_atbrgl1_scenario1) ############################# 2nd scenario Farmers should give fewer antibiotics to ##food-producing animals (Neither agree nor desagree=22.6%) vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_atbrgl1_scenario2 <- df[df$ATBRGL1 %in% c(2, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_atbrgl1_scenario2$Education_Level <- ifelse(df_filtered_atbrgl1_scenario2$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_atbrgl1_scenario2 <- table(df_filtered_atbrgl1_scenario2$ATBRGL1, df_filtered_atbrgl1_scenario2$Education_Level) rownames(table_atbrgl1_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") # Perform the Chi-Squared test chi_result_atbrgl1_scenario2 <- chisq.test(table_atbrgl1_scenario2) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl1_scenario2 <- oddsratio(table_atbrgl1_scenario2, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl1_scenario2, caption = "Contingency Table: Education Level vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Neither Agree Nor Disagree)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_atbrgl1_scenario2) print(odds_ratio_atbrgl1_scenario2) ############################# 3rd scenario (Strongly desagree + Neither agree nor desagree=31.28%) vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_atbrgl1_scenario3 <- df[df$ATBRGL1 %in% c(1, 2, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_atbrgl1_scenario3$Education_Level <- ifelse(df_filtered_atbrgl1_scenario3$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") df_filtered_atbrgl1_scenario3$Disagree_Neither <- df_filtered_atbrgl1_scenario3$ATBRGL1 %in% c(1, 2) table_atbrgl1_scenario3 <- table(df_filtered_atbrgl1_scenario3$Disagree_Neither, df_filtered_atbrgl1_scenario3$Education_Level) rownames(table_atbrgl1_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") # Perform the Chi-Squared test chi_result_atbrgl1_scenario3 <- chisq.test(table_atbrgl1_scenario3) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl1_scenario3 <- oddsratio(table_atbrgl1_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl1_scenario3, caption = "Contingency Table: Education Level vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Strongly Disagree + Neither)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_atbrgl1_scenario3) print(odds_ratio_atbrgl1_scenario3) -------------------------------------------------------------------------------------------------------------------- # ATBRGL2 People should not keep antibiotics and use them later for other illnesses ############################# 1st scenario Strongly desagree vs. Strongly Agree Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the database df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_atbrgl2_scenario1 <- df[df$ATBRGL2 %in% c(1, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_atbrgl2_scenario1$Education_Level <- ifelse(df_filtered_atbrgl2_scenario1$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_atbrgl2_scenario1 <- table(df_filtered_atbrgl2_scenario1$ATBRGL2, df_filtered_atbrgl2_scenario1$Education_Level) rownames(table_atbrgl2_scenario1) <- c("Strongly Disagree", "Strongly Agree") # Perform Chi-Squared test chi_result_atbrgl2_scenario1 <- chisq.test(table_atbrgl2_scenario1) # Calculate odds ratio and confidence interval odds_ratio_atbrgl2_scenario1 <- oddsratio(table_atbrgl2_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl2_scenario1, caption = "Contingency Table: Education Level vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl2_scenario1) print(odds_ratio_atbrgl2_scenario1) ############################# 2nd scenario Neither agree nor desagree vs. Strongly Agree # Filter for 'Strongly Agree' (3) and 'Neither Agree Nor Disagree' (2) responses for ATBRGL2 df_filtered_atbrgl2_scenario2 <- df[df$ATBRGL2 %in% c(2, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_atbrgl2_scenario2$Education_Level <- ifelse(df_filtered_atbrgl2_scenario2$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_atbrgl2_scenario2 <- table(df_filtered_atbrgl2_scenario2$ATBRGL2, df_filtered_atbrgl2_scenario2$Education_Level) rownames(table_atbrgl2_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") # Perform Chi-Squared test chi_result_atbrgl2_scenario2 <- chisq.test(table_atbrgl2_scenario2) # Calculate odds ratio and confidence interval odds_ratio_atbrgl2_scenario2 <- oddsratio(table_atbrgl2_scenario2, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl2_scenario2, caption = "Contingency Table: Education Level vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl2_scenario2) print(odds_ratio_atbrgl2_scenario2) ############################# 3rd scenario Neither agree nor desagree + Stringly Disagree vs. Strongly Agree df_filtered_atbrgl2_scenario3 <- df[df$ATBRGL2 %in% c(1, 2, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_atbrgl2_scenario3$Education_Level <- ifelse(df_filtered_atbrgl2_scenario3$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") df_filtered_atbrgl2_scenario3$Disagree_Neither <- df_filtered_atbrgl2_scenario3$ATBRGL2 %in% c(1, 2) table_atbrgl2_scenario3 <- table(df_filtered_atbrgl2_scenario3$Disagree_Neither, df_filtered_atbrgl2_scenario3$Education_Level) rownames(table_atbrgl2_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") # Perform the Chi-Squared test chi_result_atbrgl2_scenario3 <- chisq.test(table_atbrgl2_scenario3) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl2_scenario3 <- oddsratio(table_atbrgl2_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl2_scenario3, caption = "Contingency Table: Education Level vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl2_scenario3) print(odds_ratio_atbrgl2_scenario3) -------------------------------------------------------------------------------------------------------------------- # ATBRGL3 Parents should make sure all of their children’s vaccinations are up-to-date Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) ####1st scenario # Load dataframe df <- Database_simplified df_filtered_atbrgl3_scenario1 <- df[df$ATBRGL3 %in% c(1, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_atbrgl3_scenario1$Education_Level <- ifelse(df_filtered_atbrgl3_scenario1$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_atbrgl3_scenario1 <- table(df_filtered_atbrgl3_scenario1$ATBRGL3, df_filtered_atbrgl3_scenario1$Education_Level) rownames(table_atbrgl3_scenario1) <- c("Strongly Disagree", "Strongly Agree") # Perform Chi-Squared test chi_result_atbrgl3_scenario1 <- chisq.test(table_atbrgl3_scenario1) # Calculate odds ratio and confidence interval odds_ratio_atbrgl3_scenario1 <- oddsratio(table_atbrgl3_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl3_scenario1, caption = "Contingency Table: Education Level vs. Opinion on Children's Vaccinations (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl3_scenario1) print(odds_ratio_atbrgl3_scenario1) ### 2nd Scenario df_filtered_atbrgl3_scenario2 <- df[df$ATBRGL3 %in% c(2, 3) & df$AGE %in% c(1, 2, 3, 4, 5, 6), ] df_filtered_atbrgl3_scenario2 <- df[df$ATBRGL3 %in% c(2, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_atbrgl3_scenario2$Education_Level <- ifelse(df_filtered_atbrgl3_scenario2$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_atbrgl3_scenario2 <- table(df_filtered_atbrgl3_scenario2$ATBRGL3, df_filtered_atbrgl3_scenario2$Education_Level) rownames(table_atbrgl3_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") # Perform Chi-Squared test chi_result_atbrgl3_scenario2 <- chisq.test(table_atbrgl3_scenario2) # Calculate odds ratio and confidence interval odds_ratio_atbrgl3_scenario2 <- oddsratio(table_atbrgl3_scenario2, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl3_scenario2, caption = "Contingency Table: Education Level vs. Opinion on Children's Vaccinations (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl3_scenario2) print(odds_ratio_atbrgl3_scenario2) ## 3rd scenario df_filtered_atbrgl3_scenario3 <- df[df$ATBRGL3 %in% c(1, 2, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_atbrgl3_scenario3$Education_Level <- ifelse(df_filtered_atbrgl3_scenario3$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") df_filtered_atbrgl3_scenario3$Disagree_Neither <- df_filtered_atbrgl3_scenario3$ATBRGL3 %in% c(1, 2) table_atbrgl3_scenario3 <- table(df_filtered_atbrgl3_scenario3$Disagree_Neither, df_filtered_atbrgl3_scenario3$Education_Level) rownames(table_atbrgl3_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") # Perform the Chi-Squared test chi_result_atbrgl3_scenario3 <- chisq.test(table_atbrgl3_scenario3) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl3_scenario3 <- oddsratio(table_atbrgl3_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl3_scenario3, caption = "Contingency Table: Education Level vs. Opinion on Children's Vaccinations (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl3_scenario3) print(odds_ratio_atbrgl3_scenario3) --------------------------------------------------------------------------------------------------------------------- # ATBRGL4 People should wash their hands regularly Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_atbrgl4_scenario1 <- df[df$ATBRGL4 %in% c(1, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_atbrgl4_scenario1$Education_Level <- ifelse(df_filtered_atbrgl4_scenario1$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_atbrgl4_scenario1 <- table(df_filtered_atbrgl4_scenario1$ATBRGL4, df_filtered_atbrgl4_scenario1$Education_Level) rownames(table_atbrgl4_scenario1) <- c("Strongly Disagree", "Strongly Agree") chi_result_atbrgl4_scenario1 <- chisq.test(table_atbrgl4_scenario1) odds_ratio_atbrgl4_scenario1 <- oddsratio(table_atbrgl4_scenario1, conf.level = 0.95)$measure print(kable(table_atbrgl4_scenario1, caption = "Contingency Table: Education Level vs. Hand Washing Importance (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl4_scenario1) print(odds_ratio_atbrgl4_scenario1) ## Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl4_scenario2 <- df[df$ATBRGL4 %in% c(2, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_atbrgl4_scenario2$Education_Level <- ifelse(df_filtered_atbrgl4_scenario2$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_atbrgl4_scenario2 <- table(df_filtered_atbrgl4_scenario2$ATBRGL4, df_filtered_atbrgl4_scenario2$Education_Level) rownames(table_atbrgl4_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") chi_result_atbrgl4_scenario2 <- chisq.test(table_atbrgl4_scenario2) odds_ratio_atbrgl4_scenario2 <- oddsratio(table_atbrgl4_scenario2, conf.level = 0.95)$measure print(kable(table_atbrgl4_scenario2, caption = "Contingency Table: Education Level vs. Hand Washing Importance (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl4_scenario2) print(odds_ratio_atbrgl4_scenario2) ## Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl4_scenario3 <- df[df$ATBRGL4 %in% c(1, 2, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_atbrgl4_scenario3$Education_Level <- ifelse(df_filtered_atbrgl4_scenario3$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") df_filtered_atbrgl4_scenario3$Disagree_Neither <- df_filtered_atbrgl4_scenario3$ATBRGL4 %in% c(1, 2) table_atbrgl4_scenario3 <- table(df_filtered_atbrgl4_scenario3$Disagree_Neither, df_filtered_atbrgl4_scenario3$Education_Level) rownames(table_atbrgl4_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") chi_result_atbrgl4_scenario3 <- chisq.test(table_atbrgl4_scenario3) odds_ratio_atbrgl4_scenario3 <- oddsratio(table_atbrgl4_scenario3, conf.level = 0.95)$measure print(kable(table_atbrgl4_scenario3, caption = "Contingency Table: Education Level vs. Hand Washing Importance (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl4_scenario3) print(odds_ratio_atbrgl4_scenario3) --------------------------------------------------------------------------------------------------------------------- #ATBRGL5 Doctors should only prescribe antibiotics when they are needed Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_atbrgl5_scenario1 <- df[df$ATBRGL5 %in% c(1, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_atbrgl5_scenario1$Education_Level <- ifelse(df_filtered_atbrgl5_scenario1$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_atbrgl5_scenario1 <- table(df_filtered_atbrgl5_scenario1$ATBRGL5, df_filtered_atbrgl5_scenario1$Education_Level) rownames(table_atbrgl5_scenario1) <- c("Strongly Disagree", "Strongly Agree") chi_result_atbrgl5_scenario1 <- chisq.test(table_atbrgl5_scenario1) odds_ratio_atbrgl5_scenario1 <- oddsratio(table_atbrgl5_scenario1, conf.level = 0.95)$measure print(kable(table_atbrgl5_scenario1, caption = "Contingency Table: Education Level vs. Antibiotic Prescription Necessity (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl5_scenario1) print(odds_ratio_atbrgl5_scenario1) ## Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl5_scenario2 <- df[df$ATBRGL5 %in% c(2, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_atbrgl5_scenario2$Education_Group <- ifelse(df_filtered_atbrgl5_scenario2$NIVSCOL %in% c(7, 8), "Higher Education", "Others") table_atbrgl5_scenario2 <- table(df_filtered_atbrgl5_scenario2$ATBRGL5, df_filtered_atbrgl5_scenario2$Education_Group) rownames(table_atbrgl5_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") chi_result_atbrgl5_scenario2 <- chisq.test(table_atbrgl5_scenario2) odds_ratio_atbrgl5_scenario2 <- oddsratio(table_atbrgl5_scenario2, conf.level = 0.95)$measure print(kable(table_atbrgl5_scenario2, caption = "Contingency Table: Education Level vs. Antibiotic Prescription Necessity (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl5_scenario2) print(odds_ratio_atbrgl5_scenario2) ## Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl5_scenario3 <- df[df$ATBRGL5 %in% c(1, 2, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_atbrgl5_scenario3$Education_Group <- ifelse(df_filtered_atbrgl5_scenario3$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") df_filtered_atbrgl5_scenario3$Disagree_Neither <- df_filtered_atbrgl5_scenario3$ATBRGL5 %in% c(1, 2) table_atbrgl5_scenario3 <- table(df_filtered_atbrgl5_scenario3$Disagree_Neither, df_filtered_atbrgl5_scenario3$Education_Group) rownames(table_atbrgl5_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") chi_result_atbrgl5_scenario3 <- chisq.test(table_atbrgl5_scenario3) odds_ratio_atbrgl5_scenario3 <- oddsratio(table_atbrgl5_scenario3, conf.level = 0.95)$measure print(kable(table_atbrgl5_scenario3, caption = "Contingency Table: Education Level vs. Antibiotic Prescription Necessity (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl5_scenario3) print(odds_ratio_atbrgl5_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##ATBRGL6= People should only use antibiotics when prescribed by a doctor or nurse Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_atbrgl6_scenario1 <- df[df$ATBRGL6 %in% c(1, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_atbrgl6_scenario1$Education_Group <- ifelse(df_filtered_atbrgl6_scenario1$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_atbrgl6_scenario1 <- table(df_filtered_atbrgl6_scenario1$ATBRGL6, df_filtered_atbrgl6_scenario1$Education_Group) rownames(table_atbrgl6_scenario1) <- c("Strongly Disagree", "Strongly Agree") chi_result_atbrgl6_scenario1 <- chisq.test(table_atbrgl6_scenario1) odds_ratio_atbrgl6_scenario1 <- oddsratio(table_atbrgl6_scenario1, conf.level = 0.95)$measure print(kable(table_atbrgl6_scenario1, caption = "Contingency Table: Education Level vs. Antibiotic only when prescribed (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl6_scenario1) print(odds_ratio_atbrgl6_scenario1) ## Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl6_scenario2 <- df[df$ATBRGL6 %in% c(2, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_atbrgl6_scenario2$Education_Group <- ifelse(df_filtered_atbrgl6_scenario2$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_atbrgl6_scenario2 <- table(df_filtered_atbrgl6_scenario2$ATBRGL6, df_filtered_atbrgl6_scenario2$Education_Group) rownames(table_atbrgl6_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") chi_result_atbrgl6_scenario2 <- chisq.test(table_atbrgl6_scenario2) odds_ratio_atbrgl6_scenario2 <- oddsratio(table_atbrgl6_scenario2, conf.level = 0.95)$measure print(kable(table_atbrgl6_scenario2, caption = "Contingency Table: Education Level vs. Antibiotic only when prescribed (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl6_scenario2) print(odds_ratio_atbrgl6_scenario2) ## Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_atbrgl6_scenario3 <- df[df$ATBRGL6 %in% c(1, 2, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_atbrgl6_scenario3$Education_Group <- ifelse(df_filtered_atbrgl6_scenario3$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") df_filtered_atbrgl6_scenario3$Disagree_Neither <- df_filtered_atbrgl6_scenario3$ATBRGL6 %in% c(1, 2) table_atbrgl6_scenario3 <- table(df_filtered_atbrgl6_scenario3$Disagree_Neither, df_filtered_atbrgl6_scenario3$Education_Group) rownames(table_atbrgl6_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") chi_result_atbrgl6_scenario3 <- chisq.test(table_atbrgl6_scenario3) odds_ratio_atbrgl6_scenario3 <- oddsratio(table_atbrgl6_scenario3, conf.level = 0.95)$measure print(kable(table_atbrgl6_scenario3, caption = "Contingency Table: Education Level vs. Antibiotic only when prescribed (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl6_scenario3) print(odds_ratio_atbrgl6_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM1= Antibiotic resistance is one of the biggest problems the world faces Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_resdim1_scenario1 <- df[df$RESDIM1 %in% c(1, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resdim1_scenario1$Education_Group <- ifelse(df_filtered_resdim1_scenario1$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_resdim1_scenario1 <- table(df_filtered_resdim1_scenario1$RESDIM1, df_filtered_resdim1_scenario1$Education_Group) rownames(table_resdim1_scenario1) <- c("Strongly Disagree", "Strongly Agree") chi_result_resdim1_scenario1 <- chisq.test(table_resdim1_scenario1) odds_ratio_resdim1_scenario1 <- oddsratio(table_resdim1_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim1_scenario1, caption = "Contingency Table: Education Level vs. Perception of Antibiotic Resistance as a Global Problem (Strongly Agree vs. Strongly Disagree)")) print(chi_result_resdim1_scenario1) print(odds_ratio_resdim1_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim1_scenario2 <- df[df$RESDIM1 %in% c(2, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resdim1_scenario2$Education_Group <- ifelse(df_filtered_resdim1_scenario2$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_resdim1_scenario2 <- table(df_filtered_resdim1_scenario2$RESDIM1, df_filtered_resdim1_scenario2$Education_Group) rownames(table_resdim1_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") chi_result_resdim1_scenario2 <- chisq.test(table_resdim1_scenario2) odds_ratio_resdim1_scenario2 <- oddsratio(table_resdim1_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim1_scenario2, caption = "Contingency Table: Education Level vs. Perception of Antibiotic Resistance as a Global Problem (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim1_scenario2) print(odds_ratio_resdim1_scenario2) # Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim1_scenario3 <- df[df$RESDIM1 %in% c(1, 2, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resdim1_scenario3$Education_Group <- ifelse(df_filtered_resdim1_scenario3$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") df_filtered_resdim1_scenario3$Disagree_Neither <- df_filtered_resdim1_scenario3$RESDIM1 %in% c(1, 2) table_resdim1_scenario3 <- table(df_filtered_resdim1_scenario3$Disagree_Neither, df_filtered_resdim1_scenario3$Education_Group) rownames(table_resdim1_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") chi_result_resdim1_scenario3 <- chisq.test(table_resdim1_scenario3) odds_ratio_resdim1_scenario3 <- oddsratio(table_resdim1_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim1_scenario3, caption = "Contingency Table: Education Level vs. Perception of Antibiotic Resistance as a Global Problem (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_resdim1_scenario3) print(odds_ratio_resdim1_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM2= Medical experts will solve the problem of antibiotic resistance before it becomes too serious Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Load the Database_simplified dataframe df <- read_excel("C:/Database_simplified.xlsx") # Scenario 1: Strongly Agree vs. Strongly Disagree df_filtered_resdim2_scenario1 <- df[df$RESDIM2 %in% c(1, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resdim2_scenario1$Education_Group <- ifelse(df_filtered_resdim2_scenario1$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_resdim2_scenario1 <- table(df_filtered_resdim2_scenario1$RESDIM2, df_filtered_resdim2_scenario1$Education_Group) rownames(table_resdim2_scenario1) <- c("Strongly Disagree", "Strongly Agree") chi_result_resdim2_scenario1 <- chisq.test(table_resdim2_scenario1) odds_ratio_resdim2_scenario1 <- oddsratio(table_resdim2_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim2_scenario1, caption = "Contingency Table: Education Level vs. Belief in Solving Antibiotic Resistance (Strongly Disagree vs. Strongly Agree)")) print(chi_result_resdim2_scenario1) print(odds_ratio_resdim2_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim2_scenario2 <- df[df$RESDIM2 %in% c(1, 2) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resdim2_scenario2$Education_Group <- ifelse(df_filtered_resdim2_scenario2$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_resdim2_scenario2 <- table(df_filtered_resdim2_scenario2$RESDIM2, df_filtered_resdim2_scenario2$Education_Group) rownames(table_resdim2_scenario2) <- c("Strongly Disagree", "Neither Agree Nor Disagree") chi_result_resdim2_scenario2 <- chisq.test(table_resdim2_scenario2) odds_ratio_resdim2_scenario2 <- oddsratio(table_resdim2_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim2_scenario2, caption = "Contingency Table: Education Level vs. Belief in Solving Antibiotic Resistance (Strongly Disagree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim2_scenario2) print(odds_ratio_resdim2_scenario2) # Scenario 3: Strongly Agree + Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim2_scenario3 <- df[df$RESDIM2 %in% c(1, 2, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resdim2_scenario3$Education_Group <- ifelse(df_filtered_resdim2_scenario3$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") df_filtered_resdim2_scenario3$Agree_Neither <- df_filtered_resdim2_scenario3$RESDIM2 %in% c(2, 3) table_resdim2_scenario3 <- table(df_filtered_resdim2_scenario3$Agree_Neither, df_filtered_resdim2_scenario3$Education_Group) rownames(table_resdim2_scenario3) <- c("Strongly Disagree", "Strongly Agree + Neither") chi_result_resdim2_scenario3 <- chisq.test(table_resdim2_scenario3) odds_ratio_resdim2_scenario3 <- oddsratio(table_resdim2_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim2_scenario3, caption = "Contingency Table: Education Level vs. Belief in Solving Antibiotic Resistance (Strongly Disagree vs. Strongly Agree + Neither Agree Nor Disagree)")) print(chi_result_resdim2_scenario3) print(odds_ratio_resdim2_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM3= Everyone needs to use antibiotics responsibly Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_resdim3_scenario1 <- df[df$RESDIM3 %in% c(1, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resdim3_scenario1$Education_Group <- ifelse(df_filtered_resdim3_scenario1$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_resdim3_scenario1 <- table(df_filtered_resdim3_scenario1$RESDIM3, df_filtered_resdim3_scenario1$Education_Group) rownames(table_resdim3_scenario1) <- c("Strongly Disagree", "Strongly Agree") chi_result_resdim3_scenario1 <- chisq.test(table_resdim3_scenario1) odds_ratio_resdim3_scenario1 <- oddsratio(table_resdim3_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim3_scenario1, caption = "Contingency Table: Education Level vs. Everyone needs to use antibiotics responsibly (Strongly Agree vs. Strongly Disagree)")) print(chi_result_resdim3_scenario1) print(odds_ratio_resdim3_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim3_scenario2 <- df[df$RESDIM3 %in% c(2, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resdim3_scenario2$Education_Group <- ifelse(df_filtered_resdim3_scenario2$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_resdim3_scenario2 <- table(df_filtered_resdim3_scenario2$RESDIM3, df_filtered_resdim3_scenario2$Education_Group) rownames(table_resdim3_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") chi_result_resdim3_scenario2 <- chisq.test(table_resdim3_scenario2) odds_ratio_resdim3_scenario2 <- oddsratio(table_resdim3_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim3_scenario2, caption = "Contingency Table: Education Level vs. Everyone needs to use antibiotics responsibly (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim3_scenario2) print(odds_ratio_resdim3_scenario2) # Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim3_scenario3 <- df[df$RESDIM3 %in% c(1, 2, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resdim3_scenario3$Education_Group <- ifelse(df_filtered_resdim3_scenario3$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") df_filtered_resdim3_scenario3$Disagree_Neither <- df_filtered_resdim3_scenario3$RESDIM3 %in% c(1, 2) table_resdim3_scenario3 <- table(df_filtered_resdim3_scenario3$Disagree_Neither, df_filtered_resdim3_scenario3$Education_Group) rownames(table_resdim3_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") chi_result_resdim3_scenario3 <- chisq.test(table_resdim3_scenario3) odds_ratio_resdim3_scenario3 <- oddsratio(table_resdim3_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim3_scenario3, caption = "Contingency Table: Education Level vs. Everyone needs to use antibiotics responsibly (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_resdim3_scenario3) print(odds_ratio_resdim3_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM4= People like me can't do much to stop antibiotic resistance Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Agree vs. Strongly Disagree df_filtered_resdim4_scenario1 <- df[df$RESDIM4 %in% c(1, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resdim4_scenario1$Education_Group <- ifelse(df_filtered_resdim4_scenario1$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_resdim4_scenario1 <- table(df_filtered_resdim4_scenario1$RESDIM4, df_filtered_resdim4_scenario1$Education_Group) rownames(table_resdim4_scenario1) <- c("Strongly Disagree", "Strongly Agree") chi_result_resdim4_scenario1 <- chisq.test(table_resdim4_scenario1) odds_ratio_resdim4_scenario1 <- oddsratio(table_resdim4_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim4_scenario1, caption = "Contingency Table: Education Level vs. Belief in Individual Impact on Antibiotic Resistance (Strongly Disagree vs. Strongly Agree)")) print(chi_result_resdim4_scenario1) print(odds_ratio_resdim4_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim4_scenario2 <- df[df$RESDIM4 %in% c(1, 2) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resdim4_scenario2$Education_Group <- ifelse(df_filtered_resdim4_scenario2$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_resdim4_scenario2 <- table(df_filtered_resdim4_scenario2$RESDIM4, df_filtered_resdim4_scenario2$Education_Group) rownames(table_resdim4_scenario2) <- c("Strongly Disagree", "Neither Agree Nor Disagree") chi_result_resdim4_scenario2 <- chisq.test(table_resdim4_scenario2) odds_ratio_resdim4_scenario2 <- oddsratio(table_resdim4_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim4_scenario2, caption = "Contingency Table: Education Level vs. Belief in Individual Impact on Antibiotic Resistance (Strongly Disagree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim4_scenario2) print(odds_ratio_resdim4_scenario2) # Scenario 3: Strongly Agree + Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim4_scenario3 <- df[df$RESDIM4 %in% c(1, 2, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resdim4_scenario3$Education_Group <- ifelse(df_filtered_resdim4_scenario3$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") df_filtered_resdim4_scenario3$Agree_Neither <- df_filtered_resdim4_scenario3$RESDIM4 %in% c(2, 3) table_resdim4_scenario3 <- table(df_filtered_resdim4_scenario3$Agree_Neither, df_filtered_resdim4_scenario3$Education_Group) rownames(table_resdim4_scenario3) <- c("Strongly Disagree", "Strongly Agree + Neither") chi_result_resdim4_scenario3 <- chisq.test(table_resdim4_scenario3) odds_ratio_resdim4_scenario3 <- oddsratio(table_resdim4_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim4_scenario3, caption = "Contingency Table: Education Level vs. Belief in Individual Impact on Antibiotic Resistance (Strongly Disagree vs. Strongly Agree + Neither Agree Nor Disagree)")) print(chi_result_resdim4_scenario3) print(odds_ratio_resdim4_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM5= I am worried about the impact that antibiotic resistance will have on my health and that of my family Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_resdim5_scenario1 <- df[df$RESDIM5 %in% c(1, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resdim5_scenario1$Education_Group <- ifelse(df_filtered_resdim5_scenario1$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_resdim5_scenario1 <- table(df_filtered_resdim5_scenario1$RESDIM5, df_filtered_resdim5_scenario1$Education_Group) rownames(table_resdim5_scenario1) <- c("Strongly Disagree", "Strongly Agree") chi_result_resdim5_scenario1 <- chisq.test(table_resdim5_scenario1) odds_ratio_resdim5_scenario1 <- oddsratio(table_resdim5_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim5_scenario1, caption = "Contingency Table: Education Level vs. Impact of AMR on personal health and that of their family (Strongly Agree vs. Strongly Disagree)")) print(chi_result_resdim5_scenario1) print(odds_ratio_resdim5_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim5_scenario2 <- df[df$RESDIM5 %in% c(2, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resdim5_scenario2$Education_Group <- ifelse(df_filtered_resdim5_scenario2$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_resdim5_scenario2 <- table(df_filtered_resdim5_scenario2$RESDIM5, df_filtered_resdim5_scenario2$Education_Group) rownames(table_resdim5_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") chi_result_resdim5_scenario2 <- chisq.test(table_resdim5_scenario2) odds_ratio_resdim5_scenario2 <- oddsratio(table_resdim5_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim5_scenario2, caption = "Contingency Table: Education Level vs. Impact of AMR on personal health and that of their family (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim5_scenario2) print(odds_ratio_resdim5_scenario2) # Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree df_filtered_resdim5_scenario3 <- df[df$RESDIM5 %in% c(1, 2, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resdim5_scenario3$Education_Group <- ifelse(df_filtered_resdim5_scenario3$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") df_filtered_resdim5_scenario3$Disagree_Neither <- df_filtered_resdim5_scenario3$RESDIM5 %in% c(1, 2) table_resdim5_scenario3 <- table(df_filtered_resdim5_scenario3$Disagree_Neither, df_filtered_resdim5_scenario3$Education_Group) rownames(table_resdim5_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") chi_result_resdim5_scenario3 <- chisq.test(table_resdim5_scenario3) odds_ratio_resdim5_scenario3 <- oddsratio(table_resdim5_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim5_scenario3, caption = "Contingency Table: Education Level vs. Impact of AMR on personal health and that of their family (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_resdim5_scenario3) print(odds_ratio_resdim5_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM6= I am not at risk of getting an antibiotic-resistant infection, as long as I take my antibiotics correctly Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Agree vs. Strongly Disagree df_filtered_resdim6_scenario1 <- df[df$RESDIM6 %in% c(1, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resdim6_scenario1$Education_Group <- ifelse(df_filtered_resdim6_scenario1$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_resdim6_scenario1 <- table(df_filtered_resdim6_scenario1$RESDIM6, df_filtered_resdim6_scenario1$Education_Group) rownames(table_resdim6_scenario1) <- c("Strongly Disagree", "Strongly Agree") chi_result_resdim6_scenario1 <- chisq.test(table_resdim6_scenario1) odds_ratio_resdim6_scenario1 <- oddsratio(table_resdim6_scenario1, conf.level = 0.95)$measure print(knitr::kable(table_resdim6_scenario1, caption = "Contingency Table: Education Level vs. Perception of Risk of Antibiotic-Resistant Infection (Strongly Disagree vs. Strongly Agree)")) print(chi_result_resdim6_scenario1) print(odds_ratio_resdim6_scenario1) print(table_resdim6_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim6_scenario2 <- df[df$RESDIM6 %in% c(1, 2) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resdim6_scenario2$Education_Group <- ifelse(df_filtered_resdim6_scenario2$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") table_resdim6_scenario2 <- table(df_filtered_resdim6_scenario2$RESDIM6, df_filtered_resdim6_scenario2$Education_Group) rownames(table_resdim6_scenario2) <- c("Strongly Disagree", "Neither Agree Nor Disagree") chi_result_resdim6_scenario2 <- chisq.test(table_resdim6_scenario2) odds_ratio_resdim6_scenario2 <- oddsratio(table_resdim6_scenario2, conf.level = 0.95)$measure print(knitr::kable(table_resdim6_scenario2, caption = "Contingency Table: Education Level vs. Perception of Risk of Antibiotic-Resistant Infection (Strongly Disagree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim6_scenario2) print(odds_ratio_resdim6_scenario2) # Scenario 3: Strongly Agree + Neither Agree Nor Disagree vs. Strongly Disagree df_filtered_resdim6_scenario3 <- df[df$RESDIM6 %in% c(1, 2, 3) & df$NIVSCOL %in% c(1, 2, 3, 4, 5, 6, 7, 8), ] df_filtered_resdim6_scenario3$Education_Group <- ifelse(df_filtered_resdim6_scenario3$NIVSCOL %in% c(7, 8), "Higher Education", "Other Education") df_filtered_resdim6_scenario3$Agree_Neither <- df_filtered_resdim6_scenario3$RESDIM6 %in% c(2, 3) table_resdim6_scenario3 <- table(df_filtered_resdim6_scenario3$Agree_Neither, df_filtered_resdim6_scenario3$Education_Group) rownames(table_resdim6_scenario3) <- c("Strongly Disagree", "Strongly Agree + Neither") chi_result_resdim6_scenario3 <- chisq.test(table_resdim6_scenario3) odds_ratio_resdim6_scenario3 <- oddsratio(table_resdim6_scenario3, conf.level = 0.95)$measure print(knitr::kable(table_resdim6_scenario3, caption = "Contingency Table: Education Level vs. Perception of Risk of Antibiotic-Resistant Infection (Strongly Disagree vs. Strongly Agree + Neither Agree Nor Disagree)")) print(chi_result_resdim6_scenario3) print(odds_ratio_resdim6_scenario3) ############################################## Comparisons by Field of work/study (Health and science vs other) ########################################## ###CUSIN1 (I wash my hands before cooking (No= 9.4%)) Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) # Load the Database_simplified dataframe df_filtered <- Database_simplified # First, create a new variable 'HEALTH_SCIENCE' that is 0 if either PROF11 or PROF12 is 0, and 1 otherwise df_filtered$HEALTH_SCIENCE <- ifelse(df_filtered$PROF11 == 0 | df_filtered$PROF12 == 0, 0, 1) # Now, filter the dataframe to keep only the relevant observations df_filtered <- df_filtered[df_filtered$CUSIN1 %in% c(0, 1) & df_filtered$HEALTH_SCIENCE %in% c(0, 1), ] # Create the contingency table table <- table(df_filtered$CUSIN1, df_filtered$HEALTH_SCIENCE) # Add descriptive labels to rows and columns rownames(table) <- c("CUSIN1 (Yes)", "CUSIN1 (No)") colnames(table) <- c("Health & Science", "Other Professions") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Health & Science vs. Hand Washing") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) --------------------------------------------------------------------------------------------------- ##CUSIN2 (After handling raw food (meat and vegetables), I wash my hands with soap (No= 15.1%)) # Filter DataFrame to include only the relevant observations for CUSIN2 and professions df_filtered <- Database_simplified[Database_simplified$CUSIN2 %in% c(0, 1) & (Database_simplified$PROF11 %in% c(0, 1) | Database_simplified$PROF12 %in% c(0, 1)), ] # Create a binary variable for Health & Science Professions df_filtered$HEALTH_SCIENCE <- ifelse(df_filtered$PROF11 == 0 | df_filtered$PROF12 == 0, 0, 1) # Create the Contingency Table table <- table(df_filtered$CUSIN2, df_filtered$HEALTH_SCIENCE) # Rename rows and columns of the table rownames(table) <- c("CUSIN2 (Yes)", "CUSIN2 (No)") colnames(table) <- c("Health & Science", "Other Professions") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Health & Science vs. After handling raw food (meat and vegetables), I wash my hands with soap") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------ ##CUSIN3 (I use the same kitchen utensils for handling raw and ready-to-eat foods (Yes=25.8%)) # Filter DataFrame to include only the relevant observations for CUSIN3 and professions df_filtered <- Database_simplified[Database_simplified$CUSIN3 %in% c(0, 1) & (Database_simplified$PROF11 %in% c(0, 1) | Database_simplified$PROF12 %in% c(0, 1)), ] # Create a binary variable for Health & Science Professions df_filtered$HEALTH_SCIENCE <- ifelse(df_filtered$PROF11 == 0 | df_filtered$PROF12 == 0, 0, 1) # Create the Contingency Table table <- table(df_filtered$CUSIN3, df_filtered$HEALTH_SCIENCE) # Rename rows and columns of the table rownames(table) <- c("CUSIN3 (Yes)", "CUSIN3 (No)") colnames(table) <- c("Health & Science", "Other Professions") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Health & Science vs. I use the same kitchen utensils for handling raw and ready-to-eat foods") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------- ##CUSIN4 (I wash kitchen utensils that have been used for raw food before using them to prepare other foods (No=16.8%)) # Filter DataFrame to include only the relevant observations for CUSIN4 and professions df_filtered <- Database_simplified[Database_simplified$CUSIN4 %in% c(0, 1) & (Database_simplified$PROF11 %in% c(0, 1) | Database_simplified$PROF12 %in% c(0, 1)), ] # Create a binary variable for Health & Science Professions df_filtered$HEALTH_SCIENCE <- ifelse(df_filtered$PROF11 == 0 | df_filtered$PROF12 == 0, 0, 1) # Create the Contingency Table table <- table(df_filtered$CUSIN4, df_filtered$HEALTH_SCIENCE) # Rename rows and columns of the table rownames(table) <- c("CUSIN4 (Yes)", "CUSIN4 (No)") colnames(table) <- c("Health & Science", "Other Professions") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Health & Science vs. Washing Kitchen Utensils Used for Raw Food Before Using Them for Other Foods") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------- ##CUSIN5 (I wash fruits and vegetables before eating them (No=20.7%)) # Filter DataFrame to include only the relevant observations for CUSIN5 and professions df_filtered <- Database_simplified[Database_simplified$CUSIN5 %in% c(0, 1) & (Database_simplified$PROF11 %in% c(0, 1) | Database_simplified$PROF12 %in% c(0, 1)), ] # Create a binary variable for Health & Science Professions df_filtered$HEALTH_SCIENCE <- ifelse(df_filtered$PROF11 == 0 | df_filtered$PROF12 == 0, 0, 1) # Create the Contingency Table table <- table(df_filtered$CUSIN5, df_filtered$HEALTH_SCIENCE) # Rename rows and columns of the table rownames(table) <- c("CUSIN5 (Yes)", "CUSIN5 (No)") colnames(table) <- c("Health & Science", "Other Professions") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Health & Science vs. Washing Fruits and Vegetables Before Eating Them") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) ------------------------------------------------------------------------------------------------------------------- ##CUSIN6 (I wash my hands before eating (No=21.5)) # Filter DataFrame to include only the relevant observations for CUSIN6 and professions df_filtered <- Database_simplified[Database_simplified$CUSIN6 %in% c(0, 1) & (Database_simplified$PROF11 %in% c(0, 1) | Database_simplified$PROF12 %in% c(0, 1)), ] # Create a binary variable for Health & Science Professions df_filtered$HEALTH_SCIENCE <- ifelse(df_filtered$PROF11 == 0 | df_filtered$PROF12 == 0, 0, 1) # Create the Contingency Table table <- table(df_filtered$CUSIN6, df_filtered$HEALTH_SCIENCE) # Rename rows and columns of the table rownames(table) <- c("CUSIN6 (Yes)", "CUSIN6 (No)") colnames(table) <- c("Health & Science", "Other Professions") # Print the contingency table using knitr for a formatted output kable(table, caption = "Contingency Table: Health & Science vs. Washing Hands Before Eating") # Chi-Square Test chi_result <- chisq.test(table) # Print the results of the Chi-Square Test print(chi_result) # Calculating the odds ratio for a 2x2 table odds_ratio <- (table[1, 1] * table[2, 2]) / (table[1, 2] * table[2, 1]) # Calculating the confidence interval confidence_interval <- oddsratio(table, conf.level = 0.95)$measure # Printing the odds ratio and confidence interval print(odds_ratio) print(confidence_interval) --------------------------------------------------------------------------------------------------------------------- ##PRESCATB1 When you get a prescription for antibiotics, do you follow the recommended ##length of treatment and daily dosage? (No=4.2%) (Sometimes=9.6%) (No+Sometimes=13.8%) # Read the database Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) df <- Database_simplified ############### 1st scenario= No # Filter DataFrame to include only the relevant observations for PRESCATB1 and professions df_filtered_prescatb1 <- df[df$PRESCATB1 %in% c(0, 1) & (df$PROF11 %in% c(0, 1) | df$PROF12 %in% c(0, 1)), ] # Create a binary variable for Health & Science Professions df_filtered_prescatb1$HEALTH_SCIENCE <- ifelse(df_filtered_prescatb1$PROF11 == 0 | df_filtered_prescatb1$PROF12 == 0, 0, 1) # Create the Contingency Table table_prescatb1 <- table(df_filtered_prescatb1$PRESCATB1, df_filtered_prescatb1$HEALTH_SCIENCE) # Add descriptive labels to the rows and columns rownames(table_prescatb1) <- c("Yes", "No") colnames(table_prescatb1) <- c("Health & Science", "Other Professions") # Perform the Chi-Squared test chi_result_prescatb1 <- chisq.test(table_prescatb1) # Calculate the odds ratio and confidence interval odds_ratio_prescatb1 <- oddsratio(table_prescatb1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_prescatb1, caption = "Contingency Table: Profession vs. Following Prescription for Antibiotics")) # Print the results of the Chi-Squared test print(chi_result_prescatb1) # Print the odds ratio and confidence interval print(odds_ratio_prescatb1) ################## 2nd scenario= Sometimes # Filter DataFrame to include only the relevant observations for PRESCATB1 and professions df_filtered_prescatb1_sometimes <- df[df$PRESCATB1 %in% c(0, 3) & (df$PROF11 %in% c(0, 1) | df$PROF12 %in% c(0, 1)), ] # Create a binary variable for Health & Science Professions df_filtered_prescatb1_sometimes$HEALTH_SCIENCE <- ifelse(df_filtered_prescatb1_sometimes$PROF11 == 0 | df_filtered_prescatb1_sometimes$PROF12 == 0, 0, 1) # Create the Contingency Table table_prescatb1_sometimes <- table(df_filtered_prescatb1_sometimes$PRESCATB1, df_filtered_prescatb1_sometimes$HEALTH_SCIENCE) # Add descriptive labels to the rows and columns rownames(table_prescatb1_sometimes) <- c("Yes", "Sometimes") colnames(table_prescatb1_sometimes) <- c("Health & Science", "Other Professions")# Perform the Chi-Squared test chi_result_prescatb1_sometimes <- chisq.test(table_prescatb1_sometimes) # Calculate the odds ratio and confidence interval odds_ratio_prescatb1_sometimes <- oddsratio(table_prescatb1_sometimes, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_prescatb1_sometimes, caption = "Contingency Table: Profession vs. Following Prescription for Antibiotics Sometimes")) # Print the results of the Chi-Squared test print(chi_result_prescatb1_sometimes) # Print the odds ratio and confidence interval print(odds_ratio_prescatb1_sometimes) ################## 3rd scenario= No+Sometimes # Filter DataFrame to include only the relevant observations for PRESCATB1 and professions df_filtered_prescatb1_combined <- df[df$PRESCATB1 %in% c(0, 1, 3) & (df$PROF11 %in% c(0, 1) | df$PROF12 %in% c(0, 1)), ] # Create a binary variable for Health & Science Professions df_filtered_prescatb1_combined$HEALTH_SCIENCE <- ifelse(df_filtered_prescatb1_combined$PROF11 == 0 | df_filtered_prescatb1_combined$PROF12 == 0, 0, 1) df_filtered_prescatb1_combined$No_Sometimes <- df_filtered_prescatb1_combined$PRESCATB1 %in% c(1, 3) # Create the Contingency Table table_prescatb1_combined <- table(df_filtered_prescatb1_combined$No_Sometimes, df_filtered_prescatb1_combined$HEALTH_SCIENCE) # Adjust the table to have 'Yes' and 'No+Sometimes' as row names rownames(table_prescatb1_combined) <- c("Yes", "No_Sometimes") colnames(table_prescatb1_combined) <- c("Health & Science", "Other Professions") # Perform the Chi-Squared test chi_result_prescatb1_combined <- chisq.test(table_prescatb1_combined) # Calculate the odds ratio and confidence interval odds_ratio_prescatb1_combined <- oddsratio(table_prescatb1_combined, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_prescatb1_combined, caption = "Contingency Table: Profession vs. Following Prescription for Antibiotics (Yes vs. No+Sometimes)")) # Print the results of the Chi-Squared test print(chi_result_prescatb1_combined) # Print the odds ratio and confidence interval print(odds_ratio_prescatb1_combined) --------------------------------------------------------------------------------------------------------------------- ##ARRETATB Do you stop taking antibiotics when symptoms start to disappear? ##(Always=7.3%) (Sometimes=20.4%) (Always+Sometimes=27.7%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) df <- Database_simplified ############### 1st scenario= Always # Filter DataFrame to include only the relevant observations for ARRETATB and professions df_filtered_arretatb <- df[df$ARRETATB %in% c(0, 1) & (df$PROF11 %in% c(0, 1) | df$PROF12 %in% c(0, 1)), ] # Create a binary variable for Health & Science Professions df_filtered_arretatb$HEALTH_SCIENCE <- ifelse(df_filtered_arretatb$PROF11 == 0 | df_filtered_arretatb$PROF12 == 0, 0, 1) # Create the Contingency Table table_arretatb <- table(df_filtered_arretatb$ARRETATB, df_filtered_arretatb$HEALTH_SCIENCE) # Add descriptive labels to the rows and columns rownames(table_arretatb) <- c("Always", "Never") colnames(table_arretatb) <- c("Health & Science", "Other Professions") # Perform the Chi-Squared test chi_result_arretatb <- chisq.test(table_arretatb) # Calculate the odds ratio and confidence interval odds_ratio_arretatb <- oddsratio(table_arretatb, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_arretatb, caption = "Contingency Table: Profession vs. Stopping Antibiotics Always vs. Never")) # Print the results of the Chi-Squared test print(chi_result_arretatb) # Print the odds ratio and confidence interval print(odds_ratio_arretatb) ################# 2nd scenario: Sometimes # Filter DataFrame to include only the relevant observations for ARRETATB and professions df_filtered_arretatb_sometimes <- df[df$ARRETATB %in% c(1, 2) & (df$PROF11 %in% c(0, 1) | df$PROF12 %in% c(0, 1)), ] # Create a binary variable for Health & Science Professions df_filtered_arretatb_sometimes$HEALTH_SCIENCE <- ifelse(df_filtered_arretatb_sometimes$PROF11 == 0 | df_filtered_arretatb_sometimes$PROF12 == 0, 0, 1) # Create the Contingency Table table_arretatb_sometimes <- table(df_filtered_arretatb_sometimes$ARRETATB == 2, df_filtered_arretatb_sometimes$HEALTH_SCIENCE) # Add descriptive labels to the rows and columns rownames(table_arretatb_sometimes) <- c("Never", "Sometimes") colnames(table_arretatb_sometimes) <- c("Health & Science", "Other Professions") # Perform the Chi-Squared test chi_result_arretatb_sometimes <- chisq.test(table_arretatb_sometimes) # Calculate the odds ratio and confidence interval odds_ratio_arretatb_sometimes <- oddsratio(table_arretatb_sometimes, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_arretatb_sometimes, caption = "Contingency Table: Profession vs. Stopping Antibiotics Sometimes vs. Never")) # Print the results of the Chi-Squared test print(chi_result_arretatb_sometimes) # Print the odds ratio and confidence interval print(odds_ratio_arretatb_sometimes) ############### #3rd scenario= Sometimes+Always # Filter DataFrame to include only the relevant observations for ARRETATB and professions df_filtered_arretatb_combined <- df[df$ARRETATB %in% c(0, 1, 2) & (df$PROF11 %in% c(0, 1) | df$PROF12 %in% c(0, 1)), ] # Create a binary variable for Health & Science Professions df_filtered_arretatb_combined$HEALTH_SCIENCE <- ifelse(df_filtered_arretatb_combined$PROF11 == 0 | df_filtered_arretatb_combined$PROF12 == 0, 0, 1) # Create the Contingency Table table_arretatb_combined <- table(df_filtered_arretatb_combined$ARRETATB %in% c(0, 2), df_filtered_arretatb_combined$HEALTH_SCIENCE) # Add descriptive labels to the rows and columns rownames(table_arretatb_combined) <- c("Never", "Sometimes_Always") colnames(table_arretatb_combined) <- c("Health & Science", "Other Professions") # Perform the Chi-Squared test chi_result_arretatb_combined <- chisq.test(table_arretatb_combined) # Calculate the odds ratio and confidence interval odds_ratio_arretatb_combined <- oddsratio(table_arretatb_combined, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_arretatb_combined, caption = "Contingency Table: Profession vs. Stopping Antibiotics (Sometimes+Always vs. Never)")) # Print the results of the Chi-Squared test print(chi_result_arretatb_combined) # Print the odds ratio and confidence interval print(odds_ratio_arretatb_combined) --------------------------------------------------------------------------------------------------------------------- ##ATBORAL1 Have you ever taken an oral antibiotic treatment (by mouth) without a medical prescription? (Yes=12.3%) df_filtered_atboral <- df[df$ATBORAL1 %in% c(0, 1) & (df$PROF11 %in% c(0, 1) | df$PROF12 %in% c(0, 1)), ] # Create a binary variable for Health & Science Professions df_filtered_atboral$HEALTH_SCIENCE <- ifelse(df_filtered_atboral$PROF11 == 0 | df_filtered_atboral$PROF12 == 0, "Health and Science", "Other Professions") # Create the Contingency Table table_atboral <- table(df_filtered_atboral$ATBORAL1, df_filtered_atboral$HEALTH_SCIENCE) # Add descriptive labels to the rows and columns rownames(table_atboral) <- c("Yes", "No") # Perform the Chi-Squared test chi_result_atboral <- chisq.test(table_atboral) # Calculate the odds ratio and confidence interval odds_ratio_atboral <- oddsratio(table_atboral, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atboral, caption = "Contingency Table: Profession vs. Taking Oral Antibiotics Without Prescription (Yes vs. No)")) # Print the results of the Chi-Squared test print(chi_result_atboral) # Print the odds ratio and confidence interval print(odds_ratio_atboral) -------------------------------------------------------------------------------------------------------- ### ATBANI1 I can exchange resistant bacteria with my pet (False=23.2%) # Filter DataFrame for the relevant variables: ATBANI1 and PROF11/PROF12 df_filtered_atbani1 <- df[df$ATBANI1 %in% c(0, 1), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_atbani1$HEALTH_SCIENCE <- ifelse(df_filtered_atbani1$PROF11 == 0 | df_filtered_atbani1$PROF12 == 0, "Health and Science", "Other Professions") # Create the contingency table table_atbani1 <- table(df_filtered_atbani1$ATBANI1, df_filtered_atbani1$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_atbani1) <- c("True", "False") # Perform the Chi-Squared test chi_result_atbani1 <- chisq.test(table_atbani1) # Calculate the odds ratio and confidence interval odds_ratio_atbani1 <- oddsratio(table_atbani1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani1, caption = "Contingency Table: Health and Science vs. Other Professions vs. Exchanging Resistant Bacteria with Pets (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani1) # Print the odds ratio and confidence interval print(odds_ratio_atbani1) --------------------------------------------------------------------------------------------------------------------- ### ATBANI2=The use of antibiotics in livestock and crops can increase the #presence of resistant bacteria in the environment (False=14.7%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Filter DataFrame for the relevant variable: ATBANI2 df_filtered_atbani2 <- df[df$ATBANI2 %in% c(0, 1), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_atbani2$HEALTH_SCIENCE <- ifelse(df_filtered_atbani2$PROF11 == 0 | df_filtered_atbani2$PROF12 == 0, "Health and Science", "Other Professions") # Create the contingency table table_atbani2 <- table(df_filtered_atbani2$ATBANI2, df_filtered_atbani2$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_atbani2) <- c("True", "False") # Perform the Chi-Squared test chi_result_atbani2 <- chisq.test(table_atbani2) # Calculate the odds ratio and confidence interval odds_ratio_atbani2 <- oddsratio(table_atbani2, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani2, caption = "Contingency Table: Health and Science vs. Other Professions vs. Antibiotics in Livestock and Crops Affecting Environment (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani2) # Print the odds ratio and confidence interval print(odds_ratio_atbani2) -------------------------------------------------------------------------------------------------------------------- ##### ATBANI3 The use of antibiotics in livestock and crops can affect me directly ##(I can get resistant bacteria in my body) (False=26.3%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) df <- Database_simplified # Filter DataFrame for the relevant variable: ATBANI3 df_filtered_atbani3 <- df[df$ATBANI3 %in% c(0, 1), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_atbani3$HEALTH_SCIENCE <- ifelse(df_filtered_atbani3$PROF11 == 0 | df_filtered_atbani3$PROF12 == 0, "Health and Science", "Other Professions") # Create the contingency table table_atbani3 <- table(df_filtered_atbani3$ATBANI3, df_filtered_atbani3$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_atbani3) <- c("True", "False") # Perform the Chi-Squared test chi_result_atbani3 <- chisq.test(table_atbani3) # Calculate the odds ratio and confidence interval odds_ratio_atbani3 <- oddsratio(table_atbani3, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani3, caption = "Contingency Table: Health and Science vs. Other Professions vs. Antibiotics in Livestock and Crops Affecting Humans Directly (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani3) # Print the odds ratio and confidence interval print(odds_ratio_atbani3) ------------------------------------------------------------------------------------------------------------------- ##### ATBANI4 Resistant bacteria are only found in hospitals (True=10.8%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) df <- Database_simplified # Filter DataFrame for the relevant variable: ATBANI4 df_filtered_atbani4 <- df[df$ATBANI4 %in% c(0, 1), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_atbani4$HEALTH_SCIENCE <- ifelse(df_filtered_atbani4$PROF11 == 0 | df_filtered_atbani4$PROF12 == 0, "Health and Science", "Other Professions") # Create the contingency table table_atbani4 <- table(df_filtered_atbani4$ATBANI4, df_filtered_atbani4$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_atbani4) <- c("True", "False") # Perform the Chi-Squared test chi_result_atbani4 <- chisq.test(table_atbani4) # Calculate the odds ratio and confidence interval odds_ratio_atbani4 <- oddsratio(table_atbani4, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbani4, caption = "Contingency Table: Health and Science vs. Other Professions vs. Resistant Bacteria Found Only in Hospitals (True vs. False)")) # Print the results of the Chi-Squared test print(chi_result_atbani4) # Print the odds ratio and confidence interval print(odds_ratio_atbani4) ---------------------------------------------------------------------------------------------------------------------- #####RESATB1 Antibiotic resistance occurs when your body becomes resistant to antibiotics and they ##no longer work as well (True=58.3%) Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) df <- Database_simplified # Filter DataFrame for the relevant variable: RESATB1 df_filtered_resatb1 <- df[df$RESATB1 %in% c(0, 1), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_resatb1$HEALTH_SCIENCE <- ifelse(df_filtered_resatb1$PROF11 == 0 | df_filtered_resatb1$PROF12 == 0, "Health and Science", "Other Professions") # Create the contingency table table_resatb1 <- table(df_filtered_resatb1$RESATB1, df_filtered_resatb1$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_resatb1) <- c("True", "False") # Perform the Chi-Squared test chi_result_resatb1 <- chisq.test(table_resatb1) # Calculate the odds ratio and confidence interval odds_ratio_resatb1 <- oddsratio(table_resatb1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb1, caption = "Contingency Table: Health and Science vs. Other Professions vs. Understanding of Antibiotic Resistance (RESATB1: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb1) print(odds_ratio_resatb1) ------------------------------------------------------------------------------------------------------------------- #####RESATB2 Many infections are becoming increasingly resistant to antibiotic treatment (False=12.5%) # Load the database df <- Database_simplified # Filter DataFrame for the relevant variable: RESATB2 df_filtered_resatb2 <- df[df$RESATB2 %in% c(0, 1), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_resatb2$HEALTH_SCIENCE <- ifelse(df_filtered_resatb2$PROF11 == 0 | df_filtered_resatb2$PROF12 == 0, "Health and Science", "Other Professions") # Create the contingency table table_resatb2 <- table(df_filtered_resatb2$RESATB2, df_filtered_resatb2$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_resatb2) <- c("True", "False") # Perform the Chi-Squared test chi_result_resatb2 <- chisq.test(table_resatb2) # Calculate the odds ratio and confidence interval odds_ratio_resatb2 <- oddsratio(table_resatb2, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb2, caption = "Contingency Table: Health and Science vs. Other Professions vs. Perception of Increasing Infection Resistance (RESATB2: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb2) print(odds_ratio_resatb2) --------------------------------------------------------------------------------------------------------------------- #####RESATB3 If bacteria are resistant to antibiotics, it can be very difficult or impossible to treat the infections they cause (False=16.7%) # Load the database df <- Database_simplified # Filter DataFrame for the relevant variable: RESATB3 df_filtered_resatb3 <- df[df$RESATB3 %in% c(0, 1), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_resatb3$HEALTH_SCIENCE <- ifelse(df_filtered_resatb3$PROF11 == 0 | df_filtered_resatb3$PROF12 == 0, "Health and Science", "Other Professions") # Create the contingency table table_resatb3 <- table(df_filtered_resatb3$RESATB3, df_filtered_resatb3$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_resatb3) <- c("True", "False") # Perform the Chi-Squared test chi_result_resatb3 <- chisq.test(table_resatb3) # Calculate the odds ratio and confidence interval odds_ratio_resatb3 <- oddsratio(table_resatb3, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb3, caption = "Contingency Table: Health and Science vs. Other Professions vs. Perception of Difficulty Treating Infections (RESATB3: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb3) print(odds_ratio_resatb3) ---------------------------------------------------------------------------------------------------------------------- #####RESATB4 Antibiotic resistance is an issue that could affect me or my family (False=11.8%) # Load the database df <- Database_simplified # Filter DataFrame for the relevant variable: RESATB4 df_filtered_resatb4 <- df[df$RESATB4 %in% c(0, 1), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_resatb4$HEALTH_SCIENCE <- ifelse(df_filtered_resatb4$PROF11 == 0 | df_filtered_resatb4$PROF12 == 0, "Health and Science", "Other Professions") # Create the contingency table table_resatb4 <- table(df_filtered_resatb4$RESATB4, df_filtered_resatb4$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_resatb4) <- c("True", "False") # Perform the Chi-Squared test chi_result_resatb4 <- chisq.test(table_resatb4) # Calculate the odds ratio and confidence interval odds_ratio_resatb4 <- oddsratio(table_resatb4, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb4, caption = "Contingency Table: Health and Science vs. Other Professions vs. Perception of Antibiotic Resistance Affecting One's Family (RESATB4: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb4) print(odds_ratio_resatb4) --------------------------------------------------------------------------------------------------------------------- #####RESATB5 Antibiotic resistance is an issue in other countries but not here (True=9.9%) # Load the database df <- Database_simplified # Filter DataFrame for the relevant variable: RESATB5 df_filtered_resatb5 <- df[df$RESATB5 %in% c(0, 1), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_resatb5$HEALTH_SCIENCE <- ifelse(df_filtered_resatb5$PROF11 == 0 | df_filtered_resatb5$PROF12 == 0, "Health and Science", "Other Professions") # Create the contingency table table_resatb5 <- table(df_filtered_resatb5$RESATB5, df_filtered_resatb5$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_resatb5) <- c("True", "False") # Perform the Chi-Squared test chi_result_resatb5 <- chisq.test(table_resatb5) # Calculate the odds ratio and confidence interval odds_ratio_resatb5 <- oddsratio(table_resatb5, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb5, caption = "Contingency Table: Health and Science vs. Other Professions vs. Perception of Antibiotic Resistance as an Issue Only in Other Countries (RESATB5: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb5) print(odds_ratio_resatb5) --------------------------------------------------------------------------------------------------------------------- #####RESATB6 Antibiotic resistance is only a problem for people who take antibiotics regularly (True=17.5%) # Load the database df <- Database_simplified # Filter DataFrame for the relevant variable: RESATB6 df_filtered_resatb6 <- df[df$RESATB6 %in% c(0, 1), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_resatb6$HEALTH_SCIENCE <- ifelse(df_filtered_resatb6$PROF11 == 0 | df_filtered_resatb6$PROF12 == 0, "Health and Science", "Other Professions") # Create the contingency table table_resatb6 <- table(df_filtered_resatb6$RESATB6, df_filtered_resatb6$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_resatb6) <- c("True", "False") # Perform the Chi-Squared test chi_result_resatb6 <- chisq.test(table_resatb6) # Calculate the odds ratio and confidence interval odds_ratio_resatb6 <- oddsratio(table_resatb6, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb6, caption = "Contingency Table: Health and Science vs. Other Professions vs. Perception of Antibiotic Resistance as a Problem Only for Regular Antibiotic Users (RESATB6: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb6) print(odds_ratio_resatb6) --------------------------------------------------------------------------------------------------------------------- #####RESATB7 Bacteria that are resistant to antibiotics can be spread from person to person (False=20.2%) # Load the database df <- Database_simplified # Filter DataFrame for the relevant variable: RESATB7 df_filtered_resatb7 <- df[df$RESATB7 %in% c(0, 1), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_resatb7$HEALTH_SCIENCE <- ifelse(df_filtered_resatb7$PROF11 == 0 | df_filtered_resatb7$PROF12 == 0, "Health and Science", "Other Professions") # Create the contingency table table_resatb7 <- table(df_filtered_resatb7$RESATB7, df_filtered_resatb7$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_resatb7) <- c("True", "False") # Perform the Chi-Squared test chi_result_resatb7 <- chisq.test(table_resatb7) # Calculate the odds ratio and confidence interval odds_ratio_resatb7 <- oddsratio(table_resatb7, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb7, caption = "Contingency Table: Health and Science vs. Other Professions vs. Perception of Bacteria Transmission Person to Person (RESATB7: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb7) print(odds_ratio_resatb7) -------------------------------------------------------------------------------------------------------------------- #####RESATB8 Antibiotic-resistant infections could make medical procedures like surgery, organ transplants, ##and cancer treatment much more dangerous (False=12.0%) # Load the database df <- Database_simplified # Filter DataFrame for the relevant variable: RESATB8 df_filtered_resatb8 <- df[df$RESATB8 %in% c(0, 1), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_resatb8$HEALTH_SCIENCE <- ifelse(df_filtered_resatb8$PROF11 == 0 | df_filtered_resatb8$PROF12 == 0, "Health and Science", "Other Professions") # Create the contingency table table_resatb8 <- table(df_filtered_resatb8$RESATB8, df_filtered_resatb8$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_resatb8) <- c("True", "False") # Perform the Chi-Squared test chi_result_resatb8 <- chisq.test(table_resatb8) # Calculate the odds ratio and confidence interval odds_ratio_resatb8 <- oddsratio(table_resatb8, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_resatb8, caption = "Contingency Table: Health and Science vs. Other Professions vs. Perception of Antibiotic-Resistant Infections and Medical Procedures (RESATB8: True vs. False)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_resatb8) print(odds_ratio_resatb8) -------------------------------------------------------------------------------------------------------------------- # Load dataframe Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) df <- Database_simplified # Filter DataFrame for the relevant variable: ATBRGL1 df_filtered_atbrgl1_scenario1 <- df[df$ATBRGL1 %in% c(1, 3), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_atbrgl1_scenario1$HEALTH_SCIENCE <- ifelse(df_filtered_atbrgl1_scenario1$PROF11 == 0 | df_filtered_atbrgl1_scenario1$PROF12 == 0, "Health and Science", "Other Professions") # Create the contingency table table_atbrgl1_scenario1 <- table(df_filtered_atbrgl1_scenario1$ATBRGL1, df_filtered_atbrgl1_scenario1$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_atbrgl1_scenario1) <- c("Strongly Disagree", "Strongly Agree") # Perform the Chi-Squared test chi_result_atbrgl1_scenario1 <- chisq.test(table_atbrgl1_scenario1) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl1_scenario1 <- oddsratio(table_atbrgl1_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl1_scenario1, caption = "Contingency Table: Health and Science vs. Other Professions vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Strongly Disagree)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_atbrgl1_scenario1) print(odds_ratio_atbrgl1_scenario1) ############################# 2nd scenario Farmers should give fewer antibiotics to ##food-producing animals (Neither agree nor desagree=22.6%) vs. Strongly Agree # Load dataframe df <- Database_simplified # Filter DataFrame for the relevant variable: ATBRGL1 df_filtered_atbrgl1_scenario2 <- df[df$ATBRGL1 %in% c(2, 3), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_atbrgl1_scenario2$HEALTH_SCIENCE <- ifelse(df_filtered_atbrgl1_scenario2$PROF11 == 0 | df_filtered_atbrgl1_scenario2$PROF12 == 0, "Health and Science", "Other Professions") # Create the contingency table table_atbrgl1_scenario2 <- table(df_filtered_atbrgl1_scenario2$ATBRGL1, df_filtered_atbrgl1_scenario2$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_atbrgl1_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") # Perform the Chi-Squared test chi_result_atbrgl1_scenario2 <- chisq.test(table_atbrgl1_scenario2) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl1_scenario2 <- oddsratio(table_atbrgl1_scenario2, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl1_scenario2, caption = "Contingency Table: Health and Science vs. Other Professions vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Neither Agree Nor Disagree)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_atbrgl1_scenario2) print(odds_ratio_atbrgl1_scenario2) ############################# 3rd scenario (Strongly desagree + Neither agree nor desagree=31.28%) vs. Strongly Agree # Load dataframe df <- Database_simplified # Filter DataFrame for the relevant variable: ATBRGL1 df_filtered_atbrgl1_scenario3 <- df[df$ATBRGL1 %in% c(1, 2, 3), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_atbrgl1_scenario3$HEALTH_SCIENCE <- ifelse(df_filtered_atbrgl1_scenario3$PROF11 == 0 | df_filtered_atbrgl1_scenario3$PROF12 == 0, "Health and Science", "Other Professions") # Categorize responses into Strongly Agree vs. Strongly Disagree + Neither df_filtered_atbrgl1_scenario3$Disagree_Neither <- df_filtered_atbrgl1_scenario3$ATBRGL1 %in% c(1, 2) # Create the contingency table table_atbrgl1_scenario3 <- table(df_filtered_atbrgl1_scenario3$Disagree_Neither, df_filtered_atbrgl1_scenario3$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_atbrgl1_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") # Perform the Chi-Squared test chi_result_atbrgl1_scenario3 <- chisq.test(table_atbrgl1_scenario3) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl1_scenario3 <- oddsratio(table_atbrgl1_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl1_scenario3, caption = "Contingency Table: Health and Science vs. Other Professions vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Strongly Disagree + Neither)")) # Print the results of the Chi-Squared test and odds ratio print(chi_result_atbrgl1_scenario3) print(odds_ratio_atbrgl1_scenario3) -------------------------------------------------------------------------------------------------------------------- # ATBRGL2 People should not keep antibiotics and use them later for other illnesses ############################# 1st scenario Strongly desagree vs. Strongly Agree Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the database df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree df_filtered_atbrgl2_scenario1 <- df[df$ATBRGL2 %in% c(1, 3), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_atbrgl2_scenario1$HEALTH_SCIENCE <- ifelse(df_filtered_atbrgl2_scenario1$PROF11 == 0 | df_filtered_atbrgl2_scenario1$PROF12 == 0, "Health and Science", "Other Professions") # Create the contingency table table_atbrgl2_scenario1 <- table(df_filtered_atbrgl2_scenario1$ATBRGL2, df_filtered_atbrgl2_scenario1$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_atbrgl2_scenario1) <- c("Strongly Disagree", "Strongly Agree") # Perform Chi-Squared test chi_result_atbrgl2_scenario1 <- chisq.test(table_atbrgl2_scenario1) # Calculate odds ratio and confidence interval odds_ratio_atbrgl2_scenario1 <- oddsratio(table_atbrgl2_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl2_scenario1, caption = "Contingency Table: Health and Science vs. Other Professions vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl2_scenario1) print(odds_ratio_atbrgl2_scenario1) ############################# 2nd scenario Neither agree nor desagree vs. Strongly Agree # Filter for 'Strongly Agree' (3) and 'Neither Agree Nor Disagree' (2) responses for ATBRGL2 df_filtered_atbrgl2_scenario2 <- df[df$ATBRGL2 %in% c(2, 3), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_atbrgl2_scenario2$HEALTH_SCIENCE <- ifelse(df_filtered_atbrgl2_scenario2$PROF11 == 0 | df_filtered_atbrgl2_scenario2$PROF12 == 0, "Health and Science", "Other Professions") # Create the contingency table table_atbrgl2_scenario2 <- table(df_filtered_atbrgl2_scenario2$ATBRGL2, df_filtered_atbrgl2_scenario2$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_atbrgl2_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") # Perform Chi-Squared test chi_result_atbrgl2_scenario2 <- chisq.test(table_atbrgl2_scenario2) # Calculate odds ratio and confidence interval odds_ratio_atbrgl2_scenario2 <- oddsratio(table_atbrgl2_scenario2, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl2_scenario2, caption = "Contingency Table: Health and Science vs. Other Professions vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl2_scenario2) print(odds_ratio_atbrgl2_scenario2) ############################# 3rd scenario Neither agree nor desagree + Stringly Disagree vs. Strongly Agree df_filtered_atbrgl2_scenario3 <- df[df$ATBRGL2 %in% c(1, 2, 3), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_atbrgl2_scenario3$HEALTH_SCIENCE <- ifelse(df_filtered_atbrgl2_scenario3$PROF11 == 0 | df_filtered_atbrgl2_scenario3$PROF12 == 0, "Health and Science", "Other Professions") # Categorize responses into Strongly Agree vs. Strongly Disagree + Neither df_filtered_atbrgl2_scenario3$Disagree_Neither <- df_filtered_atbrgl2_scenario3$ATBRGL2 %in% c(1, 2) # Create the contingency table table_atbrgl2_scenario3 <- table(df_filtered_atbrgl2_scenario3$Disagree_Neither, df_filtered_atbrgl2_scenario3$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_atbrgl2_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") # Perform the Chi-Squared test chi_result_atbrgl2_scenario3 <- chisq.test(table_atbrgl2_scenario3) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl2_scenario3 <- oddsratio(table_atbrgl2_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl2_scenario3, caption = "Contingency Table: Health and Science vs. Other Professions vs. Opinion on Antibiotics in Farming (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl2_scenario3) print(odds_ratio_atbrgl2_scenario3) -------------------------------------------------------------------------------------------------------------------- # ATBRGL3 Parents should make sure all of their children’s vaccinations are up-to-date Database_simplified <- read_excel("C:/Database_simplified.xlsx") View(Database_simplified) ####1st scenario # Load dataframe df <- Database_simplified df_filtered_atbrgl3_scenario1 <- df[df$ATBRGL3 %in% c(1, 3), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_atbrgl3_scenario1$HEALTH_SCIENCE <- ifelse(df_filtered_atbrgl3_scenario1$PROF11 == 0 | df_filtered_atbrgl3_scenario1$PROF12 == 0, "Health and Science", "Other Professions") # Create the contingency table table_atbrgl3_scenario1 <- table(df_filtered_atbrgl3_scenario1$ATBRGL3, df_filtered_atbrgl3_scenario1$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_atbrgl3_scenario1) <- c("Strongly Disagree", "Strongly Agree") # Perform Chi-Squared test chi_result_atbrgl3_scenario1 <- chisq.test(table_atbrgl3_scenario1) # Calculate odds ratio and confidence interval odds_ratio_atbrgl3_scenario1 <- oddsratio(table_atbrgl3_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl3_scenario1, caption = "Contingency Table: Health and Science vs. Other Professions vs. Opinion on Children's Vaccinations (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl3_scenario1) print(odds_ratio_atbrgl3_scenario1) ### 2nd Scenario # Load dataframe df <- Database_simplified df_filtered_atbrgl3_scenario2 <- df[df$ATBRGL3 %in% c(2, 3), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_atbrgl3_scenario2$HEALTH_SCIENCE <- ifelse(df_filtered_atbrgl3_scenario2$PROF11 == 0 | df_filtered_atbrgl3_scenario2$PROF12 == 0, "Health and Science", "Other Professions") # Create the contingency table table_atbrgl3_scenario2 <- table(df_filtered_atbrgl3_scenario2$ATBRGL3, df_filtered_atbrgl3_scenario2$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_atbrgl3_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") # Perform Chi-Squared test chi_result_atbrgl3_scenario2 <- chisq.test(table_atbrgl3_scenario2) # Calculate odds ratio and confidence interval odds_ratio_atbrgl3_scenario2 <- oddsratio(table_atbrgl3_scenario2, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl3_scenario2, caption = "Contingency Table: Health and Science vs. Other Professions vs. Opinion on Children's Vaccinations (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl3_scenario2) print(odds_ratio_atbrgl3_scenario2) ## 3rd scenario # Load dataframe df <- Database_simplified df_filtered_atbrgl3_scenario3 <- df[df$ATBRGL3 %in% c(1, 2, 3), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_atbrgl3_scenario3$HEALTH_SCIENCE <- ifelse(df_filtered_atbrgl3_scenario3$PROF11 == 0 | df_filtered_atbrgl3_scenario3$PROF12 == 0, "Health and Science", "Other Professions") # Categorize responses into Strongly Agree vs. Strongly Disagree + Neither df_filtered_atbrgl3_scenario3$Disagree_Neither <- df_filtered_atbrgl3_scenario3$ATBRGL3 %in% c(1, 2) # Create the contingency table table_atbrgl3_scenario3 <- table(df_filtered_atbrgl3_scenario3$Disagree_Neither, df_filtered_atbrgl3_scenario3$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_atbrgl3_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") # Perform the Chi-Squared test chi_result_atbrgl3_scenario3 <- chisq.test(table_atbrgl3_scenario3) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl3_scenario3 <- oddsratio(table_atbrgl3_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table and results print(kable(table_atbrgl3_scenario3, caption = "Contingency Table: Health and Science vs. Other Professions vs. Opinion on Children's Vaccinations (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl3_scenario3) print(odds_ratio_atbrgl3_scenario3) --------------------------------------------------------------------------------------------------------------------- # ATBRGL4 People should wash their hands regularly Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_atbrgl4_scenario1 <- df[df$ATBRGL4 %in% c(1, 3), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_atbrgl4_scenario1$HEALTH_SCIENCE <- ifelse(df_filtered_atbrgl4_scenario1$PROF11 == 0 | df_filtered_atbrgl4_scenario1$PROF12 == 0, "Health and Science", "Other Professions") # Create the contingency table table_atbrgl4_scenario1 <- table(df_filtered_atbrgl4_scenario1$ATBRGL4, df_filtered_atbrgl4_scenario1$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_atbrgl4_scenario1) <- c("Strongly Disagree", "Strongly Agree") # Perform the Chi-Squared test chi_result_atbrgl4_scenario1 <- chisq.test(table_atbrgl4_scenario1) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl4_scenario1 <- oddsratio(table_atbrgl4_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl4_scenario1, caption = "Contingency Table: Health and Science vs. Other Professions vs. Hand Washing Importance (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl4_scenario1) print(odds_ratio_atbrgl4_scenario1) ## Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_atbrgl4_scenario2 <- df[df$ATBRGL4 %in% c(2, 3), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_atbrgl4_scenario2$HEALTH_SCIENCE <- ifelse(df_filtered_atbrgl4_scenario2$PROF11 == 0 | df_filtered_atbrgl4_scenario2$PROF12 == 0, "Health and Science", "Other Professions") # Create the contingency table table_atbrgl4_scenario2 <- table(df_filtered_atbrgl4_scenario2$ATBRGL4, df_filtered_atbrgl4_scenario2$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_atbrgl4_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") # Perform the Chi-Squared test chi_result_atbrgl4_scenario2 <- chisq.test(table_atbrgl4_scenario2) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl4_scenario2 <- oddsratio(table_atbrgl4_scenario2, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl4_scenario2, caption = "Contingency Table: Health and Science vs. Other Professions vs. Hand Washing Importance (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl4_scenario2) print(odds_ratio_atbrgl4_scenario2) ## Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_atbrgl4_scenario3 <- df[df$ATBRGL4 %in% c(1, 2, 3), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_atbrgl4_scenario3$HEALTH_SCIENCE <- ifelse(df_filtered_atbrgl4_scenario3$PROF11 == 0 | df_filtered_atbrgl4_scenario3$PROF12 == 0, "Health and Science", "Other Professions") # Categorize responses into Strongly Agree vs. Strongly Disagree + Neither df_filtered_atbrgl4_scenario3$Disagree_Neither <- df_filtered_atbrgl4_scenario3$ATBRGL4 %in% c(1, 2) # Create the contingency table table_atbrgl4_scenario3 <- table(df_filtered_atbrgl4_scenario3$Disagree_Neither, df_filtered_atbrgl4_scenario3$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_atbrgl4_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") # Perform the Chi-Squared test chi_result_atbrgl4_scenario3 <- chisq.test(table_atbrgl4_scenario3) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl4_scenario3 <- oddsratio(table_atbrgl4_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl4_scenario3, caption = "Contingency Table: Health and Science vs. Other Professions vs. Hand Washing Importance (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl4_scenario3) print(odds_ratio_atbrgl4_scenario3) --------------------------------------------------------------------------------------------------------------------- #ATBRGL5 Doctors should only prescribe antibiotics when they are needed Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_atbrgl5_scenario1 <- df[df$ATBRGL5 %in% c(1, 3), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_atbrgl5_scenario1$HEALTH_SCIENCE <- ifelse(df_filtered_atbrgl5_scenario1$PROF11 == 0 | df_filtered_atbrgl5_scenario1$PROF12 == 0, "Health and Science", "Other Professions") # Create the contingency table table_atbrgl5_scenario1 <- table(df_filtered_atbrgl5_scenario1$ATBRGL5, df_filtered_atbrgl5_scenario1$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_atbrgl5_scenario1) <- c("Strongly Disagree", "Strongly Agree") # Perform the Chi-Squared test chi_result_atbrgl5_scenario1 <- chisq.test(table_atbrgl5_scenario1) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl5_scenario1 <- oddsratio(table_atbrgl5_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl5_scenario1, caption = "Contingency Table: Health and Science vs. Other Professions vs. Antibiotic Prescription Necessity (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl5_scenario1) print(odds_ratio_atbrgl5_scenario1) ## Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_atbrgl5_scenario2 <- df[df$ATBRGL5 %in% c(2, 3), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_atbrgl5_scenario2$HEALTH_SCIENCE <- ifelse(df_filtered_atbrgl5_scenario2$PROF11 == 0 | df_filtered_atbrgl5_scenario2$PROF12 == 0, "Health and Science", "Others") # Create the contingency table table_atbrgl5_scenario2 <- table(df_filtered_atbrgl5_scenario2$ATBRGL5, df_filtered_atbrgl5_scenario2$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_atbrgl5_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") # Perform the Chi-Squared test chi_result_atbrgl5_scenario2 <- chisq.test(table_atbrgl5_scenario2) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl5_scenario2 <- oddsratio(table_atbrgl5_scenario2, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl5_scenario2, caption = "Contingency Table: Health and Science vs. Others vs. Antibiotic Prescription Necessity (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl5_scenario2) print(odds_ratio_atbrgl5_scenario2) ## Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_atbrgl5_scenario3 <- df[df$ATBRGL5 %in% c(1, 2, 3), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_atbrgl5_scenario3$HEALTH_SCIENCE <- ifelse(df_filtered_atbrgl5_scenario3$PROF11 == 0 | df_filtered_atbrgl5_scenario3$PROF12 == 0, "Health and Science", "Other Education") # Categorize responses into Strongly Agree vs. Strongly Disagree + Neither df_filtered_atbrgl5_scenario3$Disagree_Neither <- df_filtered_atbrgl5_scenario3$ATBRGL5 %in% c(1, 2) # Create the contingency table table_atbrgl5_scenario3 <- table(df_filtered_atbrgl5_scenario3$Disagree_Neither, df_filtered_atbrgl5_scenario3$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_atbrgl5_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") # Perform the Chi-Squared test chi_result_atbrgl5_scenario3 <- chisq.test(table_atbrgl5_scenario3) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl5_scenario3 <- oddsratio(table_atbrgl5_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl5_scenario3, caption = "Contingency Table: Health and Science vs. Other Education vs. Antibiotic Prescription Necessity (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl5_scenario3) print(odds_ratio_atbrgl5_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##ATBRGL6= People should only use antibiotics when prescribed by a doctor or nurse Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified ## Scenario 1: Strongly Disagree vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_atbrgl6_scenario1 <- df[df$ATBRGL6 %in% c(1, 3), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_atbrgl6_scenario1$HEALTH_SCIENCE <- ifelse(df_filtered_atbrgl6_scenario1$PROF11 == 0 | df_filtered_atbrgl6_scenario1$PROF12 == 0, "Health and Science", "Other Education") # Create the contingency table table_atbrgl6_scenario1 <- table(df_filtered_atbrgl6_scenario1$ATBRGL6, df_filtered_atbrgl6_scenario1$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_atbrgl6_scenario1) <- c("Strongly Disagree", "Strongly Agree") # Perform the Chi-Squared test chi_result_atbrgl6_scenario1 <- chisq.test(table_atbrgl6_scenario1) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl6_scenario1 <- oddsratio(table_atbrgl6_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl6_scenario1, caption = "Contingency Table: Health and Science vs. Other Education vs. Antibiotic only when prescribed (Strongly Agree vs. Strongly Disagree)")) print(chi_result_atbrgl6_scenario1) print(odds_ratio_atbrgl6_scenario1) ## Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_atbrgl6_scenario2 <- df[df$ATBRGL6 %in% c(2, 3), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_atbrgl6_scenario2$HEALTH_SCIENCE <- ifelse(df_filtered_atbrgl6_scenario2$PROF11 == 0 | df_filtered_atbrgl6_scenario2$PROF12 == 0, "Health and Science", "Other Education") # Create the contingency table table_atbrgl6_scenario2 <- table(df_filtered_atbrgl6_scenario2$ATBRGL6, df_filtered_atbrgl6_scenario2$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_atbrgl6_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") # Perform the Chi-Squared test chi_result_atbrgl6_scenario2 <- chisq.test(table_atbrgl6_scenario2) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl6_scenario2 <- oddsratio(table_atbrgl6_scenario2, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl6_scenario2, caption = "Contingency Table: Health and Science vs. Other Education vs. Antibiotic only when prescribed (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_atbrgl6_scenario2) print(odds_ratio_atbrgl6_scenario2) ## Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_atbrgl6_scenario3 <- df[df$ATBRGL6 %in% c(1, 2, 3), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_atbrgl6_scenario3$HEALTH_SCIENCE <- ifelse(df_filtered_atbrgl6_scenario3$PROF11 == 0 | df_filtered_atbrgl6_scenario3$PROF12 == 0, "Health and Science", "Other Education") # Categorize responses into Strongly Agree vs. Strongly Disagree + Neither df_filtered_atbrgl6_scenario3$Disagree_Neither <- df_filtered_atbrgl6_scenario3$ATBRGL6 %in% c(1, 2) # Create the contingency table table_atbrgl6_scenario3 <- table(df_filtered_atbrgl6_scenario3$Disagree_Neither, df_filtered_atbrgl6_scenario3$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_atbrgl6_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") # Perform the Chi-Squared test chi_result_atbrgl6_scenario3 <- chisq.test(table_atbrgl6_scenario3) # Calculate the odds ratio and confidence interval odds_ratio_atbrgl6_scenario3 <- oddsratio(table_atbrgl6_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table print(kable(table_atbrgl6_scenario3, caption = "Contingency Table: Health and Science vs. Other Education vs. Antibiotic only when prescribed (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_atbrgl6_scenario3) print(odds_ratio_atbrgl6_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM1= Antibiotic resistance is one of the biggest problems the world faces Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Disagree vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_resdim1_scenario1 <- df[df$RESDIM1 %in% c(1, 3), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_resdim1_scenario1$HEALTH_SCIENCE <- ifelse(df_filtered_resdim1_scenario1$PROF11 == 0 | df_filtered_resdim1_scenario1$PROF12 == 0, "Health and Science", "Other Education") # Create the contingency table table_resdim1_scenario1 <- table(df_filtered_resdim1_scenario1$RESDIM1, df_filtered_resdim1_scenario1$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_resdim1_scenario1) <- c("Strongly Disagree", "Strongly Agree") # Perform the Chi-Squared test chi_result_resdim1_scenario1 <- chisq.test(table_resdim1_scenario1) # Calculate the odds ratio and confidence interval odds_ratio_resdim1_scenario1 <- oddsratio(table_resdim1_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table and results print(knitr::kable(table_resdim1_scenario1, caption = "Contingency Table: Health and Science vs. Other Education vs. Perception of Antibiotic Resistance as a Global Problem (Strongly Agree vs. Strongly Disagree)")) print(chi_result_resdim1_scenario1) print(odds_ratio_resdim1_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_resdim1_scenario2 <- df[df$RESDIM1 %in% c(2, 3), ] # Create the HEALTH_SCIENCE variable df_filtered_resdim1_scenario2$HEALTH_SCIENCE <- ifelse(df_filtered_resdim1_scenario2$PROF11 == 0 | df_filtered_resdim1_scenario2$PROF12 == 0, "Health and Science", "Other Education") # Create the contingency table table_resdim1_scenario2 <- table(df_filtered_resdim1_scenario2$RESDIM1, df_filtered_resdim1_scenario2$HEALTH_SCIENCE) # Add descriptive labels rownames(table_resdim1_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") # Perform the Chi-Squared test chi_result_resdim1_scenario2 <- chisq.test(table_resdim1_scenario2) # Calculate odds ratio and confidence interval odds_ratio_resdim1_scenario2 <- oddsratio(table_resdim1_scenario2, conf.level = 0.95)$measure # Print the table and results print(knitr::kable(table_resdim1_scenario2, caption = "Contingency Table: Health and Science vs. Other Education vs. Perception of Antibiotic Resistance as a Global Problem (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim1_scenario2) print(odds_ratio_resdim1_scenario2) # Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_resdim1_scenario3 <- df[df$RESDIM1 %in% c(1, 2, 3), ] # Create the HEALTH_SCIENCE variable df_filtered_resdim1_scenario3$HEALTH_SCIENCE <- ifelse(df_filtered_resdim1_scenario3$PROF11 == 0 | df_filtered_resdim1_scenario3$PROF12 == 0, "Health and Science", "Other Education") # Categorize responses df_filtered_resdim1_scenario3$Disagree_Neither <- df_filtered_resdim1_scenario3$RESDIM1 %in% c(1, 2) # Create the contingency table table_resdim1_scenario3 <- table(df_filtered_resdim1_scenario3$Disagree_Neither, df_filtered_resdim1_scenario3$HEALTH_SCIENCE) # Add descriptive labels rownames(table_resdim1_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") # Perform the Chi-Squared test chi_result_resdim1_scenario3 <- chisq.test(table_resdim1_scenario3) # Calculate odds ratio and confidence interval odds_ratio_resdim1_scenario3 <- oddsratio(table_resdim1_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table and results print(knitr::kable(table_resdim1_scenario3, caption = "Contingency Table: Health and Science vs. Other Education vs. Perception of Antibiotic Resistance as a Global Problem (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_resdim1_scenario3) print(odds_ratio_resdim1_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM2= Medical experts will solve the problem of antibiotic resistance before it becomes too serious Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Load the Database_simplified dataframe df <- read_excel("C:/Database_simplified.xlsx") # Scenario 1: Strongly Agree vs. Strongly Disagree # Load dataframe df <- Database_simplified df_filtered_resdim2_scenario1 <- df[df$RESDIM2 %in% c(1, 3), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_resdim2_scenario1$HEALTH_SCIENCE <- ifelse(df_filtered_resdim2_scenario1$PROF11 == 0 | df_filtered_resdim2_scenario1$PROF12 == 0, "Health and Science", "Other Education") # Create the contingency table table_resdim2_scenario1 <- table(df_filtered_resdim2_scenario1$RESDIM2, df_filtered_resdim2_scenario1$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_resdim2_scenario1) <- c("Strongly Disagree", "Strongly Agree") # Perform the Chi-Squared test chi_result_resdim2_scenario1 <- chisq.test(table_resdim2_scenario1) # Calculate the odds ratio and confidence interval odds_ratio_resdim2_scenario1 <- oddsratio(table_resdim2_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table and results print(knitr::kable(table_resdim2_scenario1, caption = "Contingency Table: Health and Science vs. Other Education vs. Belief in Solving Antibiotic Resistance (Strongly Disagree vs. Strongly Agree)")) print(chi_result_resdim2_scenario1) print(odds_ratio_resdim2_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Disagree # Load dataframe df <- Database_simplified df_filtered_resdim2_scenario2 <- df[df$RESDIM2 %in% c(1, 2), ] # Create the HEALTH_SCIENCE variable df_filtered_resdim2_scenario2$HEALTH_SCIENCE <- ifelse(df_filtered_resdim2_scenario2$PROF11 == 0 | df_filtered_resdim2_scenario2$PROF12 == 0, "Health and Science", "Other Education") # Create the contingency table table_resdim2_scenario2 <- table(df_filtered_resdim2_scenario2$RESDIM2, df_filtered_resdim2_scenario2$HEALTH_SCIENCE) # Add descriptive labels rownames(table_resdim2_scenario2) <- c("Strongly Disagree", "Neither Agree Nor Disagree") # Perform the Chi-Squared test chi_result_resdim2_scenario2 <- chisq.test(table_resdim2_scenario2) # Calculate odds ratio and confidence interval odds_ratio_resdim2_scenario2 <- oddsratio(table_resdim2_scenario2, conf.level = 0.95)$measure # Print the table and results print(knitr::kable(table_resdim2_scenario2, caption = "Contingency Table: Health and Science vs. Other Education vs. Belief in Solving Antibiotic Resistance (Strongly Disagree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim2_scenario2) print(odds_ratio_resdim2_scenario2) # Scenario 3: Strongly Agree + Neither Agree Nor Disagree vs. Strongly Disagree # Load dataframe df <- Database_simplified df_filtered_resdim2_scenario3 <- df[df$RESDIM2 %in% c(1, 2, 3), ] # Create the HEALTH_SCIENCE variable df_filtered_resdim2_scenario3$HEALTH_SCIENCE <- ifelse(df_filtered_resdim2_scenario3$PROF11 == 0 | df_filtered_resdim2_scenario3$PROF12 == 0, "Health and Science", "Other Education") # Categorize responses df_filtered_resdim2_scenario3$Agree_Neither <- df_filtered_resdim2_scenario3$RESDIM2 %in% c(2, 3) # Create the contingency table table_resdim2_scenario3 <- table(df_filtered_resdim2_scenario3$Agree_Neither, df_filtered_resdim2_scenario3$HEALTH_SCIENCE) # Add descriptive labels rownames(table_resdim2_scenario3) <- c("Strongly Disagree", "Strongly Agree + Neither") # Perform the Chi-Squared test chi_result_resdim2_scenario3 <- chisq.test(table_resdim2_scenario3) # Calculate odds ratio and confidence interval odds_ratio_resdim2_scenario3 <- oddsratio(table_resdim2_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table and results print(knitr::kable(table_resdim2_scenario3, caption = "Contingency Table: Health and Science vs. Other Education vs. Belief in Solving Antibiotic Resistance (Strongly Disagree vs. Strongly Agree + Neither Agree Nor Disagree)")) print(chi_result_resdim2_scenario3) print(odds_ratio_resdim2_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM3= Everyone needs to use antibiotics responsibly Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Disagree vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_resdim3_scenario1 <- df[df$RESDIM3 %in% c(1, 3), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_resdim3_scenario1$HEALTH_SCIENCE <- ifelse(df_filtered_resdim3_scenario1$PROF11 == 0 | df_filtered_resdim3_scenario1$PROF12 == 0, "Health and Science", "Other Education") # Create the contingency table table_resdim3_scenario1 <- table(df_filtered_resdim3_scenario1$RESDIM3, df_filtered_resdim3_scenario1$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_resdim3_scenario1) <- c("Strongly Disagree", "Strongly Agree") # Perform the Chi-Squared test chi_result_resdim3_scenario1 <- chisq.test(table_resdim3_scenario1) # Calculate the odds ratio and confidence interval odds_ratio_resdim3_scenario1 <- oddsratio(table_resdim3_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table and results print(knitr::kable(table_resdim3_scenario1, caption = "Contingency Table: Health and Science vs. Other Education vs. Everyone needs to use antibiotics responsibly (Strongly Agree vs. Strongly Disagree)")) print(chi_result_resdim3_scenario1) print(odds_ratio_resdim3_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_resdim3_scenario2 <- df[df$RESDIM3 %in% c(2, 3), ] # Create the HEALTH_SCIENCE variable df_filtered_resdim3_scenario2$HEALTH_SCIENCE <- ifelse(df_filtered_resdim3_scenario2$PROF11 == 0 | df_filtered_resdim3_scenario2$PROF12 == 0, "Health and Science", "Other Education") # Create the contingency table table_resdim3_scenario2 <- table(df_filtered_resdim3_scenario2$RESDIM3, df_filtered_resdim3_scenario2$HEALTH_SCIENCE) # Add descriptive labels rownames(table_resdim3_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") # Perform the Chi-Squared test chi_result_resdim3_scenario2 <- chisq.test(table_resdim3_scenario2) # Calculate odds ratio and confidence interval odds_ratio_resdim3_scenario2 <- oddsratio(table_resdim3_scenario2, conf.level = 0.95)$measure # Print the table and results print(knitr::kable(table_resdim3_scenario2, caption = "Contingency Table: Health and Science vs. Other Education vs. Everyone needs to use antibiotics responsibly (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim3_scenario2) print(odds_ratio_resdim3_scenario2) # Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_resdim3_scenario3 <- df[df$RESDIM3 %in% c(1, 2, 3), ] # Create the HEALTH_SCIENCE variable df_filtered_resdim3_scenario3$HEALTH_SCIENCE <- ifelse(df_filtered_resdim3_scenario3$PROF11 == 0 | df_filtered_resdim3_scenario3$PROF12 == 0, "Health and Science", "Other Education") # Categorize responses df_filtered_resdim3_scenario3$Disagree_Neither <- df_filtered_resdim3_scenario3$RESDIM3 %in% c(1, 2) # Create the contingency table table_resdim3_scenario3 <- table(df_filtered_resdim3_scenario3$Disagree_Neither, df_filtered_resdim3_scenario3$HEALTH_SCIENCE) # Add descriptive labels rownames(table_resdim3_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") # Perform the Chi-Squared test chi_result_resdim3_scenario3 <- chisq.test(table_resdim3_scenario3) # Calculate odds ratio and confidence interval odds_ratio_resdim3_scenario3 <- oddsratio(table_resdim3_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table and results print(knitr::kable(table_resdim3_scenario3, caption = "Contingency Table: Health and Science vs. Other Education vs. Everyone needs to use antibiotics responsibly (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_resdim3_scenario3) print(odds_ratio_resdim3_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM4= People like me can't do much to stop antibiotic resistance Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Agree vs. Strongly Disagree # Load dataframe df <- Database_simplified df_filtered_resdim4_scenario1 <- df[df$RESDIM4 %in% c(1, 3), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_resdim4_scenario1$HEALTH_SCIENCE <- ifelse(df_filtered_resdim4_scenario1$PROF11 == 0 | df_filtered_resdim4_scenario1$PROF12 == 0, "Health and Science", "Other Education") # Create the contingency table table_resdim4_scenario1 <- table(df_filtered_resdim4_scenario1$RESDIM4, df_filtered_resdim4_scenario1$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_resdim4_scenario1) <- c("Strongly Disagree", "Strongly Agree") # Perform the Chi-Squared test chi_result_resdim4_scenario1 <- chisq.test(table_resdim4_scenario1) # Calculate the odds ratio and confidence interval odds_ratio_resdim4_scenario1 <- oddsratio(table_resdim4_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table and results print(knitr::kable(table_resdim4_scenario1, caption = "Contingency Table: Health and Science vs. Other Education vs. Belief in Individual Impact on Antibiotic Resistance (Strongly Disagree vs. Strongly Agree)")) print(chi_result_resdim4_scenario1) print(odds_ratio_resdim4_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Disagree # Load dataframe df <- Database_simplified df_filtered_resdim4_scenario2 <- df[df$RESDIM4 %in% c(1, 2), ] # Create the HEALTH_SCIENCE variable df_filtered_resdim4_scenario2$HEALTH_SCIENCE <- ifelse(df_filtered_resdim4_scenario2$PROF11 == 0 | df_filtered_resdim4_scenario2$PROF12 == 0, "Health and Science", "Other Education") # Create the contingency table table_resdim4_scenario2 <- table(df_filtered_resdim4_scenario2$RESDIM4, df_filtered_resdim4_scenario2$HEALTH_SCIENCE) # Add descriptive labels rownames(table_resdim4_scenario2) <- c("Strongly Disagree", "Neither Agree Nor Disagree") # Perform the Chi-Squared test chi_result_resdim4_scenario2 <- chisq.test(table_resdim4_scenario2) # Calculate odds ratio and confidence interval odds_ratio_resdim4_scenario2 <- oddsratio(table_resdim4_scenario2, conf.level = 0.95)$measure # Print the table and results print(knitr::kable(table_resdim4_scenario2, caption = "Contingency Table: Health and Science vs. Other Education vs. Belief in Individual Impact on Antibiotic Resistance (Strongly Disagree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim4_scenario2) print(odds_ratio_resdim4_scenario2) # Scenario 3: Strongly Agree + Neither Agree Nor Disagree vs. Strongly Disagree # Load dataframe df <- Database_simplified df_filtered_resdim4_scenario3 <- df[df$RESDIM4 %in% c(1, 2, 3), ] # Create the HEALTH_SCIENCE variable df_filtered_resdim4_scenario3$HEALTH_SCIENCE <- ifelse(df_filtered_resdim4_scenario3$PROF11 == 0 | df_filtered_resdim4_scenario3$PROF12 == 0, "Health and Science", "Other Education") # Categorize responses df_filtered_resdim4_scenario3$Agree_Neither <- df_filtered_resdim4_scenario3$RESDIM4 %in% c(2, 3) # Create the contingency table table_resdim4_scenario3 <- table(df_filtered_resdim4_scenario3$Agree_Neither, df_filtered_resdim4_scenario3$HEALTH_SCIENCE) # Add descriptive labels rownames(table_resdim4_scenario3) <- c("Strongly Disagree", "Strongly Agree + Neither") # Perform the Chi-Squared test chi_result_resdim4_scenario3 <- chisq.test(table_resdim4_scenario3) # Calculate odds ratio and confidence interval odds_ratio_resdim4_scenario3 <- oddsratio(table_resdim4_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table and results print(knitr::kable(table_resdim4_scenario3, caption = "Contingency Table: Health and Science vs. Other Education vs. Belief in Individual Impact on Antibiotic Resistance (Strongly Disagree vs. Strongly Agree + Neither Agree Nor Disagree)")) print(chi_result_resdim4_scenario3) print(odds_ratio_resdim4_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM5= I am worried about the impact that antibiotic resistance will have on my health and that of my family Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Disagree vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_resdim5_scenario1 <- df[df$RESDIM5 %in% c(1, 3), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_resdim5_scenario1$HEALTH_SCIENCE <- ifelse(df_filtered_resdim5_scenario1$PROF11 == 0 | df_filtered_resdim5_scenario1$PROF12 == 0, "Health and Science", "Other Education") # Create the contingency table table_resdim5_scenario1 <- table(df_filtered_resdim5_scenario1$RESDIM5, df_filtered_resdim5_scenario1$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_resdim5_scenario1) <- c("Strongly Disagree", "Strongly Agree") # Perform the Chi-Squared test chi_result_resdim5_scenario1 <- chisq.test(table_resdim5_scenario1) # Calculate the odds ratio and confidence interval odds_ratio_resdim5_scenario1 <- oddsratio(table_resdim5_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table and results print(knitr::kable(table_resdim5_scenario1, caption = "Contingency Table: Health and Science vs. Other Education vs. Impact of AMR on personal health and that of their family (Strongly Agree vs. Strongly Disagree)")) print(chi_result_resdim5_scenario1) print(odds_ratio_resdim5_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_resdim5_scenario2 <- df[df$RESDIM5 %in% c(2, 3), ] # Create the HEALTH_SCIENCE variable df_filtered_resdim5_scenario2$HEALTH_SCIENCE <- ifelse(df_filtered_resdim5_scenario2$PROF11 == 0 | df_filtered_resdim5_scenario2$PROF12 == 0, "Health and Science", "Other Education") # Create the contingency table table_resdim5_scenario2 <- table(df_filtered_resdim5_scenario2$RESDIM5, df_filtered_resdim5_scenario2$HEALTH_SCIENCE) # Add descriptive labels rownames(table_resdim5_scenario2) <- c("Neither Agree Nor Disagree", "Strongly Agree") # Perform the Chi-Squared test chi_result_resdim5_scenario2 <- chisq.test(table_resdim5_scenario2) # Calculate odds ratio and confidence interval odds_ratio_resdim5_scenario2 <- oddsratio(table_resdim5_scenario2, conf.level = 0.95)$measure # Print the table and results print(knitr::kable(table_resdim5_scenario2, caption = "Contingency Table: Health and Science vs. Other Education vs. Impact of AMR on personal health and that of their family (Strongly Agree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim5_scenario2) print(odds_ratio_resdim5_scenario2) # Scenario 3: Strongly Disagree + Neither Agree Nor Disagree vs. Strongly Agree # Load dataframe df <- Database_simplified df_filtered_resdim5_scenario3 <- df[df$RESDIM5 %in% c(1, 2, 3), ] # Create the HEALTH_SCIENCE variable df_filtered_resdim5_scenario3$HEALTH_SCIENCE <- ifelse(df_filtered_resdim5_scenario3$PROF11 == 0 | df_filtered_resdim5_scenario3$PROF12 == 0, "Health and Science", "Other Education") # Categorize responses df_filtered_resdim5_scenario3$Disagree_Neither <- df_filtered_resdim5_scenario3$RESDIM5 %in% c(1, 2) # Create the contingency table table_resdim5_scenario3 <- table(df_filtered_resdim5_scenario3$Disagree_Neither, df_filtered_resdim5_scenario3$HEALTH_SCIENCE) # Add descriptive labels rownames(table_resdim5_scenario3) <- c("Strongly Agree", "Strongly Disagree + Neither") # Perform the Chi-Squared test chi_result_resdim5_scenario3 <- chisq.test(table_resdim5_scenario3) # Calculate odds ratio and confidence # Calculate odds ratio and confidence interval odds_ratio_resdim5_scenario3 <- oddsratio(table_resdim5_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table and results print(knitr::kable(table_resdim5_scenario3, caption = "Contingency Table: Health and Science vs. Other Education vs. Impact of AMR on personal health and that of their family (Strongly Agree vs. Strongly Disagree + Neither Agree Nor Disagree)")) print(chi_result_resdim5_scenario3) print(odds_ratio_resdim5_scenario3) ---------------------------------------------------------------------------------------------------------------------- ##RESDIM6= I am not at risk of getting an antibiotic-resistant infection, as long as I take my antibiotics correctly Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified dataframe df <- Database_simplified # Scenario 1: Strongly Agree vs. Strongly Disagree # Load dataframe df <- Database_simplified df_filtered_resdim6_scenario1 <- df[df$RESDIM6 %in% c(1, 3), ] # Create the HEALTH_SCIENCE variable based on PROF11 and PROF12 df_filtered_resdim6_scenario1$HEALTH_SCIENCE <- ifelse(df_filtered_resdim6_scenario1$PROF11 == 0 | df_filtered_resdim6_scenario1$PROF12 == 0, "Health and Science", "Other Education") # Create the contingency table table_resdim6_scenario1 <- table(df_filtered_resdim6_scenario1$RESDIM6, df_filtered_resdim6_scenario1$HEALTH_SCIENCE) # Add descriptive labels to the rows rownames(table_resdim6_scenario1) <- c("Strongly Disagree", "Strongly Agree") # Perform the Chi-Squared test chi_result_resdim6_scenario1 <- chisq.test(table_resdim6_scenario1) # Calculate the odds ratio and confidence interval odds_ratio_resdim6_scenario1 <- oddsratio(table_resdim6_scenario1, conf.level = 0.95)$measure # Print the formatted contingency table and results print(knitr::kable(table_resdim6_scenario1, caption = "Contingency Table: Health and Science vs. Other Education vs. Perception of Risk of Antibiotic-Resistant Infection (Strongly Disagree vs. Strongly Agree)")) print(chi_result_resdim6_scenario1) print(odds_ratio_resdim6_scenario1) # Scenario 2: Neither Agree Nor Disagree vs. Strongly Disagree # Load dataframe df <- Database_simplified df_filtered_resdim6_scenario2 <- df[df$RESDIM6 %in% c(1, 2), ] # Create the HEALTH_SCIENCE variable df_filtered_resdim6_scenario2$HEALTH_SCIENCE <- ifelse(df_filtered_resdim6_scenario2$PROF11 == 0 | df_filtered_resdim6_scenario2$PROF12 == 0, "Health and Science", "Other Education") # Create the contingency table table_resdim6_scenario2 <- table(df_filtered_resdim6_scenario2$RESDIM6, df_filtered_resdim6_scenario2$HEALTH_SCIENCE) # Add descriptive labels rownames(table_resdim6_scenario2) <- c("Strongly Disagree", "Neither Agree Nor Disagree") # Perform the Chi-Squared test chi_result_resdim6_scenario2 <- chisq.test(table_resdim6_scenario2) # Calculate odds ratio and confidence interval odds_ratio_resdim6_scenario2 <- oddsratio(table_resdim6_scenario2, conf.level = 0.95)$measure # Print the table and results print(knitr::kable(table_resdim6_scenario2, caption = "Contingency Table: Health and Science vs. Other Education vs. Perception of Risk of Antibiotic-Resistant Infection (Strongly Disagree vs. Neither Agree Nor Disagree)")) print(chi_result_resdim6_scenario2) print(odds_ratio_resdim6_scenario2) # Scenario 3: Strongly Agree + Neither Agree Nor Disagree vs. Strongly Disagree # Load dataframe df <- Database_simplified df_filtered_resdim6_scenario3 <- df[df$RESDIM6 %in% c(1, 2, 3), ] # Create the HEALTH_SCIENCE variable df_filtered_resdim6_scenario3$HEALTH_SCIENCE <- ifelse(df_filtered_resdim6_scenario3$PROF11 == 0 | df_filtered_resdim6_scenario3$PROF12 == 0, "Health and Science", "Other Education") # Categorize responses df_filtered_resdim6_scenario3$Agree_Neither <- df_filtered_resdim6_scenario3$RESDIM6 %in% c(2, 3) # Create the contingency table table_resdim6_scenario3 <- table(df_filtered_resdim6_scenario3$Agree_Neither, df_filtered_resdim6_scenario3$HEALTH_SCIENCE) # Add descriptive labels rownames(table_resdim6_scenario3) <- c("Strongly Disagree", "Strongly Agree + Neither") # Perform the Chi-Squared test chi_result_resdim6_scenario3 <- chisq.test(table_resdim6_scenario3) # Calculate odds ratio and # Calculate odds ratio and confidence interval odds_ratio_resdim6_scenario3 <- oddsratio(table_resdim6_scenario3, conf.level = 0.95)$measure # Print the formatted contingency table and results print(knitr::kable(table_resdim6_scenario3, caption = "Contingency Table: Health and Science vs. Other Education vs. Perception of Risk of Antibiotic-Resistant Infection (Strongly Disagree vs. Strongly Agree + Neither Agree Nor Disagree)")) print(chi_result_resdim6_scenario3) print(odds_ratio_resdim6_scenario3) ########################################################## Multivariate Analysis ############################# # Load necessary packages install.packages("car") library(car) install.packages("readxl") library(readxl) #Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified into a dataframe df <- Database_simplified ###### CUSIN1 ######## # Preparing the variables df$CUSIN1 <- as.factor(ifelse(df$CUSIN2 %in% c(0, 1), df$CUSIN1, NA)) # Keep only Yes (0) and No (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Removing rows with NA in the variables of interest df <- na.omit(df) # Building the logistic regression model model <- glm(CUSIN1 ~ AGE + HEALTH_SCIENCE, data = df, family = binomial()) # Checking the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison # Alternative model with only AGE for CUSIN1 alternative_model1_CUSIN1 <- glm(CUSIN1 ~ AGE, data = df, family = binomial()) # Alternative model with only HEALTH_SCIENCE for CUSIN1 alternative_model2_CUSIN1 <- glm(CUSIN1 ~ HEALTH_SCIENCE, data = df, family = binomial()) # Compare AIC of the main model with the alternative models aic_values_CUSIN1 <- AIC(model, alternative_model1_CUSIN1, alternative_model2_CUSIN1) print(aic_values_CUSIN1) ###### CUSIN2 ####### #Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified into a dataframe df <- Database_simplified # Preparing the variables df$CUSIN2 <- as.factor(ifelse(df$CUSIN2 %in% c(0, 1), df$CUSIN2, NA)) # Keep only Yes (0) and No (1) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Femme (0) and Homme (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Removing rows with NA in the variables of interest df <- na.omit(df) # Building the logistic regression model model <- glm(CUSIN2 ~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df, family = binomial()) # Checking the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison # Model with only GENRE and AGE alternative_model1 <- glm(CUSIN2 ~ GENRE + AGE, data = df, family = binomial()) # Model with only GENRE and NIVSCOL alternative_model2 <- glm(CUSIN2 ~ GENRE + NIVSCOL, data = df, family = binomial()) # Model with only AGE and NIVSCOL alternative_model3 <- glm(CUSIN2 ~ AGE + NIVSCOL, data = df, family = binomial()) # Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(CUSIN2 ~ GENRE + AGE + NIVSCOL, data = df, family = binomial()) # Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(CUSIN2 ~ GENRE + HEALTH_SCIENCE, data = df, family = binomial()) # Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(CUSIN2 ~ AGE + HEALTH_SCIENCE, data = df, family = binomial()) # Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(CUSIN2 ~ NIVSCOL + HEALTH_SCIENCE, data = df, family = binomial()) # Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) ###### CUSIN3 ####### #Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified into a dataframe df <- Database_simplified # Preparing the variables df$CUSIN3 <- as.factor(ifelse(df$CUSIN3 %in% c(0, 1), df$CUSIN3, NA)) # Keep only Yes (0) and No (1) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Femme (0) and Homme (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Removing rows with NA in the variables of interest df <- na.omit(df) # Building the logistic regression model model <- glm(CUSIN3 ~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df, family = binomial()) # Checking the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison # Model with only GENRE and AGE alternative_model1 <- glm(CUSIN3 ~ GENRE + AGE, data = df, family = binomial()) # Model with only GENRE and NIVSCOL alternative_model2 <- glm(CUSIN3 ~ GENRE + NIVSCOL, data = df, family = binomial()) # Model with only AGE and NIVSCOL alternative_model3 <- glm(CUSIN3 ~ AGE + NIVSCOL, data = df, family = binomial()) # Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(CUSIN3 ~ GENRE + AGE + NIVSCOL, data = df, family = binomial()) # Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(CUSIN3 ~ GENRE + HEALTH_SCIENCE, data = df, family = binomial()) # Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(CUSIN3 ~ AGE + HEALTH_SCIENCE, data = df, family = binomial()) # Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(CUSIN3 ~ NIVSCOL + HEALTH_SCIENCE, data = df, family = binomial()) # Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) ###### CUSIN4 ####### #Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified into a dataframe df <- Database_simplified # Preparing the variables df$CUSIN4 <- as.factor(ifelse(df$CUSIN4 %in% c(0, 1), df$CUSIN4, NA)) # Keep only Yes (0) and No (1) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Femme (0) and Homme (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Removing rows with NA in the variables of interest df <- na.omit(df) # Building the logistic regression model model <- glm(CUSIN4 ~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df, family = binomial()) # Checking the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison # Model with only GENRE and AGE alternative_model1 <- glm(CUSIN4 ~ GENRE + AGE, data = df, family = binomial()) # Model with only GENRE and NIVSCOL alternative_model2 <- glm(CUSIN4 ~ GENRE + NIVSCOL, data = df, family = binomial()) # Model with only AGE and NIVSCOL alternative_model3 <- glm(CUSIN4 ~ AGE + NIVSCOL, data = df, family = binomial()) # Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(CUSIN4 ~ GENRE + AGE + NIVSCOL, data = df, family = binomial()) # Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(CUSIN4 ~ GENRE + HEALTH_SCIENCE, data = df, family = binomial()) # Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(CUSIN4 ~ AGE + HEALTH_SCIENCE, data = df, family = binomial()) # Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(CUSIN4 ~ NIVSCOL + HEALTH_SCIENCE, data = df, family = binomial()) # Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) ###### CUSIN5 ####### #Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified into a dataframe df <- Database_simplified # Preparing the variables df$CUSIN5 <- as.factor(ifelse(df$CUSIN5 %in% c(0, 1), df$CUSIN5, NA)) # Keep only Yes (0) and No (1) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Femme (0) and Homme (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) # Removing rows with NA in the variables of interest df <- na.omit(df) # Building the logistic regression model model <- glm(CUSIN5 ~ GENRE + AGE + NIVSCOL , data = df, family = binomial()) # Checking the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison # Model with only GENRE and AGE alternative_model1 <- glm(CUSIN5 ~ GENRE + AGE, data = df, family = binomial()) # Model with only GENRE and NIVSCOL alternative_model2 <- glm(CUSIN5 ~ GENRE + NIVSCOL, data = df, family = binomial()) # Model with only AGE and NIVSCOL alternative_model3 <- glm(CUSIN5 ~ AGE + NIVSCOL, data = df, family = binomial()) # Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(CUSIN5 ~ GENRE + AGE + NIVSCOL, data = df, family = binomial()) # Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4) print(aic_values) ###### CUSIN6 ####### #Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") #View(Database_simplified) # Load the Database_simplified into a dataframe df <- Database_simplified # Preparing the variables df$CUSIN6 <- as.factor(ifelse(df$CUSIN6 %in% c(0, 1), df$CUSIN6, NA)) # Keep only Yes (0) and No (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Removing rows with NA in the variables of interest df <- na.omit(df) # Building the logistic regression model model <- glm(CUSIN6 ~ AGE + NIVSCOL + HEALTH_SCIENCE , data = df, family = binomial()) # Checking the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison # Model with only AGE and NIVSCOL alternative_model1 <- glm(CUSIN6 ~ AGE + NIVSCOL, data = df, family = binomial()) # Model with GENRE, AGE, and NIVSCOL alternative_model2 <- glm(CUSIN6 ~ GENRE + AGE + NIVSCOL, data = df, family = binomial()) # Model with AGE and HEALTH_SCIENCE alternative_model3 <- glm(CUSIN6 ~ AGE + HEALTH_SCIENCE, data = df, family = binomial()) # Model with NIVSCOL and HEALTH_SCIENCE alternative_model4 <- glm(CUSIN6 ~ NIVSCOL + HEALTH_SCIENCE, data = df, family = binomial()) # Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4) print(aic_values) ###### PRESCATB1 ####### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$PRESCATB1 <- as.factor(ifelse(df$PRESCATB1 %in% c(0, 1, 3), df$PRESCATB1, NA)) # Keep only Yes (0), No (1), and Sometimes (3) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Create a combined 'No_Sometimes' variable for PRESCATB1 df$No_Sometimes <- df$PRESCATB1 %in% c(1, 3) # Remove rows with NA in the variables of interest df <- na.omit(df) # Build the logistic regression model model <- glm(No_Sometimes ~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison # Model with only GENRE and AGE alternative_model1 <- glm(No_Sometimes ~ GENRE + AGE, data = df, family = binomial()) # Model with only GENRE and NIVSCOL alternative_model2 <- glm(No_Sometimes ~ GENRE + NIVSCOL, data = df, family = binomial()) # Model with only AGE and NIVSCOL alternative_model3 <- glm(No_Sometimes ~ AGE + NIVSCOL, data = df, family = binomial()) # Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(No_Sometimes ~ GENRE + AGE + NIVSCOL, data = df, family = binomial()) # Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(No_Sometimes ~ GENRE + HEALTH_SCIENCE, data = df, family = binomial()) # Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(No_Sometimes ~ AGE + HEALTH_SCIENCE, data = df, family = binomial()) # Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(No_Sometimes ~ NIVSCOL + HEALTH_SCIENCE, data = df, family = binomial()) # Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) #### ARRETATB #### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$ARRETATB <- as.factor(ifelse(df$ARRETATB %in% c(0, 2), df$ARRETATB, NA)) #Keep only Always (0) and Sometimes (2) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Create a combined 'Sometimes_Always' variable for ARRETATB df$Sometimes_Always <- df$ARRETATB %in% c(0, 2) # Remove rows with NA in the variables of interest df <- na.omit(df) # Build the logistic regression model model <- glm(Sometimes_Always ~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) #### ATBORAL #### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$ATBORAL1 <- as.factor(ifelse(df$ATBORAL1 %in% c(0, 1), df$ATBORAL1, NA)) # Keep only Yes (0) and No (1) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'Yes' and 'No' in ATBORAL1 df_filtered_atboral1 <- df[df$ATBORAL1 %in% c(0, 1), ] # Remove rows with NA in the variables of interest df_filtered_atboral1 <- na.omit(df_filtered_atboral1) # Build the logistic regression model model <- glm(ATBORAL1 ~ GENRE + AGE + HEALTH_SCIENCE, data = df_filtered_atboral1, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) #Fit alternative models for AIC comparison #Model with only GENRE and AGE alternative_model1 <- glm(ATBORAL1 ~ GENRE + AGE, data = df_filtered_atboral1, family = binomial()) #Model with GENRE and HEALTH_SCIENCE alternative_model2 <- glm(ATBORAL1 ~ GENRE + HEALTH_SCIENCE, data = df_filtered_atboral1, family = binomial()) #Model with AGE and HEALTH_SCIENCE alternative_model3 <- glm(ATBORAL1 ~ AGE + HEALTH_SCIENCE, data = df_filtered_atboral1, family = binomial()) #Model with NIVSCOL and HEALTH_SCIENCE alternative_model4 <- glm(ATBORAL1 ~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_atboral1, family = binomial()) #Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4) print(aic_values) ##### ATBANI1 #### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$ATBANI1 <- as.factor(ifelse(df$ATBANI1 %in% c(0, 1), df$ATBANI1, NA)) # Keep only True (0) and False (1) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'True' and 'False' in ATBANI1 df_filtered_atbani1 <- df[df$ATBANI1 %in% c(0, 1), ] # Remove rows with NA in the variables of interest df_filtered_atbani1 <- na.omit(df_filtered_atbani1) # Build the logistic regression model model <- glm(ATBANI1 ~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_atbani1, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison # Model with only GENRE and AGE alternative_model1 <- glm(ATBANI1 ~ GENRE + AGE, data = df_filtered_atbani1, family = binomial()) # Model with only GENRE and NIVSCOL alternative_model2 <- glm(ATBANI1 ~ GENRE + NIVSCOL, data = df_filtered_atbani1, family = binomial()) # Model with only AGE and NIVSCOL alternative_model3 <- glm(ATBANI1 ~ AGE + NIVSCOL, data = df_filtered_atbani1, family = binomial()) # Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(ATBANI1 ~ GENRE + AGE + NIVSCOL, data = df_filtered_atbani1, family = binomial()) # Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(ATBANI1 ~ GENRE + HEALTH_SCIENCE, data = df_filtered_atbani1, family = binomial()) # Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(ATBANI1 ~ AGE + HEALTH_SCIENCE, data = df_filtered_atbani1, family = binomial()) # Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(ATBANI1 ~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_atbani1, family = binomial()) # Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) #### ATBANI2 #### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$ATBANI2 <- as.factor(ifelse(df$ATBANI2 %in% c(0, 1), df$ATBANI2, NA)) # Keep only True (0) and False (1) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'True' and 'False' in ATBANI2 df_filtered_atbani2 <- df[df$ATBANI2 %in% c(0, 1), ] # Remove rows with NA in the variables of interest df_filtered_atbani2 <- na.omit(df_filtered_atbani2) # Build the logistic regression model model <- glm(ATBANI2 ~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_atbani2, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison # Model with only GENRE and AGE alternative_model1 <- glm(ATBANI2 ~ GENRE + AGE, data = df_filtered_atbani2, family = binomial()) # Model with only GENRE and NIVSCOL alternative_model2 <- glm(ATBANI2 ~ GENRE + NIVSCOL, data = df_filtered_atbani2, family = binomial()) # Model with only AGE and NIVSCOL alternative_model3 <- glm(ATBANI2 ~ AGE + NIVSCOL, data = df_filtered_atbani2, family = binomial()) # Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(ATBANI2 ~ GENRE + AGE + NIVSCOL, data = df_filtered_atbani2, family = binomial()) # Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(ATBANI2 ~ GENRE + HEALTH_SCIENCE, data = df_filtered_atbani2, family = binomial()) # Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(ATBANI2 ~ AGE + HEALTH_SCIENCE, data = df_filtered_atbani2, family = binomial()) # Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(ATBANI2 ~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_atbani2, family = binomial()) # Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) #### ATBANI3 #### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$ATBANI3 <- as.factor(ifelse(df$ATBANI3 %in% c(0, 1), df$ATBANI3, NA)) # Keep only True (0) and False (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'True' and 'False' in ATBANI3 df_filtered_ATBANI3 <- df[df$ATBANI3 %in% c(0, 1), ] # Remove rows with NA in the variables of interest df_filtered_ATBANI3 <- na.omit(df_filtered_ATBANI3) # Build the logistic regression model model <- glm(ATBANI3 ~ AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_ATBANI3, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison # Model with only AGE and NIVSCOL alternative_model1 <- glm(ATBANI3 ~ AGE + NIVSCOL, data = df_filtered_ATBANI3, family = binomial()) # Model with AGE and HEALTH_SCIENCE alternative_model2 <- glm(ATBANI3 ~ AGE + HEALTH_SCIENCE, data = df_filtered_ATBANI3, family = binomial()) # Model with NIVSCOL and HEALTH_SCIENCE alternative_model3 <- glm(ATBANI3 ~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_ATBANI3, family = binomial()) # Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3) print(aic_values) #### ATBANI4 #### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$ATBANI4 <- as.factor(ifelse(df$ATBANI4 %in% c(0, 1), df$ATBANI4, NA)) # Keep only True (0) and False (1) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'True' and 'False' in ATBANI4 df_filtered_ATBANI4 <- df[df$ATBANI4 %in% c(0, 1), ] # Remove rows with NA in the variables of interest df_filtered_ATBANI4 <- na.omit(df_filtered_ATBANI4) # Build the logistic regression model model <- glm(ATBANI4 ~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_ATBANI4, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison # Model with only GENRE and AGE alternative_model1 <- glm(ATBANI4 ~ GENRE + AGE, data = df_filtered_ATBANI4, family = binomial()) # Model with only GENRE and NIVSCOL alternative_model2 <- glm(ATBANI4 ~ GENRE + NIVSCOL, data = df_filtered_ATBANI4, family = binomial()) # Model with only AGE and NIVSCOL alternative_model3 <- glm(ATBANI4 ~ AGE + NIVSCOL, data = df_filtered_ATBANI4, family = binomial()) # Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(ATBANI4 ~ GENRE + AGE + NIVSCOL, data = df_filtered_ATBANI4, family = binomial()) # Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(ATBANI4 ~ GENRE + HEALTH_SCIENCE, data = df_filtered_ATBANI4, family = binomial()) # Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(ATBANI4 ~ AGE + HEALTH_SCIENCE, data = df_filtered_ATBANI4, family = binomial()) # Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(ATBANI4 ~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_ATBANI4, family = binomial()) # Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) #### RESATB1 #### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$RESATB1 <- as.factor(ifelse(df$RESATB1 %in% c(0, 1), df$RESATB1, NA)) # Keep only True (0) and False (1) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'True' and 'False' in RESATB1 df_filtered_RESATB1 <- df[df$RESATB1 %in% c(0, 1), ] # Remove rows with NA in the variables of interest df_filtered_RESATB1 <- na.omit(df_filtered_RESATB1) # Build the logistic regression model model <- glm(RESATB1 ~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESATB1, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison # Model with only GENRE and AGE alternative_model1 <- glm(RESATB1 ~ GENRE + AGE, data = df_filtered_RESATB1, family = binomial()) # Model with only GENRE and NIVSCOL alternative_model2 <- glm(RESATB1 ~ GENRE + NIVSCOL, data = df_filtered_RESATB1, family = binomial()) # Model with only AGE and NIVSCOL alternative_model3 <- glm(RESATB1 ~ AGE + NIVSCOL, data = df_filtered_RESATB1, family = binomial()) # Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(RESATB1 ~ GENRE + AGE + NIVSCOL, data = df_filtered_RESATB1, family = binomial()) # Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(RESATB1 ~ GENRE + HEALTH_SCIENCE, data = df_filtered_RESATB1, family = binomial()) # Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(RESATB1 ~ AGE + HEALTH_SCIENCE, data = df_filtered_RESATB1, family = binomial()) # Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(RESATB1 ~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESATB1, family = binomial()) # Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) #### RESATB2 #### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$RESATB2 <- as.factor(ifelse(df$RESATB2 %in% c(0, 1), df$RESATB2, NA)) # Keep only True (0) and False (1) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'True' and 'False' in RESATB2 df_filtered_RESATB2 <- df[df$RESATB2 %in% c(0, 1), ] # Remove rows with NA in the variables of interest df_filtered_RESATB2 <- na.omit(df_filtered_RESATB2) # Build the logistic regression model model <- glm(RESATB2 ~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESATB2, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison # Model with only GENRE and AGE alternative_model1 <- glm(RESATB2 ~ GENRE + AGE, data = df_filtered_RESATB2, family = binomial()) # Model with only GENRE and NIVSCOL alternative_model2 <- glm(RESATB2 ~ GENRE + NIVSCOL, data = df_filtered_RESATB2, family = binomial()) # Model with only AGE and NIVSCOL alternative_model3 <- glm(RESATB2 ~ AGE + NIVSCOL, data = df_filtered_RESATB2, family = binomial()) # Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(RESATB2 ~ GENRE + AGE + NIVSCOL, data = df_filtered_RESATB2, family = binomial()) # Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(RESATB2 ~ GENRE + HEALTH_SCIENCE, data = df_filtered_RESATB2, family = binomial()) # Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(RESATB2 ~ AGE + HEALTH_SCIENCE, data = df_filtered_RESATB2, family = binomial()) # Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(RESATB2 ~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESATB2, family = binomial()) # Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) #### RESATB3 #### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$RESATB3 <- as.factor(ifelse(df$RESATB3 %in% c(0, 1), df$RESATB3, NA)) # Keep only True (0) and False (1) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'True' and 'False' in RESATB3 df_filtered_RESATB3 <- df[df$RESATB3 %in% c(0, 1), ] # Remove rows with NA in the variables of interest df_filtered_RESATB3 <- na.omit(df_filtered_RESATB3) # Build the logistic regression model model <- glm(RESATB3 ~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESATB3, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison # Model with only GENRE and AGE alternative_model1 <- glm(RESATB3 ~ GENRE + AGE, data = df_filtered_RESATB3, family = binomial()) # Model with only GENRE and NIVSCOL alternative_model2 <- glm(RESATB3 ~ GENRE + NIVSCOL, data = df_filtered_RESATB3, family = binomial()) # Model with only AGE and NIVSCOL alternative_model3 <- glm(RESATB3 ~ AGE + NIVSCOL, data = df_filtered_RESATB3, family = binomial()) # Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(RESATB3 ~ GENRE + AGE + NIVSCOL, data = df_filtered_RESATB3, family = binomial()) # Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(RESATB3 ~ GENRE + HEALTH_SCIENCE, data = df_filtered_RESATB3, family = binomial()) # Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(RESATB3 ~ AGE + HEALTH_SCIENCE, data = df_filtered_RESATB3, family = binomial()) # Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(RESATB3 ~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESATB3, family = binomial()) # Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) #### RESATB4 #### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$RESATB4 <- as.factor(ifelse(df$RESATB4 %in% c(0, 1), df$RESATB4, NA)) # Keep only True (0) and False (1) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'True' and 'False' in RESATB4 df_filtered_RESATB4 <- df[df$RESATB4 %in% c(0, 1), ] # Remove rows with NA in the variables of interest df_filtered_RESATB4 <- na.omit(df_filtered_RESATB4) # Build the logistic regression model model <- glm(RESATB4 ~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESATB4, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison # Model with only GENRE and AGE alternative_model1 <- glm(RESATB4 ~ GENRE + AGE, data = df_filtered_RESATB4, family = binomial()) # Model with only GENRE and NIVSCOL alternative_model2 <- glm(RESATB4 ~ GENRE + NIVSCOL, data = df_filtered_RESATB4, family = binomial()) # Model with only AGE and NIVSCOL alternative_model3 <- glm(RESATB4 ~ AGE + NIVSCOL, data = df_filtered_RESATB4, family = binomial()) # Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(RESATB4 ~ GENRE + AGE + NIVSCOL, data = df_filtered_RESATB4, family = binomial()) # Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(RESATB4 ~ GENRE + HEALTH_SCIENCE, data = df_filtered_RESATB4, family = binomial()) # Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(RESATB4 ~ AGE + HEALTH_SCIENCE, data = df_filtered_RESATB4, family = binomial()) # Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(RESATB4 ~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESATB4, family = binomial()) # Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) #### RESATB5 #### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$RESATB5 <- as.factor(ifelse(df$RESATB5 %in% c(0, 1), df$RESATB5, NA)) # Keep only True (0) and False (1) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'True' and 'False' in RESATB5 df_filtered_RESATB5 <- df[df$RESATB5 %in% c(0, 1), ] # Remove rows with NA in the variables of interest df_filtered_RESATB5 <- na.omit(df_filtered_RESATB5) # Build the logistic regression model model <- glm(RESATB5 ~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESATB5, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison # Model with only GENRE and AGE alternative_model1 <- glm(RESATB5 ~ GENRE + AGE, data = df_filtered_RESATB5, family = binomial()) # Model with only GENRE and NIVSCOL alternative_model2 <- glm(RESATB5 ~ GENRE + NIVSCOL, data = df_filtered_RESATB5, family = binomial()) # Model with only AGE and NIVSCOL alternative_model3 <- glm(RESATB5 ~ AGE + NIVSCOL, data = df_filtered_RESATB5, family = binomial()) # Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(RESATB5 ~ GENRE + AGE + NIVSCOL, data = df_filtered_RESATB5, family = binomial()) # Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(RESATB5 ~ GENRE + HEALTH_SCIENCE, data = df_filtered_RESATB5, family = binomial()) # Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(RESATB5 ~ AGE + HEALTH_SCIENCE, data = df_filtered_RESATB5, family = binomial()) # Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(RESATB5 ~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESATB5, family = binomial()) # Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) #### RESATB6 #### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$RESATB6 <- as.factor(ifelse(df$RESATB6 %in% c(0, 1), df$RESATB6, NA)) # Keep only True (0) and False (1) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'True' and 'False' in RESATB6 df_filtered_RESATB6 <- df[df$RESATB6 %in% c(0, 1), ] # Remove rows with NA in the variables of interest df_filtered_RESATB6 <- na.omit(df_filtered_RESATB6) # Build the logistic regression model model <- glm(RESATB6 ~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESATB6, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison # Model with only GENRE and AGE alternative_model1 <- glm(RESATB6 ~ GENRE + AGE, data = df_filtered_RESATB6, family = binomial()) # Model with only GENRE and NIVSCOL alternative_model2 <- glm(RESATB6 ~ GENRE + NIVSCOL, data = df_filtered_RESATB6, family = binomial()) # Model with only AGE and NIVSCOL alternative_model3 <- glm(RESATB6 ~ AGE + NIVSCOL, data = df_filtered_RESATB6, family = binomial()) # Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(RESATB6 ~ GENRE + AGE + NIVSCOL, data = df_filtered_RESATB6, family = binomial()) # Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(RESATB6 ~ GENRE + HEALTH_SCIENCE, data = df_filtered_RESATB6, family = binomial()) # Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(RESATB6 ~ AGE + HEALTH_SCIENCE, data = df_filtered_RESATB6, family = binomial()) # Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(RESATB6 ~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESATB6, family = binomial()) # Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) #### RESATB7 #### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$RESATB7 <- as.factor(ifelse(df$RESATB7 %in% c(0, 1), df$RESATB7, NA)) # Keep only True (0) and False (1) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'True' and 'False' in RESATB7 df_filtered_RESATB7 <- df[df$RESATB7 %in% c(0, 1), ] # Remove rows with NA in the variables of interest df_filtered_RESATB7 <- na.omit(df_filtered_RESATB7) # Build the logistic regression model model <- glm(RESATB7 ~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESATB7, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison # Model with only GENRE and AGE alternative_model1 <- glm(RESATB7 ~ GENRE + AGE, data = df_filtered_RESATB7, family = binomial()) # Model with only GENRE and NIVSCOL alternative_model2 <- glm(RESATB7 ~ GENRE + NIVSCOL, data = df_filtered_RESATB7, family = binomial()) # Model with only AGE and NIVSCOL alternative_model3 <- glm(RESATB7 ~ AGE + NIVSCOL, data = df_filtered_RESATB7, family = binomial()) # Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(RESATB7 ~ GENRE + AGE + NIVSCOL, data = df_filtered_RESATB7, family = binomial()) # Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(RESATB7 ~ GENRE + HEALTH_SCIENCE, data = df_filtered_RESATB7, family = binomial()) # Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(RESATB7 ~ AGE + HEALTH_SCIENCE, data = df_filtered_RESATB7, family = binomial()) # Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(RESATB7 ~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESATB7, family = binomial()) # Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) #### RESATB8 #### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$RESATB8 <- as.factor(ifelse(df$RESATB8 %in% c(0, 1), df$RESATB8, NA)) # Keep only True (0) and False (1) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'True' and 'False' in RESATB8 df_filtered_RESATB8 <- df[df$RESATB8 %in% c(0, 1), ] # Remove rows with NA in the variables of interest df_filtered_RESATB8 <- na.omit(df_filtered_RESATB8) # Build the logistic regression model model <- glm(RESATB8 ~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESATB8, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison # Model with only GENRE and AGE alternative_model1 <- glm(RESATB8 ~ GENRE + AGE, data = df_filtered_RESATB8, family = binomial()) # Model with only GENRE and NIVSCOL alternative_model2 <- glm(RESATB8 ~ GENRE + NIVSCOL, data = df_filtered_RESATB8, family = binomial()) # Model with only AGE and NIVSCOL alternative_model3 <- glm(RESATB8 ~ AGE + NIVSCOL, data = df_filtered_RESATB8, family = binomial()) # Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(RESATB8 ~ GENRE + AGE + NIVSCOL, data = df_filtered_RESATB8, family = binomial()) # Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(RESATB8 ~ GENRE + HEALTH_SCIENCE, data = df_filtered_RESATB8, family = binomial()) # Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(RESATB8 ~ AGE + HEALTH_SCIENCE, data = df_filtered_RESATB8, family = binomial()) # Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(RESATB8 ~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESATB8, family = binomial()) # Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) #### ATBRGL1 #### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$ATBRGL1 <- as.factor(ifelse(df$ATBRGL1 %in% c(1, 2), df$ATBRGL1, NA)) # Keep only Strongly disagree (1) and Neither agree nor disagree (2) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'Strongly disagree' and 'Neither agree nor disagree' in ATBGRL1 df_filtered_atbrgl1 <- df[df$ATBRGL1 %in% c(1, 2), ] # Remove rows with NA in the variables of interest df_filtered_atbrgl1 <- na.omit(df_filtered_atbrgl1) # Build the logistic regression model model <- glm(ATBRGL1 ~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_atbrgl1, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison #Model with only GENRE and AGE alternative_model1 <- glm(ATBRGL1 ~ GENRE + AGE, data = df_filtered_atbrgl1, family = binomial()) #Model with only GENRE and NIVSCOL alternative_model2 <- glm(ATBRGL1 ~ GENRE + NIVSCOL, data = df_filtered_atbrgl1, family = binomial()) #Model with only AGE and NIVSCOL alternative_model3 <- glm(ATBRGL1 ~ AGE + NIVSCOL, data = df_filtered_atbrgl1, family = binomial()) #Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(ATBRGL1 ~ GENRE + AGE + NIVSCOL, data = df_filtered_atbrgl1, family = binomial()) #Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(ATBRGL1 ~ GENRE + HEALTH_SCIENCE, data = df_filtered_atbrgl1, family = binomial()) #Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(ATBRGL1 ~ AGE + HEALTH_SCIENCE, data = df_filtered_atbrgl1, family = binomial()) #Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(ATBRGL1 ~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_atbrgl1, family = binomial()) #Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) #### ATBRGL2#### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$ATBRGL2<- as.factor(ifelse(df$ATBRGL2%in% c(1, 2), df$ATBRGL2, NA)) # Keep only Strongly disagree (1) and Neither agree nor disagree (2) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'Strongly disagree' and 'Neither agree nor disagree' in ATBGRL1 df_filtered_ATBRGL2<- df[df$ATBRGL2%in% c(1, 2), ] # Remove rows with NA in the variables of interest df_filtered_ATBRGL2<- na.omit(df_filtered_ATBRGL2) # Build the logistic regression model model <- glm(ATBRGL2~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_ATBRGL2, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison #Model with only GENRE and AGE alternative_model1 <- glm(ATBRGL2~ GENRE + AGE, data = df_filtered_ATBRGL2, family = binomial()) #Model with only GENRE and NIVSCOL alternative_model2 <- glm(ATBRGL2~ GENRE + NIVSCOL, data = df_filtered_ATBRGL2, family = binomial()) #Model with only AGE and NIVSCOL alternative_model3 <- glm(ATBRGL2~ AGE + NIVSCOL, data = df_filtered_ATBRGL2, family = binomial()) #Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(ATBRGL2~ GENRE + AGE + NIVSCOL, data = df_filtered_ATBRGL2, family = binomial()) #Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(ATBRGL2~ GENRE + HEALTH_SCIENCE, data = df_filtered_ATBRGL2, family = binomial()) #Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(ATBRGL2~ AGE + HEALTH_SCIENCE, data = df_filtered_ATBRGL2, family = binomial()) #Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(ATBRGL2~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_ATBRGL2, family = binomial()) #Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) #### ATBRGL3#### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$ATBRGL3<- as.factor(ifelse(df$ATBRGL3%in% c(1, 2), df$ATBRGL3, NA)) # Keep only Strongly disagree (1) and Neither agree nor disagree (2) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'Strongly disagree' and 'Neither agree nor disagree' in ATBGRL1 df_filtered_ATBRGL3<- df[df$ATBRGL3%in% c(1, 2), ] # Remove rows with NA in the variables of interest df_filtered_ATBRGL3<- na.omit(df_filtered_ATBRGL3) # Build the logistic regression model model <- glm(ATBRGL3~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_ATBRGL3, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison #Model with only GENRE and AGE alternative_model1 <- glm(ATBRGL3~ GENRE + AGE, data = df_filtered_ATBRGL3, family = binomial()) #Model with only GENRE and NIVSCOL alternative_model2 <- glm(ATBRGL3~ GENRE + NIVSCOL, data = df_filtered_ATBRGL3, family = binomial()) #Model with only AGE and NIVSCOL alternative_model3 <- glm(ATBRGL3~ AGE + NIVSCOL, data = df_filtered_ATBRGL3, family = binomial()) #Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(ATBRGL3~ GENRE + AGE + NIVSCOL, data = df_filtered_ATBRGL3, family = binomial()) #Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(ATBRGL3~ GENRE + HEALTH_SCIENCE, data = df_filtered_ATBRGL3, family = binomial()) #Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(ATBRGL3~ AGE + HEALTH_SCIENCE, data = df_filtered_ATBRGL3, family = binomial()) #Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(ATBRGL3~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_ATBRGL3, family = binomial()) #Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) #### ATBRGL4#### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$ATBRGL4<- as.factor(ifelse(df$ATBRGL4%in% c(1, 2), df$ATBRGL4, NA)) # Keep only Strongly disagree (1) and Neither agree nor disagree (2) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'Strongly disagree' and 'Neither agree nor disagree' in ATBGRL1 df_filtered_ATBRGL4<- df[df$ATBRGL4%in% c(1, 2), ] # Remove rows with NA in the variables of interest df_filtered_ATBRGL4<- na.omit(df_filtered_ATBRGL4) # Build the logistic regression model model <- glm(ATBRGL4~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_ATBRGL4, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison #Model with only GENRE and AGE alternative_model1 <- glm(ATBRGL4~ GENRE + AGE, data = df_filtered_ATBRGL4, family = binomial()) #Model with only GENRE and NIVSCOL alternative_model2 <- glm(ATBRGL4~ GENRE + NIVSCOL, data = df_filtered_ATBRGL4, family = binomial()) #Model with only AGE and NIVSCOL alternative_model3 <- glm(ATBRGL4~ AGE + NIVSCOL, data = df_filtered_ATBRGL4, family = binomial()) #Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(ATBRGL4~ GENRE + AGE + NIVSCOL, data = df_filtered_ATBRGL4, family = binomial()) #Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(ATBRGL4~ GENRE + HEALTH_SCIENCE, data = df_filtered_ATBRGL4, family = binomial()) #Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(ATBRGL4~ AGE + HEALTH_SCIENCE, data = df_filtered_ATBRGL4, family = binomial()) #Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(ATBRGL4~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_ATBRGL4, family = binomial()) #Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) #### ATBRGL5#### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$ATBRGL5<- as.factor(ifelse(df$ATBRGL5%in% c(1, 2), df$ATBRGL5, NA)) # Keep only Strongly disagree (1) and Neither agree nor disagree (2) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'Strongly disagree' and 'Neither agree nor disagree' in ATBGRL1 df_filtered_ATBRGL5<- df[df$ATBRGL5%in% c(1, 2), ] # Remove rows with NA in the variables of interest df_filtered_ATBRGL5<- na.omit(df_filtered_ATBRGL5) # Build the logistic regression model model <- glm(ATBRGL5~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_ATBRGL5, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison #Model with only GENRE and AGE alternative_model1 <- glm(ATBRGL5~ GENRE + AGE, data = df_filtered_ATBRGL5, family = binomial()) #Model with only GENRE and NIVSCOL alternative_model2 <- glm(ATBRGL5~ GENRE + NIVSCOL, data = df_filtered_ATBRGL5, family = binomial()) #Model with only AGE and NIVSCOL alternative_model3 <- glm(ATBRGL5~ AGE + NIVSCOL, data = df_filtered_ATBRGL5, family = binomial()) #Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(ATBRGL5~ GENRE + AGE + NIVSCOL, data = df_filtered_ATBRGL5, family = binomial()) #Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(ATBRGL5~ GENRE + HEALTH_SCIENCE, data = df_filtered_ATBRGL5, family = binomial()) #Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(ATBRGL5~ AGE + HEALTH_SCIENCE, data = df_filtered_ATBRGL5, family = binomial()) #Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(ATBRGL5~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_ATBRGL5, family = binomial()) #Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) #### ATBRGL6#### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$ATBRGL6<- as.factor(ifelse(df$ATBRGL6%in% c(1, 2), df$ATBRGL6, NA)) # Keep only Strongly disagree (1) and Neither agree nor disagree (2) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'Strongly disagree' and 'Neither agree nor disagree' in ATBGRL1 df_filtered_ATBRGL6<- df[df$ATBRGL6%in% c(1, 2), ] # Remove rows with NA in the variables of interest df_filtered_ATBRGL6<- na.omit(df_filtered_ATBRGL6) # Build the logistic regression model model <- glm(ATBRGL6~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_ATBRGL6, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison #Model with only GENRE and AGE alternative_model1 <- glm(ATBRGL6~ GENRE + AGE, data = df_filtered_ATBRGL6, family = binomial()) #Model with only GENRE and NIVSCOL alternative_model2 <- glm(ATBRGL6~ GENRE + NIVSCOL, data = df_filtered_ATBRGL6, family = binomial()) #Model with only AGE and NIVSCOL alternative_model3 <- glm(ATBRGL6~ AGE + NIVSCOL, data = df_filtered_ATBRGL6, family = binomial()) #Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(ATBRGL6~ GENRE + AGE + NIVSCOL, data = df_filtered_ATBRGL6, family = binomial()) #Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(ATBRGL6~ GENRE + HEALTH_SCIENCE, data = df_filtered_ATBRGL6, family = binomial()) #Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(ATBRGL6~ AGE + HEALTH_SCIENCE, data = df_filtered_ATBRGL6, family = binomial()) #Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(ATBRGL6~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_ATBRGL6, family = binomial()) #Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) #### ATBRGL7#### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$ATBRGL7<- as.factor(ifelse(df$ATBRGL7%in% c(1, 2), df$ATBRGL7, NA)) # Keep only Strongly disagree (1) and Neither agree nor disagree (2) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'Strongly disagree' and 'Neither agree nor disagree' in ATBGRL1 df_filtered_ATBRGL7<- df[df$ATBRGL7%in% c(1, 2), ] # Remove rows with NA in the variables of interest df_filtered_ATBRGL7<- na.omit(df_filtered_ATBRGL7) # Build the logistic regression model model <- glm(ATBRGL7~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_ATBRGL7, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison #Model with only GENRE and AGE alternative_model1 <- glm(ATBRGL7~ GENRE + AGE, data = df_filtered_ATBRGL7, family = binomial()) #Model with only GENRE and NIVSCOL alternative_model2 <- glm(ATBRGL7~ GENRE + NIVSCOL, data = df_filtered_ATBRGL7, family = binomial()) #Model with only AGE and NIVSCOL alternative_model3 <- glm(ATBRGL7~ AGE + NIVSCOL, data = df_filtered_ATBRGL7, family = binomial()) #Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(ATBRGL7~ GENRE + AGE + NIVSCOL, data = df_filtered_ATBRGL7, family = binomial()) #Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(ATBRGL7~ GENRE + HEALTH_SCIENCE, data = df_filtered_ATBRGL7, family = binomial()) #Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(ATBRGL7~ AGE + HEALTH_SCIENCE, data = df_filtered_ATBRGL7, family = binomial()) #Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(ATBRGL7~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_ATBRGL7, family = binomial()) #Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) #### ATBRGL8#### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$ATBRGL8<- as.factor(ifelse(df$ATBRGL8%in% c(1, 2), df$ATBRGL8, NA)) # Keep only Strongly disagree (1) and Neither agree nor disagree (2) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'Strongly disagree' and 'Neither agree nor disagree' in ATBGRL1 df_filtered_ATBRGL8<- df[df$ATBRGL8%in% c(1, 2), ] # Remove rows with NA in the variables of interest df_filtered_ATBRGL8<- na.omit(df_filtered_ATBRGL8) # Build the logistic regression model model <- glm(ATBRGL8~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_ATBRGL8, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison #Model with only GENRE and AGE alternative_model1 <- glm(ATBRGL8~ GENRE + AGE, data = df_filtered_ATBRGL8, family = binomial()) #Model with only GENRE and NIVSCOL alternative_model2 <- glm(ATBRGL8~ GENRE + NIVSCOL, data = df_filtered_ATBRGL8, family = binomial()) #Model with only AGE and NIVSCOL alternative_model3 <- glm(ATBRGL8~ AGE + NIVSCOL, data = df_filtered_ATBRGL8, family = binomial()) #Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(ATBRGL8~ GENRE + AGE + NIVSCOL, data = df_filtered_ATBRGL8, family = binomial()) #Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(ATBRGL8~ GENRE + HEALTH_SCIENCE, data = df_filtered_ATBRGL8, family = binomial()) #Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(ATBRGL8~ AGE + HEALTH_SCIENCE, data = df_filtered_ATBRGL8, family = binomial()) #Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(ATBRGL8~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_ATBRGL8, family = binomial()) #Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) #### RESDIM1 #### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$RESDIM1<- as.factor(ifelse(df$RESDIM1%in% c(1, 2), df$RESDIM1, NA)) # Keep only Strongly disagree (1) and Neither agree nor disagree (2) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'Strongly disagree' and 'Neither agree nor disagree' in ATBGRL1 df_filtered_RESDIM1<- df[df$RESDIM1%in% c(1, 2), ] # Remove rows with NA in the variables of interest df_filtered_RESDIM1<- na.omit(df_filtered_RESDIM1) # Build the logistic regression model model <- glm(RESDIM1~ AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESDIM1, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison #Model with only AGE and NIVSCOL alternative_model1 <- glm(RESDIM1~ AGE + NIVSCOL, data = df_filtered_RESDIM1, family = binomial()) #Model with AGE and HEALTH_SCIENCE alternative_model2 <- glm(RESDIM1~ AGE + HEALTH_SCIENCE, data = df_filtered_RESDIM1, family = binomial()) #Model with NIVSCOL and HEALTH_SCIENCE alternative_model3 <- glm(RESDIM1~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESDIM1, family = binomial()) #Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3) print(aic_values) #### RESDIM2 #### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$RESDIM2<- as.factor(ifelse(df$RESDIM2%in% c(3, 2), df$RESDIM2, NA)) # Keep only Strongly agree (1) and Neither agree nor disagree (2) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'Strongly disagree' and 'Neither agree nor disagree' in ATBGRL1 df_filtered_RESDIM2<- df[df$RESDIM2%in% c(3, 2), ] # Remove rows with NA in the variables of interest df_filtered_RESDIM2<- na.omit(df_filtered_RESDIM2) # Build the logistic regression model model <- glm(RESDIM2~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESDIM2, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison #Model with only GENRE and AGE alternative_model1 <- glm(RESDIM2~ GENRE + AGE, data = df_filtered_RESDIM2, family = binomial()) #Model with only GENRE and NIVSCOL alternative_model2 <- glm(RESDIM2~ GENRE + NIVSCOL, data = df_filtered_RESDIM2, family = binomial()) #Model with only AGE and NIVSCOL alternative_model3 <- glm(RESDIM2~ AGE + NIVSCOL, data = df_filtered_RESDIM2, family = binomial()) #Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(RESDIM2~ GENRE + AGE + NIVSCOL, data = df_filtered_RESDIM2, family = binomial()) #Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(RESDIM2~ GENRE + HEALTH_SCIENCE, data = df_filtered_RESDIM2, family = binomial()) #Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(RESDIM2~ AGE + HEALTH_SCIENCE, data = df_filtered_RESDIM2, family = binomial()) #Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(RESDIM2~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESDIM2, family = binomial()) #Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) #### RESDIM3 #### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$RESDIM3<- as.factor(ifelse(df$RESDIM3%in% c(1, 2), df$RESDIM3, NA)) # Keep only Strongly disagree (1) and Neither agree nor disagree (2) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'Strongly disagree' and 'Neither agree nor disagree' in ATBGRL1 df_filtered_RESDIM3<- df[df$RESDIM3%in% c(1, 2), ] # Remove rows with NA in the variables of interest df_filtered_RESDIM3<- na.omit(df_filtered_RESDIM3) # Build the logistic regression model model <- glm(RESDIM3~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESDIM3, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison #Model with only GENRE and AGE alternative_model1 <- glm(RESDIM3~ GENRE + AGE, data = df_filtered_RESDIM3, family = binomial()) #Model with only GENRE and NIVSCOL alternative_model2 <- glm(RESDIM3~ GENRE + NIVSCOL, data = df_filtered_RESDIM3, family = binomial()) #Model with only AGE and NIVSCOL alternative_model3 <- glm(RESDIM3~ AGE + NIVSCOL, data = df_filtered_RESDIM3, family = binomial()) #Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(RESDIM3~ GENRE + AGE + NIVSCOL, data = df_filtered_RESDIM3, family = binomial()) #Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(RESDIM3~ GENRE + HEALTH_SCIENCE, data = df_filtered_RESDIM3, family = binomial()) #Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(RESDIM3~ AGE + HEALTH_SCIENCE, data = df_filtered_RESDIM3, family = binomial()) #Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(RESDIM3~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESDIM3, family = binomial()) #Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) #### RESDIM4 #### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$RESDIM4<- as.factor(ifelse(df$RESDIM4%in% c(3, 2), df$RESDIM4, NA)) # Keep only Strongly agree (3) and Neither agree nor disagree (2) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'Strongly disagree' and 'Neither agree nor disagree' in ATBGRL1 df_filtered_RESDIM4<- df[df$RESDIM4%in% c(3, 2), ] # Remove rows with NA in the variables of interest df_filtered_RESDIM4<- na.omit(df_filtered_RESDIM4) # Build the logistic regression model model <- glm(RESDIM4~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESDIM4, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison #Model with only GENRE and AGE alternative_model1 <- glm(RESDIM4~ GENRE + AGE, data = df_filtered_RESDIM4, family = binomial()) #Model with only GENRE and NIVSCOL alternative_model2 <- glm(RESDIM4~ GENRE + NIVSCOL, data = df_filtered_RESDIM4, family = binomial()) #Model with only AGE and NIVSCOL alternative_model3 <- glm(RESDIM4~ AGE + NIVSCOL, data = df_filtered_RESDIM4, family = binomial()) #Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(RESDIM4~ GENRE + AGE + NIVSCOL, data = df_filtered_RESDIM4, family = binomial()) #Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(RESDIM4~ GENRE + HEALTH_SCIENCE, data = df_filtered_RESDIM4, family = binomial()) #Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(RESDIM4~ AGE + HEALTH_SCIENCE, data = df_filtered_RESDIM4, family = binomial()) #Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(RESDIM4~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESDIM4, family = binomial()) #Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) #### RESDIM5 #### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$RESDIM5<- as.factor(ifelse(df$RESDIM5%in% c(1, 2), df$RESDIM5, NA)) # Keep only Strongly disagree (1) and Neither agree nor disagree (2) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'Strongly disagree' and 'Neither agree nor disagree' in ATBGRL1 df_filtered_RESDIM5<- df[df$RESDIM5%in% c(1, 2), ] # Remove rows with NA in the variables of interest df_filtered_RESDIM5<- na.omit(df_filtered_RESDIM5) # Build the logistic regression model model <- glm(RESDIM5~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESDIM5, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison #Model with only GENRE and AGE alternative_model1 <- glm(RESDIM5~ GENRE + AGE, data = df_filtered_RESDIM5, family = binomial()) #Model with only GENRE and NIVSCOL alternative_model2 <- glm(RESDIM5~ GENRE + NIVSCOL, data = df_filtered_RESDIM5, family = binomial()) #Model with only AGE and NIVSCOL alternative_model3 <- glm(RESDIM5~ AGE + NIVSCOL, data = df_filtered_RESDIM5, family = binomial()) #Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(RESDIM5~ GENRE + AGE + NIVSCOL, data = df_filtered_RESDIM5, family = binomial()) #Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(RESDIM5~ GENRE + HEALTH_SCIENCE, data = df_filtered_RESDIM5, family = binomial()) #Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(RESDIM5~ AGE + HEALTH_SCIENCE, data = df_filtered_RESDIM5, family = binomial()) #Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(RESDIM5~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESDIM5, family = binomial()) #Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values) #### RESDIM6 #### # Load database Database_simplified <- read_excel("C:/Database_simplified.xlsx") df <- Database_simplified # Prepare the variables df$RESDIM6<- as.factor(ifelse(df$RESDIM6%in% c(1, 2), df$RESDIM6, NA)) # Keep only Strongly disagree (1) and Neither agree nor disagree (2) df$GENRE <- as.factor(ifelse(df$GENRE %in% c(0, 1), df$GENRE, NA)) # Keep only Female (0) and Male (1) df$AGE <- as.factor(ifelse(df$AGE %in% c(1, 2), "18-34", ifelse(df$AGE %in% c(3, 4, 5, 6), "35+", NA))) df$NIVSCOL <- as.factor(ifelse(df$NIVSCOL %in% c(7, 8), "Higher Education", "Other")) df$HEALTH_SCIENCE <- ifelse(Database_simplified$PROF11 == 0 | Database_simplified$PROF12 == 0, 0, 1) # Filter for 'Strongly disagree' and 'Neither agree nor disagree' in ATBGRL1 df_filtered_RESDIM6<- df[df$RESDIM6%in% c(1, 2), ] # Remove rows with NA in the variables of interest df_filtered_RESDIM6<- na.omit(df_filtered_RESDIM6) # Build the logistic regression model model <- glm(RESDIM6~ GENRE + AGE + NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESDIM6, family = binomial()) # Check the results summary(model) # To obtain Odds Ratios and confidence intervals exp(cbind(OddsRatio = coef(model), confint(model))) # Check for multicollinearity with VIF vif_model <- vif(model) print(vif_model) # Fit alternative models for AIC comparison #Model with only GENRE and AGE alternative_model1 <- glm(RESDIM6~ GENRE + AGE, data = df_filtered_RESDIM6, family = binomial()) #Model with only GENRE and NIVSCOL alternative_model2 <- glm(RESDIM6~ GENRE + NIVSCOL, data = df_filtered_RESDIM6, family = binomial()) #Model with only AGE and NIVSCOL alternative_model3 <- glm(RESDIM6~ AGE + NIVSCOL, data = df_filtered_RESDIM6, family = binomial()) #Model with GENRE, AGE, and NIVSCOL alternative_model4 <- glm(RESDIM6~ GENRE + AGE + NIVSCOL, data = df_filtered_RESDIM6, family = binomial()) #Model with GENRE and HEALTH_SCIENCE alternative_model5 <- glm(RESDIM6~ GENRE + HEALTH_SCIENCE, data = df_filtered_RESDIM6, family = binomial()) #Model with AGE and HEALTH_SCIENCE alternative_model6 <- glm(RESDIM6~ AGE + HEALTH_SCIENCE, data = df_filtered_RESDIM6, family = binomial()) #Model with NIVSCOL and HEALTH_SCIENCE alternative_model7 <- glm(RESDIM6~ NIVSCOL + HEALTH_SCIENCE, data = df_filtered_RESDIM6, family = binomial()) #Compare AIC of all models aic_values <- AIC(model, alternative_model1, alternative_model2, alternative_model3, alternative_model4, alternative_model5, alternative_model6, alternative_model7) print(aic_values)