library(graphics)
library(ggplot2)
Warning: package 'ggplot2' was built under R version 4.2.2
library(readxl)
Kolmogorov <- read_excel("D:/MARV BS MATH/4th year, 2nd sem/Nonparametric Statistics/Final Exam/Kolmogorov.xlsx")
Kolmogorov
# A tibble: 30 × 2
Patient Scores
<dbl> <dbl>
1 1 21
2 2 32
3 3 38
4 4 40
5 5 48
6 6 55
7 7 63
8 8 66
9 9 70
10 10 75
# … with 20 more rows
head(Kolmogorov)
# A tibble: 6 × 2
Patient Scores
<dbl> <dbl>
1 1 21
2 2 32
3 3 38
4 4 40
5 5 48
6 6 55
str(Kolmogorov)
tibble [30 × 2] (S3: tbl_df/tbl/data.frame)
$ Patient: num [1:30] 1 2 3 4 5 6 7 8 9 10 ...
$ Scores : num [1:30] 21 32 38 40 48 55 63 66 70 75 ...
summary(Kolmogorov)
Patient Scores
Min. : 1.00 Min. : 21.00
1st Qu.: 8.25 1st Qu.: 67.00
Median :15.50 Median : 91.50
Mean :15.50 Mean : 90.07
3rd Qu.:22.75 3rd Qu.:113.25
Max. :30.00 Max. :155.00
mean(Kolmogorov$Scores)
[1] 90.06667
sd(Kolmogorov$Scores)
[1] 34.79292
ks.test(Kolmogorov,"pnorm")
Warning in ks.test.default(Kolmogorov, "pnorm"): ties should not be present for
the Kolmogorov-Smirnov test
Asymptotic one-sample Kolmogorov-Smirnov test
data: Kolmogorov
D = 0.96532, p-value < 2.2e-16
alternative hypothesis: two-sided
Since the p-value 2.2e-16 is less than D = 0.96532, then we reject the null hypothesis and conclude that at least one value does not match the specifies distribution.
ggplot(Kolmogorov, aes(Scores)) +
geom_density()
ggplot(data=Kolmogorov) +
geom_histogram( aes(Scores, ..density..) ) +
geom_density( aes(Scores, ..density..) ) +
geom_rug( aes(Scores) )
Warning: The dot-dot notation (`..density..`) was deprecated in ggplot2 3.4.0.
ℹ Please use `after_stat(density)` instead.
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
By the graph shown above, the data is not normality distributed.