Untitled
Anonymous
plain_text
03/04/2026 5:51 AM
7.3 KB
12
Indexable
---
title: "exp 6"
author: "Dharshan"
date: "2026-03-04"
output: word_document
---
F TEST
#problem 1
```{r}
s1_squared <- 100
s2_squared <- 80
n1 <- 25
n2 <- 30
alpha <- 0.05
F_stat <- s1_squared / s2_squared
df1 <- n1 - 1
df2 <- n2 - 1
F_critical <- qf(1 - alpha / 2, df1, df2)
F_stat
F_critical
if(F_stat > F_critical | F_stat < 1 / F_critical) {
print("Reject the null hypothesis")
} else {
print("Fail to reject the null hypothesis")
}
```
#problem 2
```{r}
s1_squared <- 120
s2_squared <- 100
n1 <- 40
n2 <- 35
alpha <- 0.01
F_stat <- s1_squared / s2_squared
df1 <- n1 - 1
df2 <- n2 - 1
F_critical <- qf(1 - alpha, df1, df2)
F_stat
F_critical
if(F_stat > F_critical) {
print("Reject the null hypothesis")
} else {
print("Fail to reject the null hypothesis")
}
```
#problem 3
```{r}
s1_squared <- 25
s2_squared <- 20
n1 <- 15
n2 <- 18
alpha <- 0.05
F_stat <- s1_squared / s2_squared
df1 <- n1 - 1
df2 <- n2 - 1
F_critical <- qf(1 - alpha / 2, df1, df2)
F_stat
F_critical
if(F_stat > F_critical | F_stat < 1 / F_critical) {
print("Reject the null hypothesis")
} else {
print("Fail to reject the null hypothesis")
}
```
#problem 4
```{r}
s1_squared <- 50
s2_squared <- 40
n1 <- 25
n2 <- 30
alpha <- 0.05
F_stat <- s1_squared / s2_squared
df1 <- n1 - 1
df2 <- n2 - 1
F_critical <- qf(1 - alpha / 2, df1, df2)
F_stat
F_critical
# Decision
if(F_stat > F_critical | F_stat < 1 / F_critical) {
print("Reject the null hypothesis")
} else {
print("Fail to reject the null hypothesis")
}
```
#problem 5
```{r}
s1_squared <- 500
s2_squared <- 450
n1 <- 100
n2 <- 120
alpha <- 0.05
F_stat <- s1_squared / s2_squared
df1 <- n1 - 1
df2 <- n2 - 1
F_critical <- qf(1 - alpha, df1, df2)
F_stat
F_critical
if(F_stat > F_critical) {
print("Reject the null hypothesis")
} else {
print("Fail to reject the null hypothesis")
}
```
#problem 6
```{r}
s1_squared <- 0.25
s2_squared <- 0.20
n1 <- 50
n2 <- 60
alpha <- 0.05
F_stat <- s1_squared / s2_squared
df1 <- n1 - 1
df2 <- n2 - 1
F_critical <- qf(alpha, df1, df2)
F_stat
F_critical
if(F_stat < F_critical) {
print("Reject the null hypothesis")
} else {
print("Fail to reject the null hypothesis")
}
```
#problem 7
```{r}
s1_squared <- 300
s2_squared <- 250
n1 <- 22
n2 <- 30
alpha <- 0.01
F_stat <- s1_squared / s2_squared
df1 <- n1 - 1
df2 <- n2 - 1
F_critical <- qf(1 - alpha / 2, df1, df2)
F_stat
F_critical
if(F_stat > F_critical | F_stat < 1 / F_critical) {
print("Reject the null hypothesis")
} else {
print("Fail to reject the null hypothesis")
}
```
CHI SQUARE TEST
#problem 1
```{r}
observed <- c(8, 12, 10, 11, 9, 10)
expected <- rep(10, 6) # 60 rolls, 6 outcomes, so expected is 60 / 6 = 10
chisq_test <- chisq.test(observed, p = rep(1/6, 6), rescale.p = TRUE)
chisq_test
if(chisq_test$p.value < 0.05) {
print("Reject the null hypothesis: The die is not fair.")
} else {
print("Fail to reject the null hypothesis: The die is fair.")
}
```
#problem 2
```{r}
observed <- c(35, 25, 20, 20)
expected <- rep(25, 4) # 100 people, 4 colors, so expected is 100 / 4 = 25
chisq_test <- chisq.test(observed, p = rep(1/4, 4), rescale.p = TRUE)
chisq_test
if(chisq_test$p.value < 0.05) {
print("Reject the null hypothesis: The preferences are not evenly
distributed.")
} else {
print("Fail to reject the null hypothesis: The preferences are evenly
distributed.")
}
```
#problem 3
```{r}
data <- matrix(c(30, 70, 20, 80), nrow = 2, byrow = TRUE)
chisq_test <- chisq.test(data)
chisq_test
if(chisq_test$p.value < 0.05) {
print("Reject the null hypothesis: There is an association between gender
and smoking status.")
} else {
print("Fail to reject the null hypothesis: There is no association
between gender and smoking status.")
}
```
#problem 4
```{r}
data <- matrix(c(50, 60, 40, 30, 40, 50, 20, 30, 70), nrow = 3, byrow =
TRUE)
chisq_test <- chisq.test(data)
chisq_test
if(chisq_test$p.value < 0.05) {
print("Reject the null hypothesis: There is an association between
education level and political affiliation.")
} else {
print("Fail to reject the null hypothesis: There is no association
between education level and political affiliation.")
}
```
#problem 5
```{r}
data <- matrix(c(10, 20, 30, 15, 25, 40, 20, 30, 50, 25, 35, 45), nrow = 4,
byrow = TRUE)
chisq_test <- chisq.test(data)
chisq_test
if(chisq_test$p.value < 0.05) {
print("Reject the null hypothesis: There is an association between region
and product preference.")
} else {
print("Fail to reject the null hypothesis: There is no association
between region and product preference.")
}
```
#problem 6
```{r}
observed <- c(40, 35, 25)
total <- sum(observed)
expected_proportions <- c(1, 2, 3) / sum(c(1, 2, 3))
expected <- expected_proportions * total
chisq_test <- chisq.test(observed, p = expected_proportions, rescale.p =
TRUE)
chisq_test
if(chisq_test$p.value < 0.05) {
print("Reject the null hypothesis: The distribution does not match the
expected proportions.")
} else {
print("Fail to reject the null hypothesis: The distribution matches the
expected proportions.")
}
```
#problem 7
```{r}
data <- matrix(c(50, 40, 60, 30, 60, 40, 20, 30, 50), nrow = 3, byrow =
TRUE)
chisq_test <- chisq.test(data)
chisq_test
if(chisq_test$p.value < 0.05) {
print("Reject the null hypothesis: There is an association between age
group and product preference.")
} else {
print("Fail to reject the null hypothesis: There is no association
between age group and product preference.")
}
```
Editor is loading...
Leave a Comment