Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

S.

NAVEEN
18MIS0179

m
er as
Name: S.NAVEEN

co
eH w
REg.no: 18MIS0179

o.
rs e
ou urc
Facult : Easwarmoorthy
Questions:
o
aC s

1. The following table gives the number of fatal road accidents that occurred
vi y re

during the 7 days of a week. Write down the R programming code to test
whether the accidents are uniformly distributed over the week at 95 %
ed d

level of confidence.
ar stu
is

Ans:
Th

> alpha=0.05
> OF=c(8, 14, 16, 12, 11, 14, 9)
sh

> Tot=sum(OF)
> n=length(OF)
> EV=Tot/n
> EF=rep(EV,n)

This study source was downloaded by 100000827468763 from CourseHero.com on 11-25-2021 08:18:37 GMT -06:00

https://www.coursehero.com/file/49693599/EXP-6-Apdf/
S.NAVEEN
18MIS0179

> ChiTab=qchisq((1-alpha),(n-1))
> ChiTab
[1] 12.59159
> ChiCal=sum(((OF-EF)^2)/EF)
> ChiCal
[1] 4.166667
> if(abs(ChiCal)<abs(ChiTab)) {
+ message(sprintf("H0 is accepted and H1 is rejected"))
+ } else {
+ message(sprintf("H0 is rejected and H1 is accepted"))
+}
H0 is accepted and H1 is rejected

m
er as
>}

co
eH w
2. A total number of 3759 individuals were interviewed according to

o.
rs e
gender and decision in
ou urc
a public opinion survey on a political proposal with the results as in the
following table.
Write down the R programming code to test the hypothesis that there is
o
aC s

no association
vi y re

between gender and attitude 5 % level of significance


ed d
ar stu

Ans:
> alpha=0.05
is

> OF=matrix(c(1154, 475, 243, 1103, 442, 342),nrow=2,ncol=3)


Th

> Dim=dim(OF)
> m=Dim[1]
> n=Dim[2]
sh

> EF=matrix(nrow=m,ncol=n)
> for (i in 1:Dim[1])
+{
+ for (j in 1:Dim[2])
+{

This study source was downloaded by 100000827468763 from CourseHero.com on 11-25-2021 08:18:37 GMT -06:00

https://www.coursehero.com/file/49693599/EXP-6-Apdf/
S.NAVEEN
18MIS0179

+ EF[i,j]=round(sum(OF[i,])*sum(OF[,j])/sum(OF))
+}
+}
> ChiTab=qchisq((1-alpha),(m-1)*(n-1))
> message(sprintf("Tabulated Chi-Square Value = %0.4f",ChiTab))
Tabulated Chi-Square Value = 5.9915
> ChiCal=sum(((OF-EF)^2)/EF)
> message(sprintf("Calculated Chi-Square Value = %0.4f",ChiCal))
Calculated Chi-Square Value = 842.3324
> if ((abs(ChiCal)<abs(ChiTab))){
+ message(sprintf("H0 is accepted and H1 is rejected"))
+ message(sprintf("Attributes are independent"))

m
er as
+ } else {

co
+ message(sprintf("H0 is rejected and H1 is accepted"))

eH w
+ message(sprintf("Attributes are not independent"))

o.
+}
rs e
ou urc
H0 is rejected and H1 is accepted
Attributes are not independent
o
aC s

3. A random sample is selected from each of 3 makes of ropes (Type 1,


vi y re

Type 2 and Type 3) and their breaking strength (in certain units) are
measured with the results in the following table.
ed d
ar stu
is

Ans:
Th

> D1=c(70, 72, 75, 80, 83)


> D2=c(60, 65, 57, 84, 87, 73)
sh

> D3=c(100, 110, 108, 112, 113, 120, 107)


> Data=c(D1, D2, D3)
> Data
[1] 70 72 75 80 83 60 65 57 84 87 73 100 110 108 112 113 120 107

This study source was downloaded by 100000827468763 from CourseHero.com on 11-25-2021 08:18:37 GMT -06:00

https://www.coursehero.com/file/49693599/EXP-6-Apdf/
S.NAVEEN
18MIS0179

>
Type=c(rep("Type1",length(D1)),rep("Type2",length(D2)),rep("Type3",leng
th(D3)))
> Type
[1] "Type1" "Type1" "Type1" "Type1" "Type1" "Type2" "Type2" "Type2"
"Type2"
[10] "Type2" "Type2" "Type3" "Type3" "Type3" "Type3" "Type3" "Type3"
"Type3"
> ANOVA1=aov(Data~Type)
> summary(ANOVA1)
Df Sum Sq Mean Sq F value Pr(>F)
Type 2 5838 2919.2 38.89 1.16e-06 ***

m
er as
Residuals 15 1126 75.1

co
---

eH w
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

o.
>
rs e
ou urc
o
aC s
vi y re
ed d
ar stu
is
Th
sh

This study source was downloaded by 100000827468763 from CourseHero.com on 11-25-2021 08:18:37 GMT -06:00

https://www.coursehero.com/file/49693599/EXP-6-Apdf/
S.NAVEEN
18MIS0179

PROOF:

m
er as
co
eH w
o.
rs e
ou urc
o
aC s
vi y re
ed d
ar stu
is
Th
sh

This study source was downloaded by 100000827468763 from CourseHero.com on 11-25-2021 08:18:37 GMT -06:00

https://www.coursehero.com/file/49693599/EXP-6-Apdf/
Powered by TCPDF (www.tcpdf.org)

You might also like