#Problem #1
scores = matrix(c(.156,.49,.221,.306,.245,.165,.196,.041,.181,0.0), ncol=2,byrow=TRUE)
colnames(scores) <- c("Global", "IHS")
rownames(scores) <-c("5", "4", "3", "2", "1")
scores <- as.table(scores)
addmargins(scores)
##     Global   IHS   Sum
## 5    0.156 0.490 0.646
## 4    0.221 0.306 0.527
## 3    0.245 0.165 0.410
## 2    0.196 0.041 0.237
## 1    0.181 0.000 0.181
## Sum  0.999 1.002 2.001
prop.table(scores)
##       Global        IHS
## 5 0.07796102 0.24487756
## 4 0.11044478 0.15292354
## 3 0.12243878 0.08245877
## 2 0.09795102 0.02048976
## 1 0.09045477 0.00000000
chisq.test(scores)
## Warning in chisq.test(scores): Chi-squared approximation may be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  scores
## X-squared = 0.48437, df = 4, p-value = 0.975
chisq.test(scores)$expected
## Warning in chisq.test(scores): Chi-squared approximation may be incorrect
##       Global        IHS
## 5 0.32251574 0.32348426
## 4 0.26310495 0.26389505
## 3 0.20469265 0.20530735
## 2 0.11832234 0.11867766
## 1 0.09036432 0.09063568
## Counts, cells independent, enough data (more than  five rows)
## IHS scores are significantly better than expected value
#Problem #1 GOF#
IHS=c(.49,.306,.165,.041,.00)
Global=c(.156,.221,.245,.196,.182)
colnames(scores) <- c("Global", "IHS")
rownames(scores) <-c("5", "4", "3", "2", "1")
chisq.test(IHS, p=Global)
## Warning in chisq.test(IHS, p = Global): Chi-squared approximation may be
## incorrect
## 
##  Chi-squared test for given probabilities
## 
## data:  IHS
## X-squared = 1.0763, df = 4, p-value = 0.898
scores <- as.table(scores)
addmargins(scores)
##     Global   IHS   Sum
## 5    0.156 0.490 0.646
## 4    0.221 0.306 0.527
## 3    0.245 0.165 0.410
## 2    0.196 0.041 0.237
## 1    0.181 0.000 0.181
## Sum  0.999 1.002 2.001
prop.table(scores)
##       Global        IHS
## 5 0.07796102 0.24487756
## 4 0.11044478 0.15292354
## 3 0.12243878 0.08245877
## 2 0.09795102 0.02048976
## 1 0.09045477 0.00000000
chisq.test(scores)
## Warning in chisq.test(scores): Chi-squared approximation may be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  scores
## X-squared = 0.48437, df = 4, p-value = 0.975
chisq.test(scores)$expected
## Warning in chisq.test(scores): Chi-squared approximation may be incorrect
##       Global        IHS
## 5 0.32251574 0.32348426
## 4 0.26310495 0.26389505
## 3 0.20469265 0.20530735
## 2 0.11832234 0.11867766
## 1 0.09036432 0.09063568
#### Counts, cells independent, enough data (more than  five rows)
## IHS scores are not significantly better than expected value, 97% chance that this is due to random smapling. Therefore, fail to reject nulll that IHS is no better than global in tests
#Problem #2
APGRADE = matrix(c(29,24,8,15,6,1,2,0,0), ncol=2,byrow=TRUE)
## Warning in matrix(c(29, 24, 8, 15, 6, 1, 2, 0, 0), ncol = 2, byrow = TRUE):
## data length [9] is not a sub-multiple or multiple of the number of rows [5]
colnames(APGRADE) <- c("CALC","STATS")
rownames(APGRADE) <-c(5, 4, 3, 2, 1)
scores <- as.table(APGRADE)
addmargins(APGRADE)
##     CALC STATS Sum
## 5     29    24  53
## 4      8    15  23
## 3      6     1   7
## 2      2     0   2
## 1      0    29  29
## Sum   45    69 114
prop.table(APGRADE)
##         CALC      STATS
## 5 0.25438596 0.21052632
## 4 0.07017544 0.13157895
## 3 0.05263158 0.00877193
## 2 0.01754386 0.00000000
## 1 0.00000000 0.25438596
chisq.test(APGRADE)
## Warning in chisq.test(APGRADE): Chi-squared approximation may be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  APGRADE
## X-squared = 33.611, df = 4, p-value = 8.956e-07
chisq.test(APGRADE)$expected
## Warning in chisq.test(APGRADE): Chi-squared approximation may be incorrect
##         CALC     STATS
## 5 20.9210526 32.078947
## 4  9.0789474 13.921053
## 3  2.7631579  4.236842
## 2  0.7894737  1.210526
## 1 11.4473684 17.552632
## HOMOGENETIY TEST:
##Do homgenity test
## Conditions:
## Counts
## Data not independent or random, but assume data is representative of future class however proceed with caution!!
## ##Homogeneity test shows that 97% chance that Cal and Stats students are a homogenous group. Cal students do not score significantly better. Therefore, fail to reject null that calc and stat students score the same on tests
##
#Problem #3

STATGRADE = matrix(c(19,5,8,7,5,3,1,1,0,0), ncol=2,byrow=TRUE)
colnames(STATGRADE) <- c("M", "F")
rownames(STATGRADE) <-c("5", "4", "3", "2", "1")
scores <- as.table(STATGRADE)
addmargins(STATGRADE)
##      M  F Sum
## 5   19  5  24
## 4    8  7  15
## 3    5  3   8
## 2    1  1   2
## 1    0  0   0
## Sum 33 16  49
prop.table(STATGRADE)
##            M          F
## 5 0.38775510 0.10204082
## 4 0.16326531 0.14285714
## 3 0.10204082 0.06122449
## 2 0.02040816 0.02040816
## 1 0.00000000 0.00000000
chisq.test(STATGRADE)
## Warning in chisq.test(STATGRADE): Chi-squared approximation may be
## incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  STATGRADE
## X-squared = NaN, df = 4, p-value = NA
chisq.test(STATGRADE)$expected
## Warning in chisq.test(STATGRADE): Chi-squared approximation may be
## incorrect
##           M         F
## 5 16.163265 7.8367347
## 4 10.102041 4.8979592
## 3  5.387755 2.6122449
## 2  1.346939 0.6530612
## 1  0.000000 0.0000000
## HOMOGENETIY TEST:
##Do homgenity test
## COnditions:Counts
## Data not independent or random, but assume data is representative of future classes however proceed with caution!!
## ##Homogeneity test shows that 100% chance that higher scores for boys were based on just random variation
## Male and female test takers part of homogenous group, fail to reject null.