H0 = Pričakovana življenska doba je enaka v letih 2019 in 2020 H1 = Pričakovana življenska doba je nižja v letu 2020
podatki <- read.table("/cloud/project/Nal1Pod.csv", sep=";", dec=",", header=TRUE, col.names = c("ImeDrzave", "PZD2019", "PZD2020"))
library(tidyr)
podatki <- drop_na(podatki)
head(podatki)
## ImeDrzave PZD2019 PZD2020
## 1 Austria 81.89512 81.19268
## 2 Belarus 74.22683 72.45722
## 3 Botswana 65.46400 65.64700
## 4 Chad 53.25900 52.77700
## 5 Bermuda 81.03300 81.13600
## 6 Bahamas The 71.20500 72.67700
podatki$Diferenca <- podatki$PZD2019 - podatki$PZD2020
library(ggplot2)
ggplot(podatki, aes(x=Diferenca))+
geom_histogram(binwidth = 1, color="black")+
xlab("Diference")+
ylab("Frekvenca")
shapiro.test(podatki$Diferenca)
##
## Shapiro-Wilk normality test
##
## data: podatki$Diferenca
## W = 0.91986, p-value = 0.003303
library(psych)
##
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
describe(podatki[, -1])
## vars n mean sd median trimmed mad min max range skew
## PZD2019 1 47 73.89 7.54 74.23 74.43 10.09 53.26 84.16 30.90 -0.54
## PZD2020 2 47 73.36 7.48 73.92 73.88 9.53 52.78 84.47 31.69 -0.51
## Diferenca 3 47 0.52 0.99 0.35 0.44 0.72 -1.47 4.07 5.54 1.10
## kurtosis se
## PZD2019 -0.43 1.10
## PZD2020 -0.39 1.09
## Diferenca 2.45 0.14
t.test(podatki$PZD2019, podatki$PZD2020,
paired="TRUE",
alternative = "greater")
##
## Paired t-test
##
## data: podatki$PZD2019 and podatki$PZD2020
## t = 3.6208, df = 46, p-value = 0.0003647
## alternative hypothesis: true mean difference is greater than 0
## 95 percent confidence interval:
## 0.2798142 Inf
## sample estimates:
## mean difference
## 0.5216731
library(effectsize)
##
## Attaching package: 'effectsize'
## The following object is masked from 'package:psych':
##
## phi
cohens_d(podatki$Diferenca)
## Cohen's d | 95% CI
## ------------------------
## 0.53 | [0.22, 0.83]
interpret_cohens_d(0.53, rules = "sawilowsky2009")
## [1] "medium"
## (Rules: sawilowsky2009)
podatki <- read.table("/cloud/project/Nal1Pod.csv", sep=";", dec=",", header=TRUE, col.names = c("ImeDrzave", "PZD2019", "PZD2020"))
library(tidyr)
podatki <- drop_na(podatki)
head(podatki)
## ImeDrzave PZD2019 PZD2020
## 1 Austria 81.89512 81.19268
## 2 Belarus 74.22683 72.45722
## 3 Botswana 65.46400 65.64700
## 4 Chad 53.25900 52.77700
## 5 Bermuda 81.03300 81.13600
## 6 Bahamas The 71.20500 72.67700
podatki$Diferenca <- podatki$PZD2019 - podatki$PZD2020
library(ggplot2)
ggplot(podatki, aes(x=Diferenca))+
geom_histogram(binwidth = 1, color="black")+
xlab("Diference")+
ylab("Frekvenca")
shapiro.test(podatki$Diferenca)
##
## Shapiro-Wilk normality test
##
## data: podatki$Diferenca
## W = 0.91986, p-value = 0.003303
library(psych)
describe(podatki[, -1])
## vars n mean sd median trimmed mad min max range skew
## PZD2019 1 47 73.89 7.54 74.23 74.43 10.09 53.26 84.16 30.90 -0.54
## PZD2020 2 47 73.36 7.48 73.92 73.88 9.53 52.78 84.47 31.69 -0.51
## Diferenca 3 47 0.52 0.99 0.35 0.44 0.72 -1.47 4.07 5.54 1.10
## kurtosis se
## PZD2019 -0.43 1.10
## PZD2020 -0.39 1.09
## Diferenca 2.45 0.14
Z argumentom alternative=“greater”, povem programu da mora biti razlika med PZD2019-PZD2020 večja od 0, da sprejmem H1, saj poskušam dokazati, da se je pričakovana življenska doba iz leta 2019 na leto 2020 zmanjšala, torej mora biti dobljena razlika večja od 0.
wilcox.test(podatki$PZD2019, podatki$PZD2020,
paired=TRUE,
correct=FALSE,
exact=FALSE,
alternative="greater")
##
## Wilcoxon signed rank test
##
## data: podatki$PZD2019 and podatki$PZD2020
## V = 889.5, p-value = 0.000286
## alternative hypothesis: true location shift is greater than 0
library(effectsize)
effectsize(wilcox.test(podatki$PZD2019, podatki$PZD2020,
paired=TRUE,
correct=FALSE,
exact=FALSE,
alternative="greater"))
## r (rank biserial) | 95% CI
## --------------------------------
## 0.58 | [0.36, 1.00]
##
## - One-sided CIs: upper bound fixed at [1.00].
Efekt učinka je zelo velik, torej se je zgodila zelo velika sprememba.