Read file CSV

exam <- read.csv("C:/Users/dailo/Downloads/R-master/R-master/ExampleData.csv", header = T)

Sample

x <- rnorm(1000, mean = 10, sd = 3)
hist(x, col = 'blue')

plot(density(x), col = 'red')

qqnorm(x)
qqline(x, col =2)

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.0     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.1     ✔ tibble    3.2.0
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.1     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the ]8;;http://conflicted.r-lib.org/conflicted package]8;; to force all conflicts to become errors
new_pcs <- na.omit(exam$pcs)
print(mean(new_pcs))
## [1] 48.07548
print(median(new_pcs))
## [1] 48.88762
hist(new_pcs, col = 3)

plot(density(new_pcs), col = 4)

qqnorm(new_pcs, col = 'gray')
qqline(new_pcs, col = 2)

Về cách sử dụng giá trị p để đưa ra quyết định, một cách thông thường là sử dụng mức ý nghĩa alpha = 0.05. Nếu giá trị p thu được từ kiểm định là nhỏ hơn alpha (p < 0.05), chúng ta có thể bác bỏ giả thiết H0 về sự tuân theo phân phối chuẩn. Tuy nhiên, nếu giá trị p lớn hơn alpha (p > 0.05), thì chúng ta không thể bác bỏ giả thiết H0.

library(nortest)
shapiro.test(new_pcs)
## 
##  Shapiro-Wilk normality test
## 
## data:  new_pcs
## W = 0.98366, p-value = 4.052e-05
lillie.test(new_pcs)
## 
##  Lilliefors (Kolmogorov-Smirnov) normality test
## 
## data:  new_pcs
## D = 0.062376, p-value = 0.000167
ad.test(new_pcs)
## 
##  Anderson-Darling normality test
## 
## data:  new_pcs
## A = 2.6422, p-value = 1.14e-06