library(graphics)
library(ggplot2)
Warning: package 'ggplot2' was built under R version 4.2.2
  1. A researcher conducts a study to evaluate whether the distribution of the length of time it takes migraine patients to respond to a 100 mg. dose of an intravenously administered drug is normal, with a mean response time of 90 seconds and a standard deviation of 35 seconds (i.e., μ = 90 and σ = 35). The amount of time (in seconds) that elapses between the administration of the drug and cessation of a headache for 30 migraine patients is recorded below. The 30 scores are arranged ordinally (i.e., from fastest response time to slowest response time).
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  

Null Hypothesis : The data comes from the specified distribution.

Alternative Hypothesis: At least one value does not match the specifies distribution.

mean(Kolmogorov$Scores)
[1] 90.06667
sd(Kolmogorov$Scores)
[1] 34.79292

Do the data conform to a normal distribution with the specified parameters?

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.