Non Parametric Homework-9
Non Parametric Homework-9
Madan Neupane
2022-10-27
## Success Failure
## Male 20 80
## female 50 400
oddsratio(gender)
## $data
## Success Failure Total
## Male 20 80 100
## female 50 400 450
## Total 70 480 550
##
## $measure
## NA
## odds ratio with 95% C.I. estimate lower upper
## Male 1.000000 NA NA
## female 2.004587 1.109171 3.514536
##
## $p.value
## NA
## two-sided midp.exact fisher.exact chi.square
## Male NA NA NA
## female 0.02207671 0.0202162 0.01584399
##
## $correction
## [1] FALSE
##
## attr(,"method")
## [1] "median-unbiased estimate & mid-p exact CI"
At α =0.05
Since pvalue=0.0158 < α =0.05 . Then reject null hypothesis.
Therefore there is enough evidence to conclude that the odds ratio test of male and female
is statistically significant.
## , , Fuel = Regular
##
## Vehicles
## Timesperweek Car Truck
## >1 209 363
## <=1 384 157
##
## , , Fuel = Unleashed
##
## Vehicles
## Timesperweek Car Truck
## >1 116 389
## <=1 321 229
##
## , , Fuel = Super Unleashed
##
## Vehicles
## Timesperweek Car Truck
## >1 121 284
## <=1 329 173
##
## , , Fuel = Diesel
##
## Vehicles
## Timesperweek Car Truck
## >1 336 388
## <=1 141 184
mantelhaen.test(gas)
##
## Mantel-Haenszel chi-squared test with continuity correction
##
## data: gas
## Mantel-Haenszel X-squared = 279.33, df = 1, p-value < 2.2e-16
## alternative hypothesis: true common odds ratio is not equal to 1
## 95 percent confidence interval:
## 0.3013742 0.3897974
## sample estimates:
## common odds ratio
## 0.3427461
At α =0.05
Since X-squared(TS)=279.33 < X-squared(table)=3.841459. Then reject null hypothesis.
Therefore there is enough evidence to conclude that the common oddsratio for rRegular
fuel is higher.
Answer no .(3.75)
H 0 : Pm a l e =Pf em a l e v s H 0 : Pm a l e < P f e ma l e
Attendence <- matrix(c(3,2,10,15),
nrow = 2, ncol = 2, byrow = TRUE,
dimnames = list(c("Male", "female"),
c("Less than 5 Absenses", "More than 5 Absenses")))
Attendence
##
## Pearson's Chi-squared test
##
## data: Attendence
## X-squared = 0.67873, df = 1, p-value = 0.41
qchisq(1-0.05,1)
## [1] 3.841459
At α =0.05
Since X-squared(TS)=0.67873 < X-squared(table)=3.841459. Then fails to reject null
hypothesis.
Therefore there is not enough evidence to conclude that the proportion of females failing
their course due to at least 5 absences is higher than males.
chisq.test(shop)
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: shop
## X-squared = 12.51, df = 1, p-value = 0.0004048
qchisq(1-0.05,1)
## [1] 3.841459
At α =0.05
Since X-squared(TS)=12.51 > X-squared(table)=3.841. Then reject null hypothesis.
Therefore there is enough evidence to conclude that the gender is unrelated to working out
against the alternative that gender and working out are dependent.
##Test Statistics
Chisquare <- sum((data$frequency-data$e_i)^2/data$e_i)
df <- nrow(data)
qchisq(0.95,df-1)
## [1] 21.02607
OR,
data1<- data.frame(c(0:8),c(24,16,16,18,15,9,6,5,11))
names(data1) <- c('borers','frequency')
n1 <- sum(data$frequency) #120
##Test Statistics
Chisquare1 <- sum((data1$frequency-data1$e_i1)^2/data1$e_i)
Chisquare1
## [1] 164.0966
df <- nrow(data1)
qchisq(0.95,df-1)
## [1] 15.50731
At α =0.05
Since X-squared(TS)=259.33 or 164.0966 > X-squared(table)=3.841. Then reject null
hypothesis.
Therefore there is not enough evidence to conclude that the data are from a random
variable Poisson distribution.