#install.packages("naniar")
#install.packages("factoextra")
library(readxl)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(naniar)
library(pastecs)
##
## Attaching package: 'pastecs'
## The following objects are masked from 'package:dplyr':
##
## first, last
library(tidyr)
##
## Attaching package: 'tidyr'
## The following object is masked from 'package:pastecs':
##
## extract
library(Hmisc)
##
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:dplyr':
##
## src, summarize
## The following objects are masked from 'package:base':
##
## format.pval, units
library(factoextra)
## Loading required package: ggplot2
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
library(dplyr)
library(factoextra)
library(ggplot2)
library(tidyr)
#Importing data
mydata <- read_xlsx("./NLB_anketa_pociscena.xlsx")
## New names:
## • `` -> `...13`
## • `` -> `...31`
## • `` -> `...38`
## • `` -> `...45`
## • `` -> `...52`
## • `` -> `...58`
## • `` -> `...64`
## • `` -> `...75`
## • `` -> `...91`
## • `` -> `...106`
mydata <- as.data.frame(mydata)
#Adding a column "ID"
mydata <- mydata %>%
mutate(ID = 1:nrow(.)) %>%
select(ID, everything())
#Removing row with questions text
mydata <- mydata[-1,]
#Deleting the likert scale averages columns
columns_to_delete <- c("...13","...31","...38","...45","...52","...58","...64","...75","...91","...106")
mydata <- mydata[, !(names(mydata) %in% columns_to_delete)]
#Removing all aged below 16 and above 27
mydata <- mydata[mydata$Q1 >= 16 & mydata$Q1 <= 27, ]
#Creating a new data frame with only relevant questions
Hypo <- mydata %>%
select(ID, Q4a, Q4b, Q8a, Q8c, Q8h, Q31_2d)
#Turning all columns into numeric
for (col in names(Hypo)) {
Hypo[[col]] <- as.numeric(as.character(Hypo[[col]]))}
#Replacing missing values with NA
Hypo <- Hypo %>%
replace_with_na_all(condition = ~.x %in% c(-1, -2))
#Replacing NA values with the column average
Hypo <- Hypo %>%
mutate_all(~ifelse(is.na(.x), mean(.x, na.rm = TRUE), .x))
head(Hypo)
## # A tibble: 6 × 7
## ID Q4a Q4b Q8a Q8c Q8h Q31_2d
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 2 5 3 5 5 5 3
## 2 3 4 2 5 5 4 4
## 3 4 5 5 5 5 5 4
## 4 5 4 5 4 5 5 4
## 5 6 5 4 5 5 5 2
## 6 7 4.57 3.47 5 5 5 4
#Frequency of answers
table(Hypo$Q4a)
##
## 1 3 4 4.57364341085271
## 2 6 35 54
## 5
## 86
#Calculating the number of people that are prepared to switch
86+54+35
## [1] 175
#Testing assumptions
175*0.9 > 5
## [1] TRUE
175*(1-0.9) > 5
## [1] TRUE
Both assumptions for proportion test are met.
prop.test(x = 175,
n = 183,
p = 0.9,
correct = F,
alternative = "greater")
##
## 1-sample proportions test without continuity correction
##
## data: 175 out of 183, null probability 0.9
## X-squared = 6.4414, df = 1, p-value = 0.005575
## alternative hypothesis: true p is greater than 0.9
## 95 percent confidence interval:
## 0.9240779 1.0000000
## sample estimates:
## p
## 0.9562842
Explanation of results:
We can reject the null hypothesis (p = 0.006) and conclude that more than 90% of young people are prepared to switch banks if that bank offers a good mobile payment service.
#Frequency of answers
table(Hypo$Q4b)
##
## 1 2 3 3.47244094488189
## 6 12 46 56
## 4 5
## 42 21
#Calculating the number of people that agree with the statement
56+42+21
## [1] 119
#Testing assumptions
119*0.55 > 5
## [1] TRUE
119*(1-0.55) > 5
## [1] TRUE
Both assumptions for proportion test are met.
prop.test(x = 119,
n = 183,
p = 0.55,
correct = F,
alternative = "greater")
##
## 1-sample proportions test without continuity correction
##
## data: 119 out of 183, null probability 0.55
## X-squared = 7.4344, df = 1, p-value = 0.003199
## alternative hypothesis: true p is greater than 0.55
## 95 percent confidence interval:
## 0.5904814 1.0000000
## sample estimates:
## p
## 0.6502732
Explanation of results:
We can reject the null hypothesis (p = 0.004) and conclude that more than 55% of young people are prepared to switch banks if that bank offers a referral system.
#Frequency of answers
table(Hypo$Q8a)
##
## 2 3 4 5
## 3 7 62 111
table(Hypo$Q8c)
##
## 2 3 4 5
## 1 3 20 159
table(Hypo$Q8h)
##
## 3 4 5
## 11 70 102
#Calculating the number of people that agree with the statement
62+111+20+159+70+102
## [1] 524
#Calculating the number of people answering all 3 questions
183*3
## [1] 549
#Testing assumptions
524*0.9 > 5
## [1] TRUE
524*(1-0.9) > 5
## [1] TRUE
Both assumptions for proportion test are met.
prop.test(x = 524,
n = 549,
p = 0.9,
correct = F,
alternative = "greater")
##
## 1-sample proportions test without continuity correction
##
## data: 524 out of 549, null probability 0.9
## X-squared = 18.094, df = 1, p-value = 1.051e-05
## alternative hypothesis: true p is greater than 0.9
## 95 percent confidence interval:
## 0.9374654 1.0000000
## sample estimates:
## p
## 0.9544627
Explanation of results:
We can reject the null hypothesis (p < 0.001) and conclude that more than 90% of young people expect their banks to be reliable and trustworthy.
#Frequency of answers
table(Hypo$Q31_2d)
##
## 1 2 3 4 5
## 2 16 43 103 19
#Calculating the number of people that are prepared to switch
103+19
## [1] 122
#Testing assumptions
122*0.6 > 5
## [1] TRUE
122*(1-0.6) > 5
## [1] TRUE
Both assumptions for proportion test are met.
prop.test(x = 122,
n = 183,
p = 0.6,
correct = F,
alternative = "greater")
##
## 1-sample proportions test without continuity correction
##
## data: 122 out of 183, null probability 0.6
## X-squared = 3.3889, df = 1, p-value = 0.03282
## alternative hypothesis: true p is greater than 0.6
## 95 percent confidence interval:
## 0.6072872 1.0000000
## sample estimates:
## p
## 0.6666667
Explanation of results:
We can reject the null hypothesis (p = 0.033) and conclude that more than 60% of young people believe that advertisements have a positive effect on the level of awareness of the brand.