Math Gamification

 

Materials for foreign and Russian-speaking students studying the Data Analysis course in English 
 

Файлы решений

R скрипты

Проверки нормальности

 

#1

shapiro.test(X) # Тест Шапиро  Pvalue<alfa=0.05 гипотезу о нормальности отвергаем

#2

library(ggpubr)
ggdensity(X,main = "Density plot of X", xlab = "X")
g
lot(X)gqqp

#3 

library(nortest)         # Библиотека для pearson.test и lillie.test
pearson.test(X$V1)       # Пирсон
lillie.test(X$V1)

#4 

library("sm")                       # Для sm.density
sm.density(X$V1, model = "Normal")  # Попадаем ли в синий коридор.. 

 

 

Clean the data \ Очистка данных

 

#MAC:
x <- as.numeric(read.delim(pipe("pbpaste"), header = F, sep = ","))
#PC:
x<- as.numeric(read.delim("clipboard", header = F, sep = ","))

#delete NAN and string values
y <- na.omit(x)

          

Presentations \ Презентации

Hypothesis Tests

1. Mean test (normal dist., known variance)

R: z.test() (from BSDA package)

Excel: Z.TEST(array, μ₀, σ) Data Analysis: One-sample z-test

2. Mean test (normal dist., unknown variance)

R: t.test(x, mu = μ₀)

Excel: T.TEST(array, μ₀, tails, type=1)  Data Analysis: One-sample t-test

3. Equality of two means (independent samples, known variances)

R: z.test(x, y, sigma.x=σ₁, sigma.y=σ₂)

Excel: Two-sample z-test

4. Equality of two means (independent samples, unknown but equal variances)

R: t.test(x, y, var.equal=TRUE)

Excel: T.TEST(array1, array2, tails, type=2)   Data Analysis: Student's t-test (equal variances)

5. Equality of two means (independent samples, unknown & unequal variances)

t.test(x, y, var.equal=FALSE)

Example: Test the null hypothesis H0: E(X)=E(Y) without the assumption of equality of variances at significance level α=0.02 against the alternative H1: E(X)>E(Y)

t.test(X,Y, alternative="greater", var.equal=FALSE, conf.level=0.98)

Excel: T.TEST(array1, array2, tails, type=3)  Data Analysis: Welch’s t-test (unequal variances)

6. Equality of means (paired data)

t.test(x, y, paired=TRUE)

Excel: T.TEST(array1, array2, tails, type=1)  Data Analysis: Paired t-test

7. Equality of variances (two samples)

var.test(x, y)

Example: Test the null hypothesis H0: Var(X)=Var(Y) at significance level α=0.05 against the alternative H1: Var(X)≠Var(Y).   var.test(x,y, alternative='two.sided' )

Excel: F.TEST(array1, array2)    Data Analysis: F-test (Fisher’s test)

8. Equality of proportions

prop.test(c(x_succ, y_succ), c(n₁, n₂))

Excel: Z-test for proportions

9. Significance of correlation

cor.test(x, y, method="pearson")

Example: Test the hypothesis for insignificance of correlation coefficient ρ (i.e. H0: ρ=0 against the alternative  H1: ρ≠0)  cor.test(x, y, alternative = "two.sided") 

Excel: PEARSON(array1, array2) + T.DIST for p-value  Data Analysis: Pearson correlation test