One sample t - test using R

Data
one.sample.data = c(490, 503, 499, 492, 500, 501, 489, 478, 498, 508)

1. Description of the data
mean(one.sample.data)
sd(one.sample.data)

2. Normality assumption

2.1 Description of normality
library(moments)
skewness(one.sample.data)
kurtosis(one.sample.data)

2.2 Statistical test about symmetry and skew of the distribution
agostino.test(one.sample.data, alternative = "two.sided") # check symmetry of distribution
anscombe.test(one.sample.data, alternative = "two.sided") # check normality of kurtosis

2.3 Normality tests
2.3.1 Kolmogorov - Smirnov (Not appropriate since it computes parameters from the same data...)
ks.test(one.sample.data, "pnorm", mean(one.sample.data), sd(one.sample.data)) 

2.3.2 Shapiro - Wilk (better option)
shapiro.test(one.sample.data) # appropriate

3. One sample t - test
t.test(one.sample.data, mu = 500)

3. Non parametric one sample test
library(BSDA)
SIGN.test(one.sample.data, md = 500)  

The above example is contained in the paragraph 3.4 of the book "Στατιστική ανάλυση με τη γλώσσα R" (in Greek, ISBN: 978-960-93-9445-1) published in Thessaloniki, 2017.

Comments