Importing and cleaning the data

library(readxl)
mydata <- read_xlsx("./anketag.xlsx")

library(dplyr)

mydata <- mydata %>%
  mutate(Q1 = case_when(
    Q1 == "2" ~ "16",
    Q1 == "3" ~ "17",
    Q1 == "4" ~ "18",
    Q1 == "5" ~ "19",
    Q1 == "6" ~ "20",
    Q1 == "7" ~ "21",
    Q1 == "8" ~ "22",
    Q1 == "9" ~ "23",
    Q1 == "10" ~ "24",
    Q1 == "11" ~ "25",
    Q1 == "12" ~ "26",
    Q1 == "13" ~ "27",
    TRUE ~ as.character(Q1)
  ))

head(mydata)
## # A tibble: 6 × 100
##   Q1     Q2    Q2_15_text Q3    Q3_4_text Q4    Q5    Q5_16_text Q6a  
##   <chr>  <chr> <chr>      <chr> <chr>     <chr> <chr> <chr>      <chr>
## 1 Kolik… Kate… Drugo (pr… Kdo … Drugo (p… Ali … Kate… Drugo (pr… Zara…
## 2 23     -3    -3         -3    -3        -3    -3    -3         -3   
## 3 19     -2    -2         -2    -2        -2    -2    -2         -2   
## 4 22     1     -2         2     -2        1     2     -2         1    
## 5 19     -3    -3         -3    -3        -3    -3    -3         -3   
## 6 19     -1    -1         2     -2        1     5     -2         0    
## # ℹ 91 more variables: Q6b <chr>, Q6c <chr>, Q6d <chr>, Q6e <chr>,
## #   Q6f <chr>, Q6g <chr>, Q6h <chr>, Q6h_text <chr>, Q7a <chr>,
## #   Q7b <chr>, Q7c <chr>, Q8a <chr>, Q8b <chr>, Q8c <chr>, Q8d <chr>,
## #   Q8e <chr>, Q8f <chr>, Q9a <chr>, Q9b <chr>, Q9c <chr>, Q9d <chr>,
## #   Q9e <chr>, Q10a <chr>, Q10b <chr>, Q10c <chr>, Q10d <chr>,
## #   Q10e <chr>, Q10f <chr>, Q11a <chr>, Q11b <chr>, Q11c <chr>,
## #   Q11d <chr>, Q11e <chr>, Q11f <chr>, Q11g <chr>, Q11h <chr>, …

“-1” -> Ni odgovora “-2” -> Preskok zaradi IF “-3” -> Nekončana anketa

mydata <- mydata[-1, ]
mydata$ID <- seq.int(nrow(mydata))
mydata <- mydata %>% 
  dplyr::select(ID, everything())
mydata <- mydata[!(mydata$Q22 == -3), ]
mydata <- mydata[!(mydata$Q22 == -2), ]

mydata[c("Q2_15_text", "Q3_4_text", "Q5_16_text", 
         "Q6h_text", "Q19_6_text")] <- list(NULL)
mydata <- mydata[!(mydata$Q1 == 1 | mydata$Q1 == 14 | mydata$XSpol == 3| mydata$Q19 == 6),]

Pri Q1 -> 1 pomeni da so bili stari manj kot 18 let in 12 pomeni več kot 27 Pri Q19 -> 6 pomeni izbira “drugo” pri zaposlitvi Pri Qxspol -> 3 pomeni izbira “drugo” pri spolu

mydata <- as.data.frame(sapply(mydata, as.numeric))
head(mydata)
##   ID Q1 Q2 Q3 Q4 Q5 Q6a Q6b Q6c Q6d Q6e Q6f Q6g Q6h Q7a Q7b Q7c Q8a
## 1  3 22  1  2  1  2   1   0   0   0   1   0   0   0   4   2   1   1
## 2  5 19 -1  2  1  5   0   0   0   0   0   0   0   1   4   4   2   2
## 3  6 23  1  2  1  2   1   0   0   0   0   0   0   0   4 -99   1   2
## 4  7 21  5  2  2  4   0   0   0   0   1   1   0   0 -99 -99   1   1
## 5  8 19  1  2  1  2   0   0   0   0   0   0   0   1 -99   1   3   2
## 6  9 18  2  2  1  2   1   1   1   1   1   1   0   0 -99 -99   1   1
##   Q8b Q8c Q8d Q8e Q8f Q9a Q9b Q9c Q9d Q9e Q10a Q10b Q10c Q10d Q10e
## 1   3 -99   3   2   3   5   4   4   5   5    5    5    5    5    5
## 2   3 -99 -99   2   3   2   4   3   3   4    5    5    5    5    4
## 3   3 -99   3   2   2   3   5   3   4   2    4    4    4    5    3
## 4   2 -99   3   1   3   1   4   1   5   1    5    5    3    4    4
## 5   2   1   2   2   1 -99   1   5   4   5    2    5    5    5    4
## 6   3 -99   3   1   2   5   3   5   5   5    5    5    5    5    4
##   Q10f Q11a Q11b Q11c Q11d Q11e Q11f Q11g Q11h Q12a Q12b Q12c Q12d
## 1    3    2    3    5    4    5    2    1    2    1    0    0    1
## 2    3    2    2    3    3    3    1    1    1    1    0    0    1
## 3    5    3    2    2    1    1    3    1    1    0    0    0    0
## 4    1    2    2  -99  -99    1  -99    2  -99    0    0    0    1
## 5    4    1    1    1    1    1    1    1    1    0    0    1    0
## 6    5    3    3    4    4    4    3    3    3    0    0    1    1
##   Q12e Q13 Q14a Q14b Q14c Q15a Q15b Q15c Q15d Q15e Q15f Q15g Q15h
## 1    0   4    3    4    2    4  -99    5    5  -99  -99  -99  -99
## 2    1   4    2    5    1  -99  -99    5    5  -99  -99  -99  -99
## 3    1   5    4    2    1    4  -99    5  -99  -99  -99  -99  -99
## 4    1   4    1    5    1    2  -99    5    5  -99  -99  -99  -99
## 5    0   4    4    2    4    5  -99    3    3    4    3  -99    4
## 6    1   5    1    3    1    5  -99  -99    4  -99  -99  -99  -99
##   Q15i Q15j Q16a Q16b Q16c Q16d Q16e Q16f Q16g Q16h Q16i Q16j Q17a
## 1  -99  -99    4  -99    5    5  -99  -99  -99  -99  -99  -99    2
## 2  -99  -99  -99  -99    3    3  -99  -99  -99  -99  -99  -99    1
## 3  -99  -99    5  -99    4  -99  -99  -99  -99  -99  -99  -99  -99
## 4  -99  -99    4  -99  -99  -99  -99  -99  -99  -99  -99  -99    2
## 5  -99  -99    5    3    1    2    3    3  -99  -99  -99  -99    4
## 6  -99  -99    5  -99  -99    4  -99  -99  -99  -99  -99  -99    5
##   Q17b Q17c Q17d Q17e Q17f Q17g Q17h Q17i Q17j Q18a Q18b Q18c Q18d
## 1  -99    5    5  -99  -99  -99  -99  -99  -99    5    5    3  -99
## 2  -99    5    4  -99  -99  -99  -99  -99  -99    5  -99    4    4
## 3  -99  -99  -99  -99  -99  -99  -99  -99  -99    5  -99    4  -99
## 4  -99    4  -99  -99  -99  -99  -99  -99  -99    5  -99    3  -99
## 5    3    4    4    2    3  -99  -99  -99  -99    5    4    4    4
## 6  -99  -99    3  -99  -99  -99  -99  -99  -99    5  -99  -99  -99
##   Q18e Q18f Q18g Q18h Q18i Q18j XSpol Q19 Q20 Q21 Q22
## 1  -99  -99  -99  -99  -99  -99     2   2   6   2   8
## 2  -99  -99  -99  -99  -99  -99     2   2   6   4   8
## 3  -99  -99  -99  -99  -99  -99     1   4   6   4   8
## 4  -99  -99  -99  -99  -99  -99     1   2   6   2   8
## 5    4    4    3    4    3    4     1   5  -1   6   8
## 6  -99  -99  -99  -99  -99  -99     1   1   3   1   8
library(dplyr)
mydata <- as.data.frame(mydata) %>%
  mutate_all(~ ifelse(. == -2, 0, .))
vse <- mydata[c("ID","Q1", "Q2", "Q3","Q4","Q5","Q6a","Q6d","Q6c","Q6b","Q6e","Q6f","Q6g", "Q7a","Q7b","Q7c","Q8a","Q8b","Q8c","Q8d","Q8e","Q8f", "Q11a", "Q11b", "Q11c", "Q11d", "Q11e", "Q11f", "Q11g", "Q11h", "Q12a","Q12b","Q12c","Q12d","Q12e","Q13", "XSpol", "Q19", "Q20", "Q21", "Q22", "Q9a","Q9b","Q9c","Q9d","Q9e","Q10a","Q10b","Q10c","Q10d","Q10e","Q10f", "Q13", "Q14a","Q14b","Q14c")]
vse <- vse[!(vse$Q6b == -1), ]
vse <- vse[!(vse$Q2 == -1), ]
vse <- vse %>%
  mutate(Q7a = ifelse(Q7a == -99, 5, Q7a))
vse <- vse %>%
  mutate(Q7b = ifelse(Q7b == -99, 5, Q7b))
vse <- vse %>%
  mutate(Q7c = ifelse(Q7c == -99, 5, Q7c))
vse <- vse %>%
  mutate(Q8a = ifelse(Q8a == -99, 5, Q8a))
vse <- vse %>%
  mutate(Q8b = ifelse(Q8b == -99, 5, Q8b))
vse <- vse %>%
  mutate(Q8c = ifelse(Q8c == -99, 5, Q8c))
vse <- vse %>%
  mutate(Q8d = ifelse(Q8d == -99, 5, Q8d))
vse <- vse %>%
  mutate(Q8e = ifelse(Q8e == -99, 5, Q8e))
vse <- vse %>%
  mutate(Q8f = ifelse(Q8f == -99, 5, Q8f))
vse <- vse %>%
  mutate(Q11a = ifelse(Q11a == -99, 5, Q11a))
vse <- vse %>%
  mutate(Q11b = ifelse(Q11b == -99, 5, Q11b))
vse <- vse %>%
  mutate(Q11c = ifelse(Q11c == -99, 5, Q11c))
vse <- vse %>%
  mutate(Q11d = ifelse(Q11d == -99, 5, Q11d))
vse <- vse %>%
  mutate(Q11e = ifelse(Q11e == -99, 5, Q11e))
vse <- vse %>%
  mutate(Q11f = ifelse(Q11f == -99, 5, Q11f))
vse <- vse %>%
  mutate(Q11g = ifelse(Q11g == -99, 5, Q11g))
vse <- vse %>%
  mutate(Q11h = ifelse(Q11h == -99, 5, Q11h))
vse <- vse %>%
  mutate(Q21 = ifelse(Q21 == -98, median(Q21, na.rm = TRUE), Q21))
vse <- vse %>%
  mutate(Q9a = ifelse(Q9a == -99, median(Q9a, na.rm = TRUE), Q9a))
vse <- vse %>%
  mutate(Q9b = ifelse(Q9b == -99, median(Q9b, na.rm = TRUE), Q9b))
vse <- vse %>%
  mutate(Q9d = ifelse(Q9d == -99, median(Q9d, na.rm = TRUE), Q9d))
vse <- vse %>%
  mutate(Q9c = ifelse(Q9c == -99, median(Q9c, na.rm = TRUE), Q9c))
vse <- vse %>%
  mutate(Q9e = ifelse(Q9e == -99, median(Q9e, na.rm = TRUE), Q9e))
vse <- vse %>%
  mutate(Q10f = ifelse(Q10f == -1, median(Q10e, na.rm = TRUE), Q10f))
vse <- vse %>%
  mutate(Q14b = ifelse(Q14b == -1, median(Q14b, na.rm = TRUE), Q14b))
vse <- vse %>%
  mutate(Q7a = ifelse(Q7a == -1, median(Q7a, na.rm = TRUE), Q7a))
vse <- vse %>%
  mutate(Q11e = ifelse(Q11e == -1, median(Q11e, na.rm = TRUE), Q11e))
vse <- vse %>%
  mutate(Q11f = ifelse(Q11f == -1, median(Q11f, na.rm = TRUE), Q11f))
vse <- vse %>%
  mutate(Q11h = ifelse(Q11h == -1, median(Q11h, na.rm = TRUE), Q11h))
vse <- vse %>%
  mutate(Q20 = ifelse(Q20 == -1, median(Q20, na.rm = TRUE), Q20))
vse <- vse %>%
  mutate(Q9c = ifelse(Q9c == -1, median(Q9c, na.rm = TRUE), Q9c))
vse <- filter_all(vse, all_vars(. != -1))
additional <- vse[c("ID","Q1", "Q2", "Q3","Q4","Q5","Q6a","Q6d","Q6c","Q6b","Q6e","Q6f","Q6g", "Q7a","Q7b","Q7c","Q8a","Q8b","Q8c","Q8d","Q8e","Q8f","Q9e","Q10a", "Q11a", "Q11b", "Q11c", "Q11d", "Q11e", "Q11f", "Q11g", "Q11h", "Q12a","Q12b","Q12c","Q12d","Q12e","Q13", "XSpol", "Q19", "Q20", "Q21", "Q22")]

clean <- vse[c("ID", "Q9a","Q9b","Q9c","Q9d","Q9e","Q10a","Q10b","Q10c","Q10d","Q10e","Q10f", "Q11b", "Q13", "Q14a","Q14b","Q14c")]

additional <- filter_all(additional, all_vars(. != -1))
clean <- filter_all(clean, all_vars(. != -1)) # Neodgovorjena vprašanja

The dataset additional includes all variables including the ones that will be used in the description of segments, and the dataset clean includes only the ones relevant to the segmentation.

After the cleaning process both of the datasets have the exact same amount of observations which is 290, this is important because we will be merging them in the end.

head(clean)
##   ID Q9a Q9b Q9c Q9d Q9e Q10a Q10b Q10c Q10d Q10e Q10f Q11b Q13 Q14a
## 1  3   5   4   4   5   5    5    5    5    5    5    3    3   4    3
## 2  6   3   5   3   4   2    4    4    4    5    3    5    2   5    4
## 3  7   1   4   1   5   1    5    5    3    4    4    1    2   4    1
## 4  8   2   1   5   4   5    2    5    5    5    4    4    1   4    4
## 5  9   5   3   5   5   5    5    5    5    5    4    5    3   5    1
## 6 10   2   4   2   2   2    4    4    5    5    3    4    2   4    3
##   Q14b Q14c
## 1    4    2
## 2    2    1
## 3    5    1
## 4    2    4
## 5    3    1
## 6    4    2
#install.packages("pastecs")

library(pastecs)

  # Calculate descriptive statistics
  desc_stats <- stat.desc(clean)

All variables are measured on Likert scale (1: I don’t agree at all, 5: I fully agree).

Correlation matrix

mydata_FA <- clean[c(-1)] # Selecting the relevant variables for factor analysis

R <- cor(mydata_FA) #Saving correlation matrix

psych::corPlot(R) #Graphical presentation of correlation matrix

Clustering (Segmentation)

For clustering we will use 4 variables, the three that we got from the factor analysis (Learning (willingness to learn), Knowledge (perceived knowledge about online fraud), Convenience (the importance of convenience)) and an additional one that measures the worry of people becoming victims of online fraud.

clean1 <- clean[c("Q11b" ,"Q10b","Q10d", "Q14a")]

head(clean1)
##   Q11b Q10b Q10d Q14a
## 1    3    5    5    3
## 2    2    4    5    4
## 3    2    5    4    1
## 4    1    5    5    4
## 5    3    5    5    1
## 6    2    4    5    3
rcorr(as.matrix(clean1), 
      type = "pearson")
##       Q11b Q10b  Q10d  Q14a
## Q11b  1.00 0.02 -0.14  0.18
## Q10b  0.02 1.00  0.20  0.10
## Q10d -0.14 0.20  1.00 -0.10
## Q14a  0.18 0.10 -0.10  1.00
## 
## n= 168 
## 
## 
## P
##      Q11b   Q10b   Q10d   Q14a  
## Q11b        0.7995 0.0750 0.0176
## Q10b 0.7995        0.0081 0.2135
## Q10d 0.0750 0.0081        0.2148
## Q14a 0.0176 0.2135 0.2148

We can see that all variables have a low correlation between each other, which is good for clustering.

#clean1 <- clean1[c("Q11b" ,"Q10b","Q10d", "Q14a")]

mydata_std <- as.data.frame(scale(clean1))

mydata_std$Dissimilarity <- sqrt(mydata_std$Q11b^2 + mydata_std$Q10b^2 + mydata_std$Q10d^2 + mydata_std$Q14a^2)

head(mydata_std[order(-mydata_std$Dissimilarity), ], 8
     )
##           Q11b       Q10b       Q10d       Q14a Dissimilarity
## 91   0.6072616 -1.7502384 -3.7308264  1.9997741      4.620635
## 54   1.4867440  1.0368711 -3.7308264 -1.1014141      4.291583
## 78   0.6072616 -1.7502384 -3.7308264  0.9660447      4.276027
## 42   2.3662263  1.0368711  0.5185216  3.0335035      4.018101
## 92  -0.2722207 -3.1437932 -1.6061524 -1.1014141      3.708150
## 100 -1.1517031 -3.1437932  0.5185216 -1.1014141      3.562560
## 135  2.3662263 -0.3566837 -1.6061524  1.9997741      3.507859
## 148  0.6072616 -3.1437932  0.5185216 -1.1014141      3.425519

Looking at the dissimilarity we might be able to identify some outliers.

clean1[c(91,54,78, 42, 92, 100, 135, 148),] %>%
print()
##     Q11b Q10b Q10d Q14a
## 91     3    3    3    4
## 54     4    5    3    1
## 78     3    3    3    3
## 42     5    5    5    5
## 92     2    2    4    1
## 100    1    2    5    1
## 135    5    4    4    4
## 148    3    2    5    1
clean1 <- clean1[-c(91,54,78, 42, 92, 100, 135, 148), ] #removing the four observations based on the dissimilarity and the clustering graph below
clean <- clean[-c(91,54,78, 42, 92, 100, 135, 148), ]
additional <- additional[-c(91,54,78, 42, 92, 100, 135, 148), ] # Removing the same observations from the dataset additional to have the exact observations as in clean (for the merging later)

library(factoextra)

mydata_std <- as.data.frame(scale(clean1[c("Q11b" ,"Q10b","Q10d", "Q14a")]))

Distances <- get_dist(mydata_std, 
                      method = "euclidian")

Distance2 <- Distances^2

fviz_dist(Distances^2)

get_clust_tendency(mydata_std[c("Q11b" ,"Q10b","Q10d", "Q14a")], #Hopkins statistics
                   n = nrow(mydata_std) - 1, 
                   graph = FALSE)
## $hopkins_stat
## [1] 0.5755004
## 
## $plot
## NULL

The hopkins statistic should be above 0.5

WARD <- mydata_std[c("Q11b" ,"Q10b","Q10d", "Q14a")] %>%
  get_dist(method = "euclidean") %>%  #Selecting distance
  hclust(method = "ward.D2") #Selecting algorithm (D2 automatically squares distances)

WARD
## 
## Call:
## hclust(d = ., method = "ward.D2")
## 
## Cluster method   : ward.D2 
## Distance         : euclidean 
## Number of objects: 160
fviz_dend(WARD)
## Warning: The `<scale>` argument of `guides()` cannot be `FALSE`. Use "none"
## instead as of ggplot2 3.3.4.
## ℹ The deprecated feature was likely used in the factoextra package.
##   Please report the issue at
##   <https://github.com/kassambara/factoextra/issues>.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning
## was generated.

 fviz_dend(WARD, 
           k = 2,
           cex = 0.5, 
           palette = "jama",
           color_labels_by_k = TRUE, 
           rect = TRUE)
## Warning in data.frame(xmin = unlist(xleft), ymin = unlist(ybottom),
## xmax = unlist(xright), : row names were found from a short variable
## and have been discarded

 fviz_dend(WARD, 
           k = 3,
           cex = 0.5, 
           palette = "jama",
           color_labels_by_k = TRUE, 
           rect = TRUE) 

 fviz_dend(WARD, 
           k = 4,
           cex = 0.5, 
           palette = "jama",
           color_labels_by_k = TRUE, 
           rect = TRUE)

 fviz_dend(WARD, 
           k = 5,
           cex = 0.5, 
           palette = "jama",
           color_labels_by_k = TRUE, 
           rect = TRUE)

set.seed(1)

OptNumber <- mydata_std[c("Q11b" ,"Q10b","Q10d", "Q14a")] %>%
  NbClust(distance = "euclidean",
          min.nc = 2, max.nc = 10, 
          method = "ward.D2", 
          index = "all") 
## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced

## Warning in log(det(P)/det(W)): NaNs produced
## Warning in max(DiffLev[, 3], na.rm = TRUE): no non-missing arguments
## to max; returning -Inf

## *** : The Hubert index is a graphical method of determining the number of clusters.
##                 In the plot of Hubert index, we seek a significant knee that corresponds to a 
##                 significant increase of the value of the measure i.e the significant peak in Hubert
##                 index second differences plot. 
## 
## *** : The D index is a graphical method of determining the number of clusters. 
##                 In the plot of D index, we seek a significant knee (the significant peak in Dindex
##                 second differences plot) that corresponds to a significant increase of the value of
##                 the measure. 
## 
## Warning in matrix(c(results), nrow = 2, ncol = 26): data length [51]
## is not a sub-multiple or multiple of the number of rows [2]
## Warning in matrix(c(results), nrow = 2, ncol = 26, dimnames =
## list(c("Number_clusters", : data length [51] is not a sub-multiple or
## multiple of the number of rows [2]

## ******************************************************************* 
## * Among all indices:                                                
## * 1 proposed 2 as the best number of clusters 
## * 2 proposed 5 as the best number of clusters 
## * 1 proposed 10 as the best number of clusters 
## 
##                    ***** Conclusion *****                            
##  
## * According to the majority rule, the best number of clusters is  5 
##  
##  
## *******************************************************************

From the analysis of dendograms and the test for number of clusters we have identified that 4 should be the ideal number of clusters.

clean1$ClusterWard <- cutree(WARD, 
                             k = 5) #Cutting the dendrogram
head(clean1)
##   Q11b Q10b Q10d Q14a ClusterWard
## 1    3    5    5    3           1
## 2    2    4    5    4           2
## 3    2    5    4    1           3
## 4    1    5    5    4           2
## 5    3    5    5    1           4
## 6    2    4    5    3           2
Initial_leaders <- aggregate(mydata_std[c("Q11b" ,"Q10b","Q10d", "Q14a")], 
                            by = list(clean1$ClusterWard), 
                            FUN = mean)

Initial_leaders
##   Group.1        Q11b       Q10b      Q10d       Q14a
## 1       1  1.16422662 -0.3147885  0.508152  0.2147218
## 2       2 -0.51925052  0.3977508  0.508152  1.7180088
## 3       3  0.14606059 -0.3342518 -1.955615  0.1170855
## 4       4 -0.04353964  1.0768375  0.508152 -0.5131715
## 5       5 -0.71114745 -0.7858003  0.508152 -0.4006424
K_MEANS <- hkmeans(mydata_std[c("Q11b" ,"Q10b","Q10d", "Q14a")], 
                   k = 5,
                   hc.metric = "euclidean",
                   hc.method = "ward.D2")

K_MEANS
## Hierarchical K-means clustering with 5 clusters of sizes 33, 21, 31, 35, 40
## 
## Cluster means:
##         Q11b       Q10b       Q10d        Q14a
## 1  1.3227548 -0.1461065  0.5081520  0.05123778
## 2 -0.3230534  0.5594381  0.2735075  1.65980408
## 3  0.1707773 -0.4252898 -1.9556155 -0.01248585
## 4 -0.3918568  1.0768375  0.5081520 -0.57525647
## 5 -0.7111475 -0.7858003  0.5081520 -0.40064236
## 
## Clustering vector:
##   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17 
##   2   2   3   2   4   2   5   2   1   3   5   1   4   2   3   5   4 
##  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34 
##   3   2   4   3   1   5   1   3   4   4   1   2   4   5   4   4   4 
##  35  36  37  38  39  40  41  43  44  45  46  47  48  49  50  51  52 
##   5   2   4   4   4   2   3   4   4   2   4   1   3   3   2   5   4 
##  53  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70 
##   4   5   5   4   4   2   5   2   3   3   2   1   1   1   4   1   5 
##  71  72  73  74  75  76  77  79  80  81  82  83  84  85  86  87  88 
##   5   5   5   2   3   5   4   1   1   1   5   3   1   4   5   1   5 
##  89  90  93  94  95  96  97  98  99 101 102 103 104 105 106 107 108 
##   1   3   5   2   3   2   5   5   1   3   3   1   3   4   5   4   5 
## 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 
##   5   3   5   3   5   5   1   5   5   1   5   1   5   4   3   2   5 
## 126 127 128 129 130 131 132 133 134 136 137 138 139 140 141 142 143 
##   4   1   3   3   2   1   3   4   3   1   4   1   1   3   5   3   4 
## 144 145 146 147 149 150 151 152 153 154 155 156 157 158 159 160 161 
##   1   1   3   4   4   5   5   4   3   2   4   3   5   5   4   1   5 
## 162 163 164 165 166 167 168 
##   5   1   1   5   1   1   3 
## 
## Within cluster sum of squares by cluster:
## [1] 53.63146 40.28994 87.35356 27.42253 38.73128
##  (between_SS / total_SS =  61.1 %)
## 
## Available components:
## 
##  [1] "cluster"      "centers"      "totss"        "withinss"    
##  [5] "tot.withinss" "betweenss"    "size"         "iter"        
##  [9] "ifault"       "data"         "hclust"
fviz_cluster(K_MEANS, 
             palette = "jama", 
             repel = F,
             ggtheme = theme_classic())

clean1$ClusterK_Means <- K_MEANS$cluster
head(clean1[c("Q11b" ,"Q10b","Q10d", "Q14a", "ClusterK_Means")])
##   Q11b Q10b Q10d Q14a ClusterK_Means
## 1    3    5    5    3              2
## 2    2    4    5    4              2
## 3    2    5    4    1              3
## 4    1    5    5    4              2
## 5    3    5    5    1              4
## 6    2    4    5    3              2
#Checking for reclassifications
table(clean1$ClusterWard)
## 
##  1  2  3  4  5 
## 29 16 33 42 40
table(clean1$ClusterK_Means)
## 
##  1  2  3  4  5 
## 33 21 31 35 40
table(clean1$ClusterWard, clean1$ClusterK_Means)
##    
##      1  2  3  4  5
##   1 26  3  0  0  0
##   2  0 16  0  0  0
##   3  0  2 31  0  0
##   4  7  0  0 35  0
##   5  0  0  0  0 40
Centroids <- K_MEANS$centers
Centroids
##         Q11b       Q10b       Q10d        Q14a
## 1  1.3227548 -0.1461065  0.5081520  0.05123778
## 2 -0.3230534  0.5594381  0.2735075  1.65980408
## 3  0.1707773 -0.4252898 -1.9556155 -0.01248585
## 4 -0.3918568  1.0768375  0.5081520 -0.57525647
## 5 -0.7111475 -0.7858003  0.5081520 -0.40064236
Figure <- as.data.frame(Centroids)
Figure$id <- 1:nrow(Figure)
Figure <- pivot_longer(Figure, cols = c("Q11b" ,"Q10b","Q10d", "Q14a"))

Figure$Groups <- factor(Figure$id, 
                        levels = c(1, 2, 3, 4, 5), 
                        labels = c("1", "2", "3", "4", "5"))

Figure$nameFactor <- factor(Figure$name, 
                            levels = c("Q11b" ,"Q10b","Q10d", "Q14a"), 
                            labels = c("Q11b" ,"Q10b","Q10d", "Q14a"))

ggplot(Figure, aes(x = nameFactor, y = value)) +
  geom_hline(yintercept = 0) +
  theme_bw() +
  geom_point(aes(shape = Groups, col = Groups), size = 3) +
  geom_line(aes(group = id), linewidth = 1) +
  ylab("Averages") +
  xlab("Cluster variables") +
  ylim(-2, 2)

Description of segments

length(clean1$ClusterK_Means)
## [1] 160
head(clean1)
##   Q11b Q10b Q10d Q14a ClusterWard ClusterK_Means
## 1    3    5    5    3           1              2
## 2    2    4    5    4           2              2
## 3    2    5    4    1           3              3
## 4    1    5    5    4           2              2
## 5    3    5    5    1           4              4
## 6    2    4    5    3           2              2

Age

aggregate(additional$Q1, 
          by = list(clean1$ClusterK_Means), 
          FUN = mean) # Q1 -> (Age)
##   Group.1        x
## 1       1 21.75758
## 2       2 22.57143
## 3       3 22.06452
## 4       4 22.02857
## 5       5 21.35000
fit <- aov(Q1 ~ as.factor(clean1$ClusterK_Means), 
           data = additional)

summary(fit)
##                                   Df Sum Sq Mean Sq F value Pr(>F)
## as.factor(clean1$ClusterK_Means)   4   23.6   5.899   1.244  0.295
## Residuals                        155  735.1   4.743
### Creating factor variables

clean$XspolF <- factor(additional$XSpol,
                      levels = c(1, 2),
                      labels = c("Moški", "Ženska"))

clean$IzobrazbaF <- factor(additional$Q20,
                           levels = c(1, 2, 3, 4, 5, 6, 7),
                           labels = c("Osnovna Šola", "Srednja Šola", "Gimnazija","Višješolska",
                                      "Visoka Šola", "Diploma", "Mag/Dr"))
clean <- clean %>% 
  mutate(IzobrazbaF = ifelse(IzobrazbaF %in% 
                               c("Osnovna Šola", "Srednja Šola","Gimnazija", "Višješolska"), "Nizka", "Visoka"))

clean$ZaposlitevF <- factor(additional$Q19,
                            levels = c(1, 2, 3, 4, 5),
                            labels = c("Dijak", "Študent", "Brezposelen", 
                                       "Zaposlen", "Samozaposlen"))

clean$DohodekF <- factor(additional$Q21,
                           levels = c(1, 2, 3, 4, 5, 6, 7),
                           labels = c("do500", "do800", "do1000","do1500",
                                      "do2000", "do3000", "nad3000"))

clean <- clean %>% 
  mutate(DohodekF = case_when(
    DohodekF %in% c("do500") ~ "Nizki",
    DohodekF %in% c("do800", "do1000") ~ "Srednji",
    TRUE ~ "Visok"
  ))

Gender

chi_square <- chisq.test(clean$XspolF, as.factor(clean1$ClusterK_Means))
chi_square
## 
##  Pearson's Chi-squared test
## 
## data:  clean$XspolF and as.factor(clean1$ClusterK_Means)
## X-squared = 7.2858, df = 4, p-value = 0.1215
addmargins(chi_square$observed)
##             
## clean$XspolF   1   2   3   4   5 Sum
##       Moški   13   4  15  19  17  68
##       Ženska  20  17  16  16  23  92
##       Sum     33  21  31  35  40 160
addmargins(round(chi_square$expected, 2)) 
##             
## clean$XspolF     1     2     3     4  5    Sum
##       Moški  14.03  8.93 13.18 14.88 17  68.02
##       Ženska 18.98 12.07 17.82 20.12 23  91.99
##       Sum    33.01 21.00 31.00 35.00 40 160.01
round(chi_square$res, 2) 
##             
## clean$XspolF     1     2     3     4     5
##       Moški  -0.27 -1.65  0.50  1.07  0.00
##       Ženska  0.24  1.42 -0.43 -0.92  0.00
addmargins(round(prop.table(chi_square$observed), 3))
##             
## clean$XspolF     1     2     3     4     5   Sum
##       Moški  0.081 0.025 0.094 0.119 0.106 0.425
##       Ženska 0.125 0.106 0.100 0.100 0.144 0.575
##       Sum    0.206 0.131 0.194 0.219 0.250 1.000
addmargins(round(prop.table(chi_square$observed, 1), 3), 2) 
##             
## clean$XspolF     1     2     3     4     5   Sum
##       Moški  0.191 0.059 0.221 0.279 0.250 1.000
##       Ženska 0.217 0.185 0.174 0.174 0.250 1.000
addmargins(round(prop.table(chi_square$observed, 2), 3), 1) 
##             
## clean$XspolF     1     2     3     4     5
##       Moški  0.394 0.190 0.484 0.543 0.425
##       Ženska 0.606 0.810 0.516 0.457 0.575
##       Sum    1.000 1.000 1.000 1.000 1.000

Education

chi_square1 <- chisq.test(clean$IzobrazbaF, as.factor(clean1$ClusterK_Means))
## Warning in chisq.test(clean$IzobrazbaF,
## as.factor(clean1$ClusterK_Means)): Chi-squared approximation may be
## incorrect
chi_square1
## 
##  Pearson's Chi-squared test
## 
## data:  clean$IzobrazbaF and as.factor(clean1$ClusterK_Means)
## X-squared = 1.9415, df = 4, p-value = 0.7465
addmargins(chi_square1$observed)
##                 
## clean$IzobrazbaF   1   2   3   4   5 Sum
##           Nizka    7   2   7   6   9  31
##           Visoka  26  19  24  29  31 129
##           Sum     33  21  31  35  40 160
addmargins(round(chi_square1$expected, 2))
##                 
## clean$IzobrazbaF     1     2     3     4     5 Sum
##           Nizka   6.39  4.07  6.01  6.78  7.75  31
##           Visoka 26.61 16.93 24.99 28.22 32.25 129
##           Sum    33.00 21.00 31.00 35.00 40.00 160
round(chi_square1$res, 2) 
##                 
## clean$IzobrazbaF     1     2     3     4     5
##           Nizka   0.24 -1.03  0.41 -0.30  0.45
##           Visoka -0.12  0.50 -0.20  0.15 -0.22
addmargins(round(prop.table(chi_square1$observed), 3))
##                 
## clean$IzobrazbaF     1     2     3     4     5   Sum
##           Nizka  0.044 0.013 0.044 0.038 0.056 0.195
##           Visoka 0.162 0.119 0.150 0.181 0.194 0.806
##           Sum    0.206 0.132 0.194 0.219 0.250 1.001
addmargins(round(prop.table(chi_square1$observed, 1), 3), 2) 
##                 
## clean$IzobrazbaF     1     2     3     4     5   Sum
##           Nizka  0.226 0.065 0.226 0.194 0.290 1.001
##           Visoka 0.202 0.147 0.186 0.225 0.240 1.000
addmargins(round(prop.table(chi_square1$observed, 2), 3), 1) 
##                 
## clean$IzobrazbaF     1     2     3     4     5
##           Nizka  0.212 0.095 0.226 0.171 0.225
##           Visoka 0.788 0.905 0.774 0.829 0.775
##           Sum    1.000 1.000 1.000 1.000 1.000

Employment

chi_square2 <- chisq.test(clean$ZaposlitevF, as.factor(clean1$ClusterK_Means))
## Warning in chisq.test(clean$ZaposlitevF,
## as.factor(clean1$ClusterK_Means)): Chi-squared approximation may be
## incorrect
chi_square2
## 
##  Pearson's Chi-squared test
## 
## data:  clean$ZaposlitevF and as.factor(clean1$ClusterK_Means)
## X-squared = 12.235, df = 12, p-value = 0.427
addmargins(chi_square2$observed)
##                  
## clean$ZaposlitevF   1   2   3   4   5 Sum
##      Dijak          4   0   2   4   7  17
##      Študent       23  18  23  23  29 116
##      Zaposlen       4   1   5   7   4  21
##      Samozaposlen   2   2   1   1   0   6
##      Sum           33  21  31  35  40 160
addmargins(round(chi_square2$expected, 2))
##                  
## clean$ZaposlitevF     1     2     3     4     5 Sum
##      Dijak         3.51  2.23  3.29  3.72  4.25  17
##      Študent      23.92 15.22 22.48 25.38 29.00 116
##      Zaposlen      4.33  2.76  4.07  4.59  5.25  21
##      Samozaposlen  1.24  0.79  1.16  1.31  1.50   6
##      Sum          33.00 21.00 31.00 35.00 40.00 160
round(chi_square2$res, 2) 
##                  
## clean$ZaposlitevF     1     2     3     4     5
##      Dijak         0.26 -1.49 -0.71  0.15  1.33
##      Študent      -0.19  0.71  0.11 -0.47  0.00
##      Zaposlen     -0.16 -1.06  0.46  1.12 -0.55
##      Samozaposlen  0.69  1.37 -0.15 -0.27 -1.22
addmargins(round(prop.table(chi_square2$observed), 3))
##                  
## clean$ZaposlitevF     1     2     3     4     5   Sum
##      Dijak        0.025 0.000 0.013 0.025 0.044 0.107
##      Študent      0.144 0.112 0.144 0.144 0.181 0.725
##      Zaposlen     0.025 0.006 0.031 0.044 0.025 0.131
##      Samozaposlen 0.013 0.013 0.006 0.006 0.000 0.038
##      Sum          0.207 0.131 0.194 0.219 0.250 1.001
addmargins(round(prop.table(chi_square2$observed, 1), 3), 2) 
##                  
## clean$ZaposlitevF     1     2     3     4     5   Sum
##      Dijak        0.235 0.000 0.118 0.235 0.412 1.000
##      Študent      0.198 0.155 0.198 0.198 0.250 0.999
##      Zaposlen     0.190 0.048 0.238 0.333 0.190 0.999
##      Samozaposlen 0.333 0.333 0.167 0.167 0.000 1.000
addmargins(round(prop.table(chi_square2$observed, 2), 3), 1) 
##                  
## clean$ZaposlitevF     1     2     3     4     5
##      Dijak        0.121 0.000 0.065 0.114 0.175
##      Študent      0.697 0.857 0.742 0.657 0.725
##      Zaposlen     0.121 0.048 0.161 0.200 0.100
##      Samozaposlen 0.061 0.095 0.032 0.029 0.000
##      Sum          1.000 1.000 1.000 1.000 1.000

#Dohodek

chi_square3 <- chisq.test(clean$DohodekF, as.factor(clean1$ClusterK_Means))
chi_square3
## 
##  Pearson's Chi-squared test
## 
## data:  clean$DohodekF and as.factor(clean1$ClusterK_Means)
## X-squared = 3.2624, df = 8, p-value = 0.9168
addmargins(chi_square3$observed)
##               
## clean$DohodekF   1   2   3   4   5 Sum
##        Nizki    12  10  11  12  20  65
##        Srednji  11   6  11  13  10  51
##        Visok    10   5   9  10  10  44
##        Sum      33  21  31  35  40 160
addmargins(round(chi_square3$expected, 2)) 
##               
## clean$DohodekF     1     2     3     4     5 Sum
##        Nizki   13.41  8.53 12.59 14.22 16.25  65
##        Srednji 10.52  6.69  9.88 11.16 12.75  51
##        Visok    9.07  5.78  8.53  9.62 11.00  44
##        Sum     33.00 21.00 31.00 35.00 40.00 160
round(chi_square3$res, 2) 
##               
## clean$DohodekF     1     2     3     4     5
##        Nizki   -0.38  0.50 -0.45 -0.59  0.93
##        Srednji  0.15 -0.27  0.36  0.55 -0.77
##        Visok    0.31 -0.32  0.16  0.12 -0.30
addmargins(round(prop.table(chi_square3$observed), 3))
##               
## clean$DohodekF     1     2     3     4     5   Sum
##        Nizki   0.075 0.062 0.069 0.075 0.125 0.406
##        Srednji 0.069 0.038 0.069 0.081 0.062 0.319
##        Visok   0.062 0.031 0.056 0.062 0.062 0.273
##        Sum     0.206 0.131 0.194 0.218 0.249 0.998
addmargins(round(prop.table(chi_square3$observed, 1), 3), 2) 
##               
## clean$DohodekF     1     2     3     4     5   Sum
##        Nizki   0.185 0.154 0.169 0.185 0.308 1.001
##        Srednji 0.216 0.118 0.216 0.255 0.196 1.001
##        Visok   0.227 0.114 0.205 0.227 0.227 1.000
addmargins(round(prop.table(chi_square3$observed, 2), 3), 1) 
##               
## clean$DohodekF     1     2     3     4     5
##        Nizki   0.364 0.476 0.355 0.343 0.500
##        Srednji 0.333 0.286 0.355 0.371 0.250
##        Visok   0.303 0.238 0.290 0.286 0.250
##        Sum     1.000 1.000 1.000 1.000 1.000

kdo vam je odprl prvi bančni račun?

clean$prviračinF <- factor(additional$Q3,
                      levels = c(1, 2),
                      labels = c("Sam", "Starši"))
chi_square4 <- chisq.test(clean$prviračinF, as.factor(clean1$ClusterK_Means))
## Warning in chisq.test(clean$prviračinF,
## as.factor(clean1$ClusterK_Means)): Chi-squared approximation may be
## incorrect
chi_square4
## 
##  Pearson's Chi-squared test
## 
## data:  clean$prviračinF and as.factor(clean1$ClusterK_Means)
## X-squared = 9.5917, df = 4, p-value = 0.0479
addmargins(chi_square3$observed)
##               
## clean$DohodekF   1   2   3   4   5 Sum
##        Nizki    12  10  11  12  20  65
##        Srednji  11   6  11  13  10  51
##        Visok    10   5   9  10  10  44
##        Sum      33  21  31  35  40 160
addmargins(round(chi_square4$expected, 2)) 
##                 
## clean$prviračinF     1     2     3     4  5    Sum
##           Sam     7.42  4.72  6.97  7.88  9  35.99
##           Starši 25.58 16.27 24.02 27.12 31 123.99
##           Sum    33.00 20.99 30.99 35.00 40 159.98
round(chi_square4$res, 2) 
##                 
## clean$prviračinF     1     2     3     4     5
##           Sam    -0.16 -1.71  1.15  1.47 -1.00
##           Starši  0.08  0.92 -0.62 -0.79  0.54
addmargins(round(prop.table(chi_square4$observed), 3))
##                 
## clean$prviračinF     1     2     3     4     5   Sum
##           Sam    0.044 0.006 0.062 0.075 0.038 0.225
##           Starši 0.162 0.125 0.131 0.144 0.212 0.774
##           Sum    0.206 0.131 0.193 0.219 0.250 0.999
addmargins(round(prop.table(chi_square4$observed, 1), 3), 2) 
##                 
## clean$prviračinF     1     2     3     4     5   Sum
##           Sam    0.194 0.028 0.278 0.333 0.167 1.000
##           Starši 0.210 0.161 0.169 0.185 0.274 0.999
addmargins(round(prop.table(chi_square4$observed, 2), 3), 1) 
##                 
## clean$prviračinF     1     2     3     4     5
##           Sam    0.212 0.048 0.323 0.343 0.150
##           Starši 0.788 0.952 0.677 0.657 0.850
##           Sum    1.000 1.000 1.000 1.000 1.000

#Kako pogosto uporabljate naslednje bančne storitve?

clean$storitveF <- factor(additional$Q7c,
                      levels = c(1, 2, 3, 4),
                      labels = c("dnevno ", "tedensko", "mesecno", "letno"))

chi_square6 <- chisq.test(clean$storitveF, as.factor(clean1$ClusterK_Means))
## Warning in chisq.test(clean$storitveF,
## as.factor(clean1$ClusterK_Means)): Chi-squared approximation may be
## incorrect
chi_square6
## 
##  Pearson's Chi-squared test
## 
## data:  clean$storitveF and as.factor(clean1$ClusterK_Means)
## X-squared = 10.181, df = 8, p-value = 0.2526
addmargins(chi_square6$observed)
##                
## clean$storitveF   1   2   3   4   5 Sum
##        dnevno    20  13  21  23  18  95
##        tedensko  11   6   8  12  17  54
##        mesecno    1   2   1   0   5   9
##        Sum       32  21  30  35  40 158
addmargins(round(chi_square6$expected, 2))
##                
## clean$storitveF     1     2     3     4     5 Sum
##        dnevno   19.24 12.63 18.04 21.04 24.05  95
##        tedensko 10.94  7.18 10.25 11.96 13.67  54
##        mesecno   1.82  1.20  1.71  1.99  2.28   9
##        Sum      32.00 21.01 30.00 34.99 40.00 158
round(chi_square6$res, 2) 
##                
## clean$storitveF     1     2     3     4     5
##        dnevno    0.17  0.11  0.70  0.43 -1.23
##        tedensko  0.02 -0.44 -0.70  0.01  0.90
##        mesecno  -0.61  0.73 -0.54 -1.41  1.80
addmargins(round(prop.table(chi_square6$observed), 3))
##                
## clean$storitveF     1     2     3     4     5   Sum
##        dnevno   0.127 0.082 0.133 0.146 0.114 0.602
##        tedensko 0.070 0.038 0.051 0.076 0.108 0.343
##        mesecno  0.006 0.013 0.006 0.000 0.032 0.057
##        Sum      0.203 0.133 0.190 0.222 0.254 1.002
addmargins(round(prop.table(chi_square6$observed, 1), 3), 2) 
##                
## clean$storitveF     1     2     3     4     5   Sum
##        dnevno   0.211 0.137 0.221 0.242 0.189 1.000
##        tedensko 0.204 0.111 0.148 0.222 0.315 1.000
##        mesecno  0.111 0.222 0.111 0.000 0.556 1.000
addmargins(round(prop.table(chi_square6$observed, 2), 3), 1) 
##                
## clean$storitveF     1     2     3     4     5
##        dnevno   0.625 0.619 0.700 0.657 0.450
##        tedensko 0.344 0.286 0.267 0.343 0.425
##        mesecno  0.031 0.095 0.033 0.000 0.125
##        Sum      1.000 1.000 1.000 1.000 1.000
aggregate(additional$Q7c, 
          by = list(clean1$ClusterK_Means), 
          FUN = mean) 
##   Group.1        x
## 1       1 1.515152
## 2       2 1.476190
## 3       3 1.451613
## 4       4 1.342857
## 5       5 1.675000

##Katere funkcije najpogosteje uporabljate v mobilni bančni aplikaciji?

clean$prijatelji <- factor(additional$Q8f,
                      levels = c(1, 2, 3, 4),
                      labels = c("dnevno ", "tedensko", "mesecno", "letno"))

chi_square7 <- chisq.test(clean$prijatelji, as.factor(clean1$ClusterK_Means))
## Warning in chisq.test(clean$prijatelji,
## as.factor(clean1$ClusterK_Means)): Chi-squared approximation may be
## incorrect
chi_square7
## 
##  Pearson's Chi-squared test
## 
## data:  clean$prijatelji and as.factor(clean1$ClusterK_Means)
## X-squared = 17.801, df = 12, p-value = 0.1219
addmargins(chi_square7$observed)
##                 
## clean$prijatelji   1   2   3   4   5 Sum
##         dnevno     3   7   8  11   8  37
##         tedensko  17  10  14  16  20  77
##         mesecno   11   2   6   6  11  36
##         letno      0   2   0   1   0   3
##         Sum       31  21  28  34  39 153
addmargins(round(chi_square7$expected, 2))
##                 
## clean$prijatelji     1     2     3     4     5 Sum
##         dnevno    7.50  5.08  6.77  8.22  9.43  37
##         tedensko 15.60 10.57 14.09 17.11 19.63  77
##         mesecno   7.29  4.94  6.59  8.00  9.18  36
##         letno     0.61  0.41  0.55  0.67  0.76   3
##         Sum      31.00 21.00 28.00 34.00 39.00 153
round(chi_square7$res, 2) 
##                 
## clean$prijatelji     1     2     3     4     5
##         dnevno   -1.64  0.85  0.47  0.97 -0.47
##         tedensko  0.35 -0.17 -0.02 -0.27  0.08
##         mesecno   1.37 -1.32 -0.23 -0.71  0.60
##         letno    -0.78  2.48 -0.74  0.41 -0.87

##Kakšne oglase si najbolj zapomnite?

clean$emotion <- factor(additional$Q12d,
                      levels = c(0, 1),
                      labels = c("ne ", "ja"))

chi_square8 <- chisq.test(clean$emotion, as.factor(clean1$ClusterK_Means))
chi_square8
## 
##  Pearson's Chi-squared test
## 
## data:  clean$emotion and as.factor(clean1$ClusterK_Means)
## X-squared = 1.7727, df = 4, p-value = 0.7775
addmargins(chi_square8$observed)
##              
## clean$emotion   1   2   3   4   5 Sum
##           ne   17  10  14  21  22  84
##           ja   16  11  17  14  18  76
##           Sum  33  21  31  35  40 160
addmargins(round(chi_square8$expected, 2))
##              
## clean$emotion     1     2     3     4  5    Sum
##           ne  17.32 11.03 16.27 18.38 21  84.00
##           ja  15.68  9.97 14.72 16.62 19  75.99
##           Sum 33.00 21.00 30.99 35.00 40 159.99
round(chi_square8$res, 2) 
##              
## clean$emotion     1     2     3     4     5
##           ne  -0.08 -0.31 -0.56  0.61  0.22
##           ja   0.08  0.32  0.59 -0.64 -0.23

#Kako pomemben vam je občutek uspeha pri varčevanju denarja?

clean$varčevanje <- factor(additional$Q13,
                      levels = c(1, 2, 3, 4, 5),
                      labels = c("1 ", "2", "3", "4", "5"))

chi_square9 <- chisq.test(clean$varčevanje, as.factor(clean1$ClusterK_Means))
## Warning in chisq.test(clean$varčevanje,
## as.factor(clean1$ClusterK_Means)): Chi-squared approximation may be
## incorrect
chi_square9
## 
##  Pearson's Chi-squared test
## 
## data:  clean$varčevanje and as.factor(clean1$ClusterK_Means)
## X-squared = 31.759, df = 16, p-value = 0.01075
addmargins(chi_square9$observed)
##                 
## clean$varčevanje   1   2   3   4   5 Sum
##              1     0   0   1   1   0   2
##              2     0   0   0   2   4   6
##              3     0   1   6   2   7  16
##              4    26  15  20  23  14  98
##              5     7   5   4   7  15  38
##              Sum  33  21  31  35  40 160
addmargins(round(chi_square9$expected, 2))
##                 
## clean$varčevanje     1     2     3     4    5 Sum
##              1    0.41  0.26  0.39  0.44  0.5   2
##              2    1.24  0.79  1.16  1.31  1.5   6
##              3    3.30  2.10  3.10  3.50  4.0  16
##              4   20.21 12.86 18.99 21.44 24.5  98
##              5    7.84  4.99  7.36  8.31  9.5  38
##              Sum 33.00 21.00 31.00 35.00 40.0 160
round(chi_square9$res, 2) 
##                 
## clean$varčevanje     1     2     3     4     5
##               1  -0.64 -0.51  0.98  0.85 -0.71
##               2  -1.11 -0.89 -1.08  0.60  2.04
##               3  -1.82 -0.76  1.65 -0.80  1.50
##               4   1.29  0.60  0.23  0.34 -2.12
##               5  -0.30  0.01 -1.24 -0.46  1.78
addmargins(round(prop.table(chi_square9$observed), 3))
##                 
## clean$varčevanje     1     2     3     4     5   Sum
##              1   0.000 0.000 0.006 0.006 0.000 0.012
##              2   0.000 0.000 0.000 0.013 0.025 0.038
##              3   0.000 0.006 0.038 0.013 0.044 0.101
##              4   0.162 0.094 0.125 0.144 0.088 0.613
##              5   0.044 0.031 0.025 0.044 0.094 0.238
##              Sum 0.206 0.131 0.194 0.220 0.251 1.002
addmargins(round(prop.table(chi_square9$observed, 1), 3), 2) 
##                 
## clean$varčevanje     1     2     3     4     5   Sum
##               1  0.000 0.000 0.500 0.500 0.000 1.000
##               2  0.000 0.000 0.000 0.333 0.667 1.000
##               3  0.000 0.062 0.375 0.125 0.438 1.000
##               4  0.265 0.153 0.204 0.235 0.143 1.000
##               5  0.184 0.132 0.105 0.184 0.395 1.000
addmargins(round(prop.table(chi_square9$observed, 2), 3), 1) 
##                 
## clean$varčevanje     1     2     3     4     5
##              1   0.000 0.000 0.032 0.029 0.000
##              2   0.000 0.000 0.000 0.057 0.100
##              3   0.000 0.048 0.194 0.057 0.175
##              4   0.788 0.714 0.645 0.657 0.350
##              5   0.212 0.238 0.129 0.200 0.375
##              Sum 1.000 1.000 1.000 1.000 1.000

##Koliko vas na splošno pritegnejo oglasi na spodnjih kanalih?

social_oglasi_mean <- rowMeans(cbind(additional$Q11c, additional$Q11d, additional$Q11e, additional$Q11f))

clean$social_oglasi <- factor(round(social_oglasi_mean),
                              levels = c(1, 2, 3, 4, 5),
                              labels = c("1", "2", "3", "4", "5"))

chi_square10 <- chisq.test(clean$social_oglasi, as.factor(clean1$ClusterK_Means))
## Warning in chisq.test(clean$social_oglasi,
## as.factor(clean1$ClusterK_Means)): Chi-squared approximation may be
## incorrect
chi_square10
## 
##  Pearson's Chi-squared test
## 
## data:  clean$social_oglasi and as.factor(clean1$ClusterK_Means)
## X-squared = 27.635, df = 16, p-value = 0.03494
addmargins(chi_square10$observed)
##                    
## clean$social_oglasi   1   2   3   4   5 Sum
##                 1     2   6   8  10  17  43
##                 2     9   4   7  11  13  44
##                 3     9   8  10   7   6  40
##                 4    11   3   6   7   4  31
##                 5     2   0   0   0   0   2
##                 Sum  33  21  31  35  40 160
addmargins(round(chi_square10$expected, 2))
##                    
## clean$social_oglasi     1     2     3     4     5 Sum
##                 1    8.87  5.64  8.33  9.41 10.75  43
##                 2    9.07  5.78  8.53  9.62 11.00  44
##                 3    8.25  5.25  7.75  8.75 10.00  40
##                 4    6.39  4.07  6.01  6.78  7.75  31
##                 5    0.41  0.26  0.39  0.44  0.50   2
##                 Sum 32.99 21.00 31.01 35.00 40.00 160
round(chi_square10$res, 2) 
##                    
## clean$social_oglasi     1     2     3     4     5
##                   1 -2.31  0.15 -0.11  0.19  1.91
##                   2 -0.02 -0.74 -0.52  0.44  0.60
##                   3  0.26  1.20  0.81 -0.59 -1.26
##                   4  1.82 -0.53  0.00  0.08 -1.35
##                   5  2.47 -0.51 -0.62 -0.66 -0.71
addmargins(round(prop.table(chi_square10$observed), 3))
##                    
## clean$social_oglasi     1     2     3     4     5   Sum
##                 1   0.013 0.038 0.050 0.062 0.106 0.269
##                 2   0.056 0.025 0.044 0.069 0.081 0.275
##                 3   0.056 0.050 0.062 0.044 0.038 0.250
##                 4   0.069 0.019 0.038 0.044 0.025 0.195
##                 5   0.013 0.000 0.000 0.000 0.000 0.013
##                 Sum 0.207 0.132 0.194 0.219 0.250 1.002
addmargins(round(prop.table(chi_square10$observed, 1), 3), 2) 
##                    
## clean$social_oglasi     1     2     3     4     5   Sum
##                   1 0.047 0.140 0.186 0.233 0.395 1.001
##                   2 0.205 0.091 0.159 0.250 0.295 1.000
##                   3 0.225 0.200 0.250 0.175 0.150 1.000
##                   4 0.355 0.097 0.194 0.226 0.129 1.001
##                   5 1.000 0.000 0.000 0.000 0.000 1.000
addmargins(round(prop.table(chi_square10$observed, 2), 3), 1) 
##                    
## clean$social_oglasi     1     2     3     4     5
##                 1   0.061 0.286 0.258 0.286 0.425
##                 2   0.273 0.190 0.226 0.314 0.325
##                 3   0.273 0.381 0.323 0.200 0.150
##                 4   0.333 0.143 0.194 0.200 0.100
##                 5   0.061 0.000 0.000 0.000 0.000
##                 Sum 1.001 1.000 1.001 1.000 1.000

fizična banka

clean$storitveaF <- factor(additional$Q7a,
                      levels = c(1, 2, 3, 4),
                      labels = c("dnevno ", "tedensko", "mesecno", "letno"))

chi_square11 <- chisq.test(clean$storitveaF, as.factor(clean1$ClusterK_Means))
## Warning in chisq.test(clean$storitveaF,
## as.factor(clean1$ClusterK_Means)): Chi-squared approximation may be
## incorrect
chi_square11
## 
##  Pearson's Chi-squared test
## 
## data:  clean$storitveaF and as.factor(clean1$ClusterK_Means)
## X-squared = 14.498, df = 12, p-value = 0.27
addmargins(chi_square11$observed)
##                 
## clean$storitveaF   1   2   3   4   5 Sum
##         dnevno     0   0   0   0   1   1
##         tedensko   0   0   1   2   0   3
##         mesecno    3   2   7   4   2  18
##         letno     25  15  17  20  28 105
##         Sum       28  17  25  26  31 127
addmargins(round(chi_square11$expected, 2))
##                 
## clean$storitveaF     1     2     3     4     5    Sum
##         dnevno    0.22  0.13  0.20  0.20  0.24   0.99
##         tedensko  0.66  0.40  0.59  0.61  0.73   2.99
##         mesecno   3.97  2.41  3.54  3.69  4.39  18.00
##         letno    23.15 14.06 20.67 21.50 25.63 105.01
##         Sum      28.00 17.00 25.00 26.00 30.99 126.99
round(chi_square11$res, 2) 
##                 
## clean$storitveaF     1     2     3     4     5
##         dnevno   -0.47 -0.37 -0.44 -0.45  1.53
##         tedensko -0.81 -0.63  0.53  1.77 -0.86
##         mesecno  -0.49 -0.26  1.84  0.16 -1.14
##         letno     0.38  0.25 -0.81 -0.32  0.47
addmargins(round(prop.table(chi_square11$observed), 3))
##                 
## clean$storitveaF     1     2     3     4     5   Sum
##         dnevno   0.000 0.000 0.000 0.000 0.008 0.008
##         tedensko 0.000 0.000 0.008 0.016 0.000 0.024
##         mesecno  0.024 0.016 0.055 0.031 0.016 0.142
##         letno    0.197 0.118 0.134 0.157 0.220 0.826
##         Sum      0.221 0.134 0.197 0.204 0.244 1.000
addmargins(round(prop.table(chi_square11$observed, 1), 3), 2) 
##                 
## clean$storitveaF     1     2     3     4     5   Sum
##         dnevno   0.000 0.000 0.000 0.000 1.000 1.000
##         tedensko 0.000 0.000 0.333 0.667 0.000 1.000
##         mesecno  0.167 0.111 0.389 0.222 0.111 1.000
##         letno    0.238 0.143 0.162 0.190 0.267 1.000
addmargins(round(prop.table(chi_square11$observed, 2), 3), 1) 
##                 
## clean$storitveaF     1     2     3     4     5
##         dnevno   0.000 0.000 0.000 0.000 0.032
##         tedensko 0.000 0.000 0.040 0.077 0.000
##         mesecno  0.107 0.118 0.280 0.154 0.065
##         letno    0.893 0.882 0.680 0.769 0.903
##         Sum      1.000 1.000 1.000 1.000 1.000

##Q8 pošiljanje denarja med prijatelji

clean$prijatenljiFF <- factor(additional$Q8a,
                      levels = c(1, 2, 3, 4),
                      labels = c("dnevno ", "tedensko", "mesecno", "letno"))

chi_square12 <- chisq.test(clean$storitveF, as.factor(clean1$ClusterK_Means))
## Warning in chisq.test(clean$storitveF,
## as.factor(clean1$ClusterK_Means)): Chi-squared approximation may be
## incorrect
chi_square12
## 
##  Pearson's Chi-squared test
## 
## data:  clean$storitveF and as.factor(clean1$ClusterK_Means)
## X-squared = 10.181, df = 8, p-value = 0.2526
addmargins(chi_square12$observed)
##                
## clean$storitveF   1   2   3   4   5 Sum
##        dnevno    20  13  21  23  18  95
##        tedensko  11   6   8  12  17  54
##        mesecno    1   2   1   0   5   9
##        Sum       32  21  30  35  40 158
addmargins(round(chi_square12$expected, 2))
##                
## clean$storitveF     1     2     3     4     5 Sum
##        dnevno   19.24 12.63 18.04 21.04 24.05  95
##        tedensko 10.94  7.18 10.25 11.96 13.67  54
##        mesecno   1.82  1.20  1.71  1.99  2.28   9
##        Sum      32.00 21.01 30.00 34.99 40.00 158
round(chi_square12$res, 2) 
##                
## clean$storitveF     1     2     3     4     5
##        dnevno    0.17  0.11  0.70  0.43 -1.23
##        tedensko  0.02 -0.44 -0.70  0.01  0.90
##        mesecno  -0.61  0.73 -0.54 -1.41  1.80
addmargins(round(prop.table(chi_square12$observed), 3))
##                
## clean$storitveF     1     2     3     4     5   Sum
##        dnevno   0.127 0.082 0.133 0.146 0.114 0.602
##        tedensko 0.070 0.038 0.051 0.076 0.108 0.343
##        mesecno  0.006 0.013 0.006 0.000 0.032 0.057
##        Sum      0.203 0.133 0.190 0.222 0.254 1.002
addmargins(round(prop.table(chi_square12$observed, 1), 3), 2) 
##                
## clean$storitveF     1     2     3     4     5   Sum
##        dnevno   0.211 0.137 0.221 0.242 0.189 1.000
##        tedensko 0.204 0.111 0.148 0.222 0.315 1.000
##        mesecno  0.111 0.222 0.111 0.000 0.556 1.000
addmargins(round(prop.table(chi_square12$observed, 2), 3), 1) 
##                
## clean$storitveF     1     2     3     4     5
##        dnevno   0.625 0.619 0.700 0.657 0.450
##        tedensko 0.344 0.286 0.267 0.343 0.425
##        mesecno  0.031 0.095 0.033 0.000 0.125
##        Sum      1.000 1.000 1.000 1.000 1.000

varčevanje

clean$varčevanjeF <- factor(additional$Q8b,
                      levels = c(1, 2, 3, 4),
                      labels = c("dnevno ", "tedensko", "mesecno", "letno"))

chi_square13 <- chisq.test(clean$varčevanjeF, as.factor(clean1$ClusterK_Means))
## Warning in chisq.test(clean$varčevanjeF,
## as.factor(clean1$ClusterK_Means)): Chi-squared approximation may be
## incorrect
chi_square13
## 
##  Pearson's Chi-squared test
## 
## data:  clean$varčevanjeF and as.factor(clean1$ClusterK_Means)
## X-squared = 10.196, df = 12, p-value = 0.5988
addmargins(chi_square13$observed)
##                  
## clean$varčevanjeF   1   2   3   4   5 Sum
##          dnevno     1   2   3   7   5  18
##          tedensko   5   3   4   2   5  19
##          mesecno   11   8  12  12  18  61
##          letno      3   2   2   0   2   9
##          Sum       20  15  21  21  30 107
addmargins(round(chi_square13$expected, 2))
##                  
## clean$varčevanjeF     1     2     3     4     5    Sum
##          dnevno    3.36  2.52  3.53  3.53  5.05  17.99
##          tedensko  3.55  2.66  3.73  3.73  5.33  19.00
##          mesecno  11.40  8.55 11.97 11.97 17.10  60.99
##          letno     1.68  1.26  1.77  1.77  2.52   9.00
##          Sum      19.99 14.99 21.00 21.00 30.00 106.98
round(chi_square12$res, 2) 
##                
## clean$storitveF     1     2     3     4     5
##        dnevno    0.17  0.11  0.70  0.43 -1.23
##        tedensko  0.02 -0.44 -0.70  0.01  0.90
##        mesecno  -0.61  0.73 -0.54 -1.41  1.80
addmargins(round(prop.table(chi_square13$observed), 3))
##                  
## clean$varčevanjeF     1     2     3     4     5   Sum
##          dnevno   0.009 0.019 0.028 0.065 0.047 0.168
##          tedensko 0.047 0.028 0.037 0.019 0.047 0.178
##          mesecno  0.103 0.075 0.112 0.112 0.168 0.570
##          letno    0.028 0.019 0.019 0.000 0.019 0.085
##          Sum      0.187 0.141 0.196 0.196 0.281 1.001
addmargins(round(prop.table(chi_square13$observed, 1), 3), 2) 
##                  
## clean$varčevanjeF     1     2     3     4     5   Sum
##          dnevno   0.056 0.111 0.167 0.389 0.278 1.001
##          tedensko 0.263 0.158 0.211 0.105 0.263 1.000
##          mesecno  0.180 0.131 0.197 0.197 0.295 1.000
##          letno    0.333 0.222 0.222 0.000 0.222 0.999
addmargins(round(prop.table(chi_square13$observed, 2), 3), 1) 
##                  
## clean$varčevanjeF     1     2     3     4     5
##          dnevno   0.050 0.133 0.143 0.333 0.167
##          tedensko 0.250 0.200 0.190 0.095 0.167
##          mesecno  0.550 0.533 0.571 0.571 0.600
##          letno    0.150 0.133 0.095 0.000 0.067
##          Sum      1.000 0.999 0.999 0.999 1.001
clean$varčevanjeF <- factor(additional$Q9e,
                      levels = c(1, 2, 3, 4, 5),
                      labels = c("nikakor se ne stirnjam ", "ne strinjam", "niti niti", "strinjam", "popolnoma strinjam"))

chi_square14 <- chisq.test(clean$varčevanjeF, as.factor(clean1$ClusterK_Means))
## Warning in chisq.test(clean$varčevanjeF,
## as.factor(clean1$ClusterK_Means)): Chi-squared approximation may be
## incorrect
chi_square14
## 
##  Pearson's Chi-squared test
## 
## data:  clean$varčevanjeF and as.factor(clean1$ClusterK_Means)
## X-squared = 20.929, df = 16, p-value = 0.1813
addmargins(chi_square14$observed)
##                          
## clean$varčevanjeF          1   2   3   4   5 Sum
##   nikakor se ne stirnjam    2   5   5  12   8  32
##   ne strinjam              18   7  12  12  22  71
##   niti niti                 4   2   6   2   6  20
##   strinjam                  7   3   4   5   3  22
##   popolnoma strinjam        2   4   4   4   1  15
##   Sum                      33  21  31  35  40 160
addmargins(round(chi_square14$expected, 2))
##                          
## clean$varčevanjeF            1     2     3     4     5 Sum
##   nikakor se ne stirnjam   6.60  4.20  6.20  7.00  8.00  32
##   ne strinjam             14.64  9.32 13.76 15.53 17.75  71
##   niti niti                4.12  2.62  3.88  4.38  5.00  20
##   strinjam                 4.54  2.89  4.26  4.81  5.50  22
##   popolnoma strinjam       3.09  1.97  2.91  3.28  3.75  15
##   Sum                     32.99 21.00 31.01 35.00 40.00 160
round(chi_square14$res, 2) 
##                          
## clean$varčevanjeF            1     2     3     4     5
##   nikakor se ne stirnjam  -1.79  0.39 -0.48  1.89  0.00
##   ne strinjam              0.88 -0.76 -0.47 -0.90  1.01
##   niti niti               -0.06 -0.39  1.08 -1.14  0.45
##   strinjam                 1.16  0.07 -0.13  0.09 -1.07
##   popolnoma strinjam      -0.62  1.45  0.64  0.40 -1.42
addmargins(round(prop.table(chi_square14$observed), 3))
##                          
## clean$varčevanjeF            1     2     3     4     5   Sum
##   nikakor se ne stirnjam  0.013 0.031 0.031 0.075 0.050 0.200
##   ne strinjam             0.112 0.044 0.075 0.075 0.138 0.444
##   niti niti               0.025 0.013 0.038 0.013 0.038 0.127
##   strinjam                0.044 0.019 0.025 0.031 0.019 0.138
##   popolnoma strinjam      0.013 0.025 0.025 0.025 0.006 0.094
##   Sum                     0.207 0.132 0.194 0.219 0.251 1.003
addmargins(round(prop.table(chi_square14$observed, 1), 3), 2) 
##                          
## clean$varčevanjeF            1     2     3     4     5   Sum
##   nikakor se ne stirnjam  0.062 0.156 0.156 0.375 0.250 0.999
##   ne strinjam             0.254 0.099 0.169 0.169 0.310 1.001
##   niti niti               0.200 0.100 0.300 0.100 0.300 1.000
##   strinjam                0.318 0.136 0.182 0.227 0.136 0.999
##   popolnoma strinjam      0.133 0.267 0.267 0.267 0.067 1.001
addmargins(round(prop.table(chi_square14$observed, 2), 3), 1) 
##                          
## clean$varčevanjeF            1     2     3     4     5
##   nikakor se ne stirnjam  0.061 0.238 0.161 0.343 0.200
##   ne strinjam             0.545 0.333 0.387 0.343 0.550
##   niti niti               0.121 0.095 0.194 0.057 0.150
##   strinjam                0.212 0.143 0.129 0.143 0.075
##   popolnoma strinjam      0.061 0.190 0.129 0.114 0.025
##   Sum                     1.000 0.999 1.000 1.000 1.000

enostavnost pomembnost

clean$enostavnostF <- factor(additional$Q10a,
                      levels = c(1, 2, 3, 4, 5),
                      labels = c("sploh ni pomembno ", "ni pomembno", "niti niti", "pomembno", "zelo pomembno"))

chi_square15 <- chisq.test(clean$enostavnostF, as.factor(clean1$ClusterK_Means))
## Warning in chisq.test(clean$enostavnostF,
## as.factor(clean1$ClusterK_Means)): Chi-squared approximation may be
## incorrect
chi_square15
## 
##  Pearson's Chi-squared test
## 
## data:  clean$enostavnostF and as.factor(clean1$ClusterK_Means)
## X-squared = 35.845, df = 16, p-value = 0.003041
addmargins(chi_square15$observed)
##                     
## clean$enostavnostF     1   2   3   4   5 Sum
##   sploh ni pomembno    0   0   0   1   0   1
##   ni pomembno          0   2   1   0   2   5
##   niti niti            5   1   7   1   3  17
##   pomembno            19   9  19  13  28  88
##   zelo pomembno        9   9   4  20   7  49
##   Sum                 33  21  31  35  40 160
addmargins(round(chi_square15$expected, 2))
##                     
## clean$enostavnostF       1     2     3     4     5 Sum
##   sploh ni pomembno   0.21  0.13  0.19  0.22  0.25   1
##   ni pomembno         1.03  0.66  0.97  1.09  1.25   5
##   niti niti           3.51  2.23  3.29  3.72  4.25  17
##   pomembno           18.15 11.55 17.05 19.25 22.00  88
##   zelo pomembno      10.11  6.43  9.49 10.72 12.25  49
##   Sum                33.01 21.00 30.99 35.00 40.00 160
round(chi_square15$res, 2) 
##                     
## clean$enostavnostF       1     2     3     4     5
##   sploh ni pomembno  -0.45 -0.36 -0.44  1.67 -0.50
##   ni pomembno        -1.02  1.66  0.03 -1.05  0.67
##   niti niti           0.80 -0.82  2.04 -1.41 -0.61
##   pomembno            0.20 -0.75  0.47 -1.42  1.28
##   zelo pomembno      -0.35  1.01 -1.78  2.83 -1.50
addmargins(round(prop.table(chi_square15$observed), 3))
##                     
## clean$enostavnostF       1     2     3     4     5   Sum
##   sploh ni pomembno  0.000 0.000 0.000 0.006 0.000 0.006
##   ni pomembno        0.000 0.013 0.006 0.000 0.013 0.032
##   niti niti          0.031 0.006 0.044 0.006 0.019 0.106
##   pomembno           0.119 0.056 0.119 0.081 0.175 0.550
##   zelo pomembno      0.056 0.056 0.025 0.125 0.044 0.306
##   Sum                0.206 0.131 0.194 0.218 0.251 1.000
addmargins(round(prop.table(chi_square15$observed, 1), 3), 2) 
##                     
## clean$enostavnostF       1     2     3     4     5   Sum
##   sploh ni pomembno  0.000 0.000 0.000 1.000 0.000 1.000
##   ni pomembno        0.000 0.400 0.200 0.000 0.400 1.000
##   niti niti          0.294 0.059 0.412 0.059 0.176 1.000
##   pomembno           0.216 0.102 0.216 0.148 0.318 1.000
##   zelo pomembno      0.184 0.184 0.082 0.408 0.143 1.001
addmargins(round(prop.table(chi_square15$observed, 2), 3), 1) 
##                     
## clean$enostavnostF       1     2     3     4     5
##   sploh ni pomembno  0.000 0.000 0.000 0.029 0.000
##   ni pomembno        0.000 0.095 0.032 0.000 0.050
##   niti niti          0.152 0.048 0.226 0.029 0.075
##   pomembno           0.576 0.429 0.613 0.371 0.700
##   zelo pomembno      0.273 0.429 0.129 0.571 0.175
##   Sum                1.001 1.001 1.000 1.000 1.000