# List of packages
packages <- c("tidyverse", "infer", "fst", "modelsummary", "effects", "survey", "interactions", "kableExtra", "flextable") # add any you need here

# Install packages if they aren't installed already
new_packages <- packages[!(packages %in% installed.packages()[,"Package"])]
if(length(new_packages)) install.packages(new_packages)

# Load the packages
lapply(packages, library, character.only = TRUE)
## Warning: package 'ggplot2' was built under R version 4.3.2
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.2     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.4     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
## Warning: package 'infer' was built under R version 4.3.2
## Warning: package 'fst' was built under R version 4.3.3
## Warning: package 'modelsummary' was built under R version 4.3.3
## Version 2.0.0 of `modelsummary`, to be released soon, will introduce a
##   breaking change: The default table-drawing package will be `tinytable`
##   instead of `kableExtra`. All currently supported table-drawing packages
##   will continue to be supported for the foreseeable future, including
##   `kableExtra`, `gt`, `huxtable`, `flextable, and `DT`.
##   
##   You can always call the `config_modelsummary()` function to change the
##   default table-drawing package in persistent fashion. To try `tinytable`
##   now:
##   
##   config_modelsummary(factory_default = 'tinytable')
##   
##   To set the default back to `kableExtra`:
##   
##   config_modelsummary(factory_default = 'kableExtra')
## Warning: package 'effects' was built under R version 4.3.2
## Loading required package: carData
## lattice theme set by effectsTheme()
## See ?effectsTheme for details.
## Warning: package 'survey' was built under R version 4.3.2
## Loading required package: grid
## Loading required package: Matrix
## 
## Attaching package: 'Matrix'
## 
## The following objects are masked from 'package:tidyr':
## 
##     expand, pack, unpack
## 
## Loading required package: survival
## Warning: package 'survival' was built under R version 4.3.2
## 
## Attaching package: 'survey'
## 
## The following object is masked from 'package:graphics':
## 
##     dotchart
## Warning: package 'interactions' was built under R version 4.3.3
## 
## Attaching package: 'kableExtra'
## 
## The following object is masked from 'package:dplyr':
## 
##     group_rows
## Warning: package 'flextable' was built under R version 4.3.3
## 
## Attaching package: 'flextable'
## 
## The following objects are masked from 'package:kableExtra':
## 
##     as_image, footnote
## 
## The following object is masked from 'package:purrr':
## 
##     compose
## [[1]]
##  [1] "lubridate" "forcats"   "stringr"   "dplyr"     "purrr"     "readr"    
##  [7] "tidyr"     "tibble"    "ggplot2"   "tidyverse" "stats"     "graphics" 
## [13] "grDevices" "utils"     "datasets"  "methods"   "base"     
## 
## [[2]]
##  [1] "infer"     "lubridate" "forcats"   "stringr"   "dplyr"     "purrr"    
##  [7] "readr"     "tidyr"     "tibble"    "ggplot2"   "tidyverse" "stats"    
## [13] "graphics"  "grDevices" "utils"     "datasets"  "methods"   "base"     
## 
## [[3]]
##  [1] "fst"       "infer"     "lubridate" "forcats"   "stringr"   "dplyr"    
##  [7] "purrr"     "readr"     "tidyr"     "tibble"    "ggplot2"   "tidyverse"
## [13] "stats"     "graphics"  "grDevices" "utils"     "datasets"  "methods"  
## [19] "base"     
## 
## [[4]]
##  [1] "modelsummary" "fst"          "infer"        "lubridate"    "forcats"     
##  [6] "stringr"      "dplyr"        "purrr"        "readr"        "tidyr"       
## [11] "tibble"       "ggplot2"      "tidyverse"    "stats"        "graphics"    
## [16] "grDevices"    "utils"        "datasets"     "methods"      "base"        
## 
## [[5]]
##  [1] "effects"      "carData"      "modelsummary" "fst"          "infer"       
##  [6] "lubridate"    "forcats"      "stringr"      "dplyr"        "purrr"       
## [11] "readr"        "tidyr"        "tibble"       "ggplot2"      "tidyverse"   
## [16] "stats"        "graphics"     "grDevices"    "utils"        "datasets"    
## [21] "methods"      "base"        
## 
## [[6]]
##  [1] "survey"       "survival"     "Matrix"       "grid"         "effects"     
##  [6] "carData"      "modelsummary" "fst"          "infer"        "lubridate"   
## [11] "forcats"      "stringr"      "dplyr"        "purrr"        "readr"       
## [16] "tidyr"        "tibble"       "ggplot2"      "tidyverse"    "stats"       
## [21] "graphics"     "grDevices"    "utils"        "datasets"     "methods"     
## [26] "base"        
## 
## [[7]]
##  [1] "interactions" "survey"       "survival"     "Matrix"       "grid"        
##  [6] "effects"      "carData"      "modelsummary" "fst"          "infer"       
## [11] "lubridate"    "forcats"      "stringr"      "dplyr"        "purrr"       
## [16] "readr"        "tidyr"        "tibble"       "ggplot2"      "tidyverse"   
## [21] "stats"        "graphics"     "grDevices"    "utils"        "datasets"    
## [26] "methods"      "base"        
## 
## [[8]]
##  [1] "kableExtra"   "interactions" "survey"       "survival"     "Matrix"      
##  [6] "grid"         "effects"      "carData"      "modelsummary" "fst"         
## [11] "infer"        "lubridate"    "forcats"      "stringr"      "dplyr"       
## [16] "purrr"        "readr"        "tidyr"        "tibble"       "ggplot2"     
## [21] "tidyverse"    "stats"        "graphics"     "grDevices"    "utils"       
## [26] "datasets"     "methods"      "base"        
## 
## [[9]]
##  [1] "flextable"    "kableExtra"   "interactions" "survey"       "survival"    
##  [6] "Matrix"       "grid"         "effects"      "carData"      "modelsummary"
## [11] "fst"          "infer"        "lubridate"    "forcats"      "stringr"     
## [16] "dplyr"        "purrr"        "readr"        "tidyr"        "tibble"      
## [21] "ggplot2"      "tidyverse"    "stats"        "graphics"     "grDevices"   
## [26] "utils"        "datasets"     "methods"      "base"
# Lets now set the working directory based on where we stored the data

setwd("C:/Users/Administrator/Desktop/Analysis")
getwd()
## [1] "C:/Users/Administrator/Desktop/Analysis"
# Let's now load the Italy Dataset to R:

italy <- read_fst("italy_data.fst")
## Warning: package 'fstcore' was built under R version 4.3.3
# Selecting specific variables
italy_selected <- italy %>%
  select(gndr, essround, edulvla, edulvlb, panpriph, panmonpb, panfolru, panclobo, panresmo)

# Convert all variables to numeric
italy_selected <- italy_selected %>%
  mutate(across(where(is.numeric), as.numeric))

# Setting values greater than 10 to NA
italy_selected$panpriph <- ifelse(italy_selected$panpriph > 10, NA, italy_selected$panpriph)
italy_selected$panmonpb <- ifelse(italy_selected$panmonpb > 10, NA, italy_selected$panmonpb)
italy_selected$panfolru <- ifelse(italy_selected$panfolru > 10, NA, italy_selected$panfolru)
italy_selected$panclobo <- ifelse(italy_selected$panclobo > 10, NA, italy_selected$panclobo)
italy_selected$panresmo <- ifelse(italy_selected$panresmo > 10, NA, italy_selected$panresmo)


# Creating and rescaling the trust variable
italy_selected$perceptions <- scales::rescale(italy_selected$panpriph + italy_selected$panmonpb + italy_selected$panfolru + italy_selected$panclobo + italy_selected$panresmo, na.rm = TRUE, to = c(0, 100))

italy_selected$misperception <- scales::rescale(italy_selected$perceptions, na.rm = TRUE, to=c(100,0))
ggplot(italy_selected, aes(x = misperception)) +
  geom_histogram(bins = 30, fill = "blue", color = "black") +
  theme_minimal() +
  labs(title = "Distribution of Perception on Managing Pandemic Scale for Italy",
       x = "Perception Scale",
       y = "Count")
## Warning: Removed 8958 rows containing non-finite values (`stat_bin()`).

It is clear that Italy exemplifies the right wing perception in managing the pandemic.

italy_selected <- italy_selected %>%
   mutate(
     ID = case_when(
       perceptions <= 50 ~ "Left",      # Categorize perceptions <= 50 as "Left"
       perceptions > 50 ~ "Right",      # Categorize perceptions > 50 as "Right"
       TRUE ~ NA_character_             # Any other values not explicitly matched above
     )
   )


table(italy_selected$ID)
## 
##  Left Right 
##   669   551
italy_pop_model <- lm(misperception ~ ID, data = italy_selected)
italy_pop_model
## 
## Call:
## lm(formula = misperception ~ ID, data = italy_selected)
## 
## Coefficients:
## (Intercept)      IDRight  
##       61.24       -21.41

Intercept (61.24):

IDRight Coefficient (-21.41):

Comparing right-leaning individuals to left-leaning ones in Italy, we expect to see the average perception scale score to be 21.41 points lower for the right-leaning group. This suggests that left-leaning individuals exhibit stronger perception attitudes than their right-leaning counterparts.

library(broom)
## Registered S3 methods overwritten by 'broom':
##   method            from  
##   tidy.glht         jtools
##   tidy.summary.glht jtools
tidy(italy_pop_model)
tidy(italy_pop_model) |>
knitr::kable(digits = 3)
term estimate std.error statistic p.value
(Intercept) 61.241 0.315 194.119 0
IDRight -21.414 0.469 -45.616 0

This coefficient is associated with an extremely low p-value, suggesting strong evidence against the null hypothesis that the intercept is zero. The p-value associated with IDRight is also extremely low, indicating strong evidence against the null hypothesis that the coefficient for IDRight is zero. These low p-values imply that both the intercept and IDRight are statistically significant predictors in the model, meaning they have a significant impact on the response variable.

summary(italy_pop_model)
## 
## Call:
## lm(formula = misperception ~ ID, data = italy_selected)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -39.827  -5.922   0.461   4.854  38.759 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  61.2410     0.3155  194.12   <2e-16 ***
## IDRight     -21.4140     0.4694  -45.62   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 8.16 on 1218 degrees of freedom
##   (8958 observations deleted due to missingness)
## Multiple R-squared:  0.6308, Adjusted R-squared:  0.6305 
## F-statistic:  2081 on 1 and 1218 DF,  p-value: < 2.2e-16
# remotes::install_github("datalorax/equatiomatic")
equatiomatic::extract_eq(italy_pop_model, use_coefs = TRUE)

\[ \operatorname{\widehat{misperception}} = 61.24 - 21.41(\operatorname{ID}_{\operatorname{Right}}) \]

datasummary_skim(italy_selected, title = "Summary Statistics")
Summary Statistics
Unique Missing Pct. Mean SD Min Median Max
gndr 3 0 1.5 0.6 1.0 2.0 9.0
essround 5 0 7.8 2.7 1.0 9.0 10.0
edulvla 6 88 2.5 2.7 1.0 2.0 88.0
edulvlb 21 12 404.6 804.6 0.0 313.0 9999.0
panpriph 12 87 3.9 2.5 0.0 4.0 10.0
panmonpb 12 88 4.5 2.7 0.0 5.0 10.0
panfolru 12 75 3.8 2.5 0.0 4.0 10.0
panclobo 12 75 6.9 2.4 0.0 7.0 10.0
panresmo 12 75 6.6 2.4 0.0 7.0 10.0
perceptions 43 88 48.4 13.4 0.0 48.9 100.0
misperception 43 88 51.6 13.4 0.0 51.1 100.0
# Recoding gender
italy_selected$gndr <- case_when(
  italy_selected$gndr == 1 ~ "Male",
  italy_selected$gndr == 2 ~ "Female",
  italy_selected$gndr == 9 ~ NA_character_,
  TRUE ~ as.character(italy_selected$gndr)
)

# Create the table with the table() function
table_data <- table(italy_selected$gndr)

# Convert the table to a data frame
table_df <- as.data.frame(table_data)

# Add a caption to the table using kable() function
table_kable <- kable(table_df, caption = "Table 1: Gender Distribution")

# Print the table
print(table_kable)
## <table>
## <caption>Table 1: Gender Distribution</caption>
##  <thead>
##   <tr>
##    <th style="text-align:left;"> Var1 </th>
##    <th style="text-align:right;"> Freq </th>
##   </tr>
##  </thead>
## <tbody>
##   <tr>
##    <td style="text-align:left;"> Female </td>
##    <td style="text-align:right;"> 5329 </td>
##   </tr>
##   <tr>
##    <td style="text-align:left;"> Male </td>
##    <td style="text-align:right;"> 4836 </td>
##   </tr>
## </tbody>
## </table>

The data presents the distribution of respondents by gender, indicating that there were 5,329 female respondents and 4,836 male respondents. This suggests that in the sample population, there were more female respondents than male respondents.

# Recoding education with case_when for consistency
italy_selected <- italy_selected %>%
  mutate(
    educ.ba = case_when(
      essround < 5 & edulvla == 5 ~ "BA or more",
      essround >= 5 & edulvlb > 600 ~ "BA or more",
      TRUE ~ "No BA"
    ),
    edulvla = ifelse(edulvla %in% c(77, 88), NA_integer_, edulvla),
    edulvlb = ifelse(edulvlb %in% c(5555, 7777, 8888), NA_integer_, edulvlb),
    educ.ba = as.character(educ.ba)  # Force educ.ba to be treated as character
  )

# Create the table with the table() function
table_data <- table(italy_selected$edulvla)

# Convert the table to a data frame
table_df <- as.data.frame(table_data)

# Add a title using add_header_above()
table_kable <- kable(table_df, caption = "Table 2: Education Levels") %>%
                add_header_above(c("Education Level" = 2), align = "c")

# Print the table
print(table_kable)
## <table>
## <caption>Table 2: Education Levels</caption>
##  <thead>
## <tr><th style="border-bottom:hidden;padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">Education Level</div></th></tr>
##   <tr>
##    <th style="text-align:left;"> Var1 </th>
##    <th style="text-align:right;"> Freq </th>
##   </tr>
##  </thead>
## <tbody>
##   <tr>
##    <td style="text-align:left;"> 1 </td>
##    <td style="text-align:right;"> 283 </td>
##   </tr>
##   <tr>
##    <td style="text-align:left;"> 2 </td>
##    <td style="text-align:right;"> 394 </td>
##   </tr>
##   <tr>
##    <td style="text-align:left;"> 3 </td>
##    <td style="text-align:right;"> 415 </td>
##   </tr>
##   <tr>
##    <td style="text-align:left;"> 5 </td>
##    <td style="text-align:right;"> 114 </td>
##   </tr>
## </tbody>
## </table>
# Recode variables with new interpretation
italy_selected <- italy_selected %>%
  mutate(
    panpriph = case_when(
      panpriph == 0 ~ "Much more important to prioritise public health",
      panpriph == 1 ~ "Slightly more important to prioritise public health",
      panpriph == 2 ~ "Somewhat more important to prioritise public health",
      panpriph == 3 ~ "Moderately more important to prioritise public health",
      panpriph == 4 ~ "Slightly more important to prioritise economic activity",
      panpriph == 5 ~ "Somewhat more important to prioritise economic activity",
      panpriph == 6 ~ "Moderately more important to prioritise economic activity",
      panpriph == 7 ~ "Much more important to prioritise economic activity",
      panpriph == 8 ~ "Much more important to prioritise economic activity",
      panpriph == 9 ~ "Much more important to prioritise economic activity",
      panpriph == 10 ~ "Much more important to prioritise economic activity",
      TRUE ~ NA_character_
    ),
    panmonpb = case_when(
      panmonpb == 0 ~ "Much more important to monitor and track the public",
      panmonpb == 1 ~ "Slightly more important to monitor and track the public",
      panmonpb == 2 ~ "Somewhat more important to monitor and track the public",
      panmonpb == 3 ~ "Moderately more important to monitor and track the public",
      panmonpb == 4 ~ "Slightly more important to maintain public privacy",
      panmonpb == 5 ~ "Somewhat more important to maintain public privacy",
      panmonpb == 6 ~ "Moderately more important to maintain public privacy",
      panmonpb == 7 ~ "Much more important to maintain public privacy",
      panmonpb == 8 ~ "Much more important to maintain public privacy",
      panmonpb == 9 ~ "Much more important to maintain public privacy",
      panmonpb == 10 ~ "Much more important to maintain public privacy",
      TRUE ~ NA_character_
    ),
    panfolru = case_when(
      panfolru == 0 ~ "Much more important to follow government rules",
      panfolru == 1 ~ "Slightly more important to follow government rules",
      panfolru == 2 ~ "Somewhat more important to follow government rules",
      panfolru == 3 ~ "Moderately more important to follow government rules",
      panfolru == 4 ~ "Slightly more important to make own decisions",
      panfolru == 5 ~ "Somewhat more important to make own decisions",
      panfolru == 6 ~ "Moderately more important to make own decisions",
      panfolru == 7 ~ "Much more important to make own decisions",
      panfolru == 8 ~ "Much more important to make own decisions",
      panfolru == 9 ~ "Much more important to make own decisions",
      panfolru == 10 ~ "Much more important to make own decisions",
      TRUE ~ NA_character_
    ),
    panclobo = case_when(
      panclobo == 0 ~ "Not at all important to close borders",
      panclobo == 1 ~ "Slightly important to close borders",
      panclobo == 2 ~ "Somewhat important to close borders",
      panclobo == 3 ~ "Moderately important to close borders",
      panclobo == 4 ~ "Very important to close borders",
      panclobo == 5 ~ "Extremely important to close borders",
      panclobo == 6 ~ "Extremely important to close borders",
      panclobo == 7 ~ "Extremely important to close borders",
      panclobo == 8 ~ "Extremely important to close borders",
      panclobo == 9 ~ "Extremely important to close borders",
      panclobo == 10 ~ "Extremely important to close borders",
      TRUE ~ NA_character_
    ),
    panresmo = case_when(
      panresmo == 0 ~ "Not at all important to restrict movement",
      panresmo == 1 ~ "Slightly important to restrict movement",
      panresmo == 2 ~ "Somewhat important to restrict movement",
      panresmo == 3 ~ "Moderately important to restrict movement",
      panresmo == 4 ~ "Very important to restrict movement",
      panresmo == 5 ~ "Extremely important to restrict movement",
      panresmo == 6 ~ "Extremely important to restrict movement",
      panresmo == 7 ~ "Extremely important to restrict movement",
      panresmo == 8 ~ "Extremely important to restrict movement",
      panresmo == 9 ~ "Extremely important to restrict movement",
      panresmo == 10 ~ "Extremely important to restrict movement",
      TRUE ~ NA_character_
    )
  )

datasummary_skim(italy_selected, type = "categorical", title = "Table 1: Summary of Categorical Variables")
Table 1: Summary of Categorical Variables
N %
gndr Female 5329 52.4
Male 4836 47.5
NA 13 0.1
panpriph Moderately more important to prioritise economic activity 128 1.3
Moderately more important to prioritise public health 142 1.4
Much more important to prioritise economic activity 189 1.9
Much more important to prioritise public health 190 1.9
Slightly more important to prioritise economic activity 143 1.4
Slightly more important to prioritise public health 64 0.6
Somewhat more important to prioritise economic activity 291 2.9
Somewhat more important to prioritise public health 140 1.4
NA 8891 87.4
panmonpb Moderately more important to maintain public privacy 117 1.1
Moderately more important to monitor and track the public 127 1.2
Much more important to maintain public privacy 330 3.2
Much more important to monitor and track the public 148 1.5
Slightly more important to maintain public privacy 129 1.3
Slightly more important to monitor and track the public 70 0.7
Somewhat more important to maintain public privacy 234 2.3
Somewhat more important to monitor and track the public 109 1.1
NA 8914 87.6
panfolru Moderately more important to follow government rules 314 3.1
Moderately more important to make own decisions 291 2.9
Much more important to follow government rules 371 3.6
Much more important to make own decisions 369 3.6
Slightly more important to follow government rules 166 1.6
Slightly more important to make own decisions 305 3.0
Somewhat more important to follow government rules 279 2.7
Somewhat more important to make own decisions 494 4.9
NA 7589 74.6
panclobo Extremely important to close borders 2181 21.4
Moderately important to close borders 122 1.2
Not at all important to close borders 30 0.3
Slightly important to close borders 20 0.2
Somewhat important to close borders 66 0.6
Very important to close borders 147 1.4
NA 7612 74.8
panresmo Extremely important to restrict movement 2136 21.0
Moderately important to restrict movement 122 1.2
Not at all important to restrict movement 42 0.4
Slightly important to restrict movement 25 0.2
Somewhat important to restrict movement 70 0.7
Very important to restrict movement 176 1.7
NA 7607 74.7
ID Left 669 6.6
Right 551 5.4
NA 8958 88.0
educ.ba BA or more 1515 14.9
No BA 8663 85.1

Interpretation:

The summary of categorical variables in Table 1 provides insights into the distribution of responses among the surveyed individuals in Italy regarding various factors related to pandemic response. The table illustrates the gender distribution, with 52.4% of respondents identifying as female and 47.5% as male. Notably, the majority of respondents did not disclose their gender, constituting only 0.1% of the sample. Regarding the importance of prioritizing public health versus economic activity during a pandemic (panpriph), a substantial portion of respondents (87.4%) did not provide a definitive preference, resulting in a significant number of missing values. However, among those who did respond, the distribution was relatively balanced between prioritizing public health and economic activity, with a slight inclination toward the former. Similarly, opinions on government monitoring versus maintaining public privacy (panmonpb) exhibited a significant proportion of missing values (87.6%). Among respondents who provided a preference, there was a diverse range of opinions, although maintaining public privacy appeared to be slightly favored. Regarding personal decision-making versus following government rules (panfolru), the data again revealed a notable proportion of missing values (74.6%). Among respondents who expressed a preference, there was a relatively even split between those favoring government rules and those advocating for personal decision-making. In terms of the importance of closing borders (panclobo) and restricting movement (panresmo) during a pandemic, a substantial majority of respondents expressed high levels of concern, with a significant proportion considering these measures extremely important.

datasummary_skim(italy_selected, title = "Table 2: Summary Statistics")
Table 2: Summary Statistics
Unique Missing Pct. Mean SD Min Median Max
essround 5 0 7.8 2.7 1.0 9.0 10.0
edulvla 5 88 2.4 1.1 1.0 2.0 5.0
edulvlb 18 13 325.0 289.5 0.0 313.0 9999.0
perceptions 43 88 48.4 13.4 0.0 48.9 100.0
misperception 43 88 51.6 13.4 0.0 51.1 100.0

Interpretation:

The summary statistics presented in Table 2 provide an overview of key variables within the dataset, including the round of the European Social Survey (essround), educational level based on ISCED 1997 levels (edulvla), and educational level based on ISCED 2011 levels (edulvlb). For the essround variable, which denotes the round of the European Social Survey, the data encompass five unique values ranging from 1 to 10, indicating the survey rounds. There are no missing values for this variable. The mean round of the survey is approximately 7.8, with a standard deviation of 2.7. The minimum round is 1, while the maximum is 10, with a median value of 9. Regarding educational attainment based on ISCED 1997 levels (edulvla), there are five unique levels ranging from 1 to 5, representing different educational qualifications. However, there are 88 missing values for this variable. The mean educational level is approximately 2.4, with a standard deviation of 1.1. The minimum level is 1, indicating incomplete primary education, while the maximum level is 5, indicating tertiary education. The median educational level is 2.0. For educational attainment based on ISCED 2011 levels (edulvlb), there are 18 unique levels, but 13 missing values are present. The mean educational level is 325.0, with a standard deviation of 289.5. The minimum level is 0.0, while the maximum level is 9999.0, suggesting potential outliers or coding inconsistencies. The median educational level is 313.0.

# Crosstabulation and visualization for panpriph and gndr*educ.ba
datasummary_crosstab(panpriph ~ gndr*educ.ba, data = italy_selected, title = "Table 3: Crosstabulation of panpriph with gndr and educ.ba")
Table 3: Crosstabulation of panpriph with gndr and educ.ba
Female
Male
panpriph BA or more No BA BA or more No BA All
Moderately more important to prioritise economic activity N 10 44 13 61 128
% row 7.8 34.4 10.2 47.7 100.0
Moderately more important to prioritise public health N 18 52 11 61 142
% row 12.7 36.6 7.7 43.0 100.0
Much more important to prioritise economic activity N 10 80 20 79 189
% row 5.3 42.3 10.6 41.8 100.0
Much more important to prioritise public health N 19 89 12 70 190
% row 10.0 46.8 6.3 36.8 100.0
Slightly more important to prioritise economic activity N 15 60 10 58 143
% row 10.5 42.0 7.0 40.6 100.0
Slightly more important to prioritise public health N 10 24 5 25 64
% row 15.6 37.5 7.8 39.1 100.0
Somewhat more important to prioritise economic activity N 36 126 18 111 291
% row 12.4 43.3 6.2 38.1 100.0
Somewhat more important to prioritise public health N 14 66 13 47 140
% row 10.0 47.1 9.3 33.6 100.0
All N 780 4549 732 4104 10178
% row 7.7 44.7 7.2 40.3 100.0

Interpretation:

Table 3 illustrates the cross tabulation of responses to the variable “panpriph,” representing the perceived importance of prioritizing public health or economic activity during a pandemic, with gender (“gndr”) and educational attainment (“educ.ba”). Across the various combinations of gender and educational attainment, respondents expressed different preferences regarding pandemic response priorities. Notably, the majority of both males and females with and without a BA or more believed that prioritizing public health was “Moderately more important” or “Much more important” compared to economic activity. However, there were variations in response proportions across different demographic groups. For instance, among females with a BA or more, 34.4% indicated that prioritizing public health was “Moderately more important,” while only 10.2% believed the same among males with a BA or more. Conversely, a higher percentage of males without a BA considered prioritizing public health to be “Moderately more important” compared to females without a BA (47.7% vs. 7.8%, respectively).

# Crosstabulation and visualization for panmonpb and gndr*educ.ba
datasummary_crosstab(panmonpb ~ gndr*educ.ba, data = italy_selected, title = "Table 4: Crosstabulation of panmonpb with gndr and educ.ba")
Table 4: Crosstabulation of panmonpb with gndr and educ.ba
Female
Male
panmonpb BA or more No BA BA or more No BA All
Moderately more important to maintain public privacy N 11 53 6 47 117
% row 9.4 45.3 5.1 40.2 100.0
Moderately more important to monitor and track the public N 13 56 6 52 127
% row 10.2 44.1 4.7 40.9 100.0
Much more important to maintain public privacy N 26 139 37 128 330
% row 7.9 42.1 11.2 38.8 100.0
Much more important to monitor and track the public N 15 64 9 60 148
% row 10.1 43.2 6.1 40.5 100.0
Slightly more important to maintain public privacy N 17 50 7 55 129
% row 13.2 38.8 5.4 42.6 100.0
Slightly more important to monitor and track the public N 10 32 8 20 70
% row 14.3 45.7 11.4 28.6 100.0
Somewhat more important to maintain public privacy N 20 89 20 105 234
% row 8.5 38.0 8.5 44.9 100.0
Somewhat more important to monitor and track the public N 19 41 9 40 109
% row 17.4 37.6 8.3 36.7 100.0
All N 780 4549 732 4104 10178
% row 7.7 44.7 7.2 40.3 100.0

Interpretation:

Table 4 presents the cross tabulation of responses to the variable “panmonpb,” reflecting the perceived importance of maintaining public privacy or monitoring and tracking the public during a pandemic, with gender (“gndr”) and educational attainment (“educ.ba”). The table reveals varying attitudes toward privacy and public monitoring across different demographic groups. Overall, respondents tended to express a higher preference for maintaining public privacy compared to monitoring and tracking the public. Among females with a BA or more, 45.3% believed that maintaining public privacy was “Moderately more important,” while only 5.1% of males with a BA or more shared this view. Conversely, a higher percentage of males without a BA considered maintaining public privacy to be “Moderately more important” compared to females without a BA (40.2% vs. 9.4%, respectively).

# Crosstabulation and visualization for panfolru and gndr*educ.ba
datasummary_crosstab(panfolru ~ gndr*educ.ba, data = italy_selected, title = "Table 5: Crosstabulation of panfolru with gndr and educ.ba")
Table 5: Crosstabulation of panfolru with gndr and educ.ba
Female
Male
panfolru BA or more No BA BA or more No BA All
Moderately more important to follow government rules N 31 139 27 117 314
% row 9.9 44.3 8.6 37.3 100.0
Moderately more important to make own decisions N 17 121 28 125 291
% row 5.8 41.6 9.6 43.0 100.0
Much more important to follow government rules N 40 157 30 144 371
% row 10.8 42.3 8.1 38.8 100.0
Much more important to make own decisions N 29 171 32 137 369
% row 7.9 46.3 8.7 37.1 100.0
Slightly more important to follow government rules N 25 65 19 57 166
% row 15.1 39.2 11.4 34.3 100.0
Slightly more important to make own decisions N 26 125 17 137 305
% row 8.5 41.0 5.6 44.9 100.0
Somewhat more important to follow government rules N 37 109 38 95 279
% row 13.3 39.1 13.6 34.1 100.0
Somewhat more important to make own decisions N 40 225 34 195 494
% row 8.1 45.5 6.9 39.5 100.0
All N 780 4549 732 4104 10178
% row 7.7 44.7 7.2 40.3 100.0

Interpretation:

Table 5 presents the cross tabulation of responses to the variable “panfolru,” which reflects preferences regarding following government rules or making personal decisions during a pandemic, with gender (“gndr”) and educational attainment (“educ.ba”). The table illustrates diverse attitudes toward government directives and personal decision-making across different demographic groups. Overall, respondents exhibited a preference for making their own decisions rather than strictly following government rules. Among females with a BA or more, 44.3% expressed a preference for making their own decisions, while only 9.9% believed it was “Moderately more important” to follow government rules. Similarly, among males without a BA, a higher percentage (43.0%) favored making their own decisions compared to following government rules (8.6%).

# Crosstabulation and visualization for panclobo and gndr*educ.ba
datasummary_crosstab(panclobo ~ gndr*educ.ba, data = italy_selected, title = "Table 6: Crosstabulation of panclobo with gndr and educ.ba")
Table 6: Crosstabulation of panclobo with gndr and educ.ba
Female
Male
panclobo BA or more No BA BA or more No BA All
Extremely important to close borders N 200 949 196 836 2181
% row 9.2 43.5 9.0 38.3 100.0
Moderately important to close borders N 13 42 7 60 122
% row 10.7 34.4 5.7 49.2 100.0
Not at all important to close borders N 3 12 4 11 30
% row 10.0 40.0 13.3 36.7 100.0
Slightly important to close borders N 1 7 1 11 20
% row 5.0 35.0 5.0 55.0 100.0
Somewhat important to close borders N 11 26 8 21 66
% row 16.7 39.4 12.1 31.8 100.0
Very important to close borders N 15 64 8 60 147
% row 10.2 43.5 5.4 40.8 100.0
All N 780 4549 732 4104 10178
% row 7.7 44.7 7.2 40.3 100.0

Interpretation:

Table 6 presents the cross tabulation of responses to the variable “panclobo,” which reflects attitudes toward closing borders during a pandemic, with gender (“gndr”) and educational attainment (“educ.ba”). The table demonstrates variations in opinions regarding the importance of closing borders across different demographic groups. Overall, a significant portion of respondents expressed extreme importance attached to closing borders, irrespective of gender or educational background. Among females with a BA or more, 43.5% considered it “Extremely important” to close borders, while among males without a BA, 38.3% held a similar view. Conversely, only a minority of respondents viewed closing borders as “Not at all important,” with 10.0% of females with a BA or more and 13.3% of males with a BA or more expressing this sentiment.

Table 7: Crosstabulation of panresmo with gndr and educ.ba
Female
Male
panresmo BA or more No BA BA or more No BA All
Extremely important to restrict movement N 194 949 178 815 2136
% row 9.1 44.4 8.3 38.2 100.0
Moderately important to restrict movement N 12 46 11 53 122
% row 9.8 37.7 9.0 43.4 100.0
Not at all important to restrict movement N 4 13 11 14 42
% row 9.5 31.0 26.2 33.3 100.0
Slightly important to restrict movement N 4 8 2 11 25
% row 16.0 32.0 8.0 44.0 100.0
Somewhat important to restrict movement N 12 23 7 28 70
% row 17.1 32.9 10.0 40.0 100.0
Very important to restrict movement N 14 67 15 80 176
% row 8.0 38.1 8.5 45.5 100.0
All N 780 4549 732 4104 10178
% row 7.7 44.7 7.2 40.3 100.0

Interpretation:

Table 7 presents the crosstabulation of responses to the variable “panresmo,” reflecting attitudes toward restricting movement during a pandemic, with gender (“gndr”) and educational attainment (“educ.ba”). The table illustrates varying opinions regarding the importance of movement restrictions across different demographic groups. Overall, a substantial proportion of respondents expressed extreme importance attached to restricting movement, irrespective of gender or educational background. Among females with a BA or more, 44.4% considered it “Extremely important” to restrict movement, while among males without a BA, 38.2% held a similar view. Conversely, a minority of respondents viewed movement restrictions as “Not at all important,” with 31.0% of females with a BA or more and 26.2% of males with a BA or more expressing this sentiment.

# Chi-square test for panfolru and gndr
chisq.test(italy_selected$panfolru, italy_selected$gndr)
## 
##  Pearson's Chi-squared test
## 
## data:  italy_selected$panfolru and italy_selected$gndr
## X-squared = 5.3731, df = 7, p-value = 0.6145
chisq.test(italy_selected$panfolru, italy_selected$educ.ba)
## 
##  Pearson's Chi-squared test
## 
## data:  italy_selected$panfolru and italy_selected$educ.ba
## X-squared = 31.043, df = 7, p-value = 6.105e-05
# Chi-square test for panpriph and gndr and education level
chisq.test(italy_selected$panpriph, italy_selected$gndr)
## 
##  Pearson's Chi-squared test
## 
## data:  italy_selected$panpriph and italy_selected$gndr
## X-squared = 11.651, df = 7, p-value = 0.1126
chisq.test(italy_selected$panpriph, italy_selected$educ.ba)
## 
##  Pearson's Chi-squared test
## 
## data:  italy_selected$panpriph and italy_selected$educ.ba
## X-squared = 2.9827, df = 7, p-value = 0.8866
# Chi-square test for panmonpb and gndr and education level
chisq.test(italy_selected$panmonpb, italy_selected$gndr)
## 
##  Pearson's Chi-squared test
## 
## data:  italy_selected$panmonpb and italy_selected$gndr
## X-squared = 6.1947, df = 7, p-value = 0.5172
chisq.test(italy_selected$panmonpb, italy_selected$educ.ba)
## 
##  Pearson's Chi-squared test
## 
## data:  italy_selected$panmonpb and italy_selected$educ.ba
## X-squared = 9.3483, df = 7, p-value = 0.2286
# Chi-square test for panclobo and gndr and education level
chisq.test(italy_selected$panclobo, italy_selected$gndr)
## 
##  Pearson's Chi-squared test
## 
## data:  italy_selected$panclobo and italy_selected$gndr
## X-squared = 4.4475, df = 5, p-value = 0.4869
chisq.test(italy_selected$panclobo, italy_selected$educ.ba)
## Warning in chisq.test(italy_selected$panclobo, italy_selected$educ.ba):
## Chi-squared approximation may be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  italy_selected$panclobo and italy_selected$educ.ba
## X-squared = 7.3184, df = 5, p-value = 0.198
# Chi-square test for panresmo and gndr and education level
chisq.test(italy_selected$panresmo, italy_selected$gndr)
## 
##  Pearson's Chi-squared test
## 
## data:  italy_selected$panresmo and italy_selected$gndr
## X-squared = 7.8289, df = 5, p-value = 0.1659
chisq.test(italy_selected$panresmo, italy_selected$educ.ba)
## Warning in chisq.test(italy_selected$panresmo, italy_selected$educ.ba):
## Chi-squared approximation may be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  italy_selected$panresmo and italy_selected$educ.ba
## X-squared = 14.301, df = 5, p-value = 0.01381

Interpretation:

The results of Pearson’s Chi-squared tests examining the association between categorical variables are as follows. Firstly, no statistically significant association was found between attitudes toward government rules (“panfolru”) and gender (“gndr”), χ^2 (7)= 5.3731,p = 0.6145. However, a significant association was observed between attitudes toward government rules and educational attainment, χ²(7) = 31.043,p < .001. Similarly, no significant association was found between attitudes toward prioritizing public health/economic activity (“panpriph”) and gender, χ²(7) = 11.651,p = .1126, or educational attainment, χ²(7) = 2.9827,p = .8866. Moreover, no significant association emerged between attitudes toward monitoring and tracking the public (“panmonpb”) and gender, χ²(7) = 6.1947,p = .5172, or educational attainment, χ²(7) = 9.3483,p = .2286. Additionally, no significant association was found between attitudes toward closing borders (“panclobo”) and gender, χ²(5) = 4.4475,p = .4869, or educational attainment, χ²(5) = 7.3184,p = .198. However, a statistically significant association was observed between attitudes toward restricting movement (“panresmo”) and educational attainment, χ²(5) = 14.301,p = .01381, but not gender, χ²(5) = 7.8289,p = .1659. These results suggest that while educational attainment plays a role in shaping attitudes toward government rules and movement restriction, gender does not appear to significantly influence these perspectives.