R Console
R Console
>
> # Two Sample T-Test
> group1 <- c(12, 15, 11, 16, 14, 14, 16)
> group2 <- c(8, 10, 14, 10, 13)
> t.test(group1, group2)
>
> # Paired T-Test
> before <- c(110, 120, 123, 132, 125)
> after <- c(120, 118, 125, 136, 121)
> t.test(before, after, paired = TRUE)
Paired t-test
>
> # 4704 Kedar Bhoir
>
> # Z-Test
> library(BSDA)
Error in library(BSDA) : there is no package called ‘BSDA’
> z.test(x = 10.2, sigma.x = 2.25, n = 400, mu = 10)
Error in z.test(x = 10.2, sigma.x = 2.25, n = 400, mu = 10) :
could not find function "z.test"
>
> # Two Sample Z-Test
> z.test(x = 67.5, y = 68, sigma.x = 2.5, sigma.y = 2.5, n.x = 1000, n.y = 2000)
Error in z.test(x = 67.5, y = 68, sigma.x = 2.5, sigma.y = 2.5, n.x = 1000, :
could not find function "z.test"
>
> # 4704 Kedar Bhoir
>
> # Chi-Square Goodness of Fit Test
> observed <- c(16, 20, 25, 14, 29, 28)
> expected <- rep(132/6, 6)
> chisq.test(observed, p = expected/sum(expected))
data: observed
X-squared = 9, df = 5, p-value = 0.1091
>
> # Chi-Square Test for Independence
> data_matrix <- matrix(c(70, 50, 80, 20, 35, 45), nrow = 3, byrow = TRUE)
> chisq.test(data_matrix)
data: data_matrix
X-squared = 25.646, df = 2, p-value = 2.698e-06
>
> # 4704 Kedar Bhoir
>
> # Mann-Whitney U Test
> x <- c(5.6, 4.6, 6.8, 4.9, 6.1, 5.3, 4.5, 5.8, 5.4)
> y <- c(7.2, 8.1, 5.1, 7.3, 6.9, 7.8, 5.9, 6.7, 6.5, 7.1)
> wilcox.test(x, y)
data: x and y
W = 10, p-value = 0.002988
alternative hypothesis: true location shift is not equal to 0
>
> # Sign Test
> library(BSDA)
Error in library(BSDA) : there is no package called ‘BSDA’
> sign_test_data <- c(46, 49, 47, 55, 59, 63, 53, 56, 67, 54, 48, 69)
> SIGN.test(sign_test_data, md = 50)
Error in SIGN.test(sign_test_data, md = 50) :
could not find function "SIGN.test"
>
> # 4704 Kedar Bhoir
>
> # Kruskal-Wallis Test
> group_A <- c(1, 5, 8, 17, 16)
> group_B <- c(2, 1, 6, 5, 7, 4)
> group_C <- c(1, 1, 3, 7, 9)
> group_D <- c(2, 1, 5, 2, 9, 7)
>
> data_list <- list(A = group_A, B = group_B, C = group_C, D = group_D)
> kruskal.test(data_list)
data: data_list
Kruskal-Wallis chi-squared = 2.1699, df = 3, p-value = 0.5379
>
> # 4704 Kedar Bhoir
>
> # One-Way ANOVA
> drug_A <- c(4, 5, 4, 3, 2, 4, 3, 4, 4)
> drug_B <- c(6, 8, 4, 5, 4, 6, 5, 8, 6)
> drug_C <- c(6, 7, 6, 6, 7, 5, 6, 5, 5)
>
> data <- data.frame(
+ Response = c(drug_A, drug_B, drug_C),
+ Group = rep(c("A", "B", "C"), each = 9)
+ )
>
> anova_result <- aov(Response ~ Group, data = data)
> summary(anova_result)
Df Sum Sq Mean Sq F value Pr(>F)
Group 2 28.22 14.111 11.91 0.000256 ***
Residuals 24 28.44 1.185
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> # 4704 Kedar Bhoir
>
> # Two-Way ANOVA
> sales_data <- data.frame(
+ Salesman = rep(c("A", "B", "C", "D"), times = 3),
+ Season = rep(c("Summer", "Winter", "Monsoon"), each = 4),
+ Sales = c(36, 32, 21, 30, 24, 25, 20, 22, 20, 18, 19, 15)
+ )
>
> two_way_anova <- aov(Sales ~ Salesman + Season, data = sales_data)
> summary(two_way_anova)
Df Sum Sq Mean Sq F value Pr(>F)
Salesman 3 77.67 25.89 2.162 0.19358
Season 2 279.50 139.75 11.673 0.00855 **
Residuals 6 71.83 11.97
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
>