Assignment week 4.2 : Analysis of continuous data three or more group comparison

Statistic summary of amyalase level among the three groups of patients

setwd("C:/TMHG531/assignment")
ind.dat3 <- read.csv("ind_t_test3.csv")
#Group 1
summary(ind.dat3[ind.dat3$group==1,2])
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    29.0    39.0    47.0    66.0    94.5   135.0
#Group 2
summary(ind.dat3[ind.dat3$group==2,2])
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   12.00   48.00  100.50   94.55  134.00  200.00
#Group 3
summary(ind.dat3[ind.dat3$group==3,2])
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    78.0    97.5   129.5   161.5   227.5   344.0

Boxplot of Amylase level among the three groups of patients

boxplot(amylase~group, data=ind.dat3, main="Amylase level among the three group of patients",
        xlab="group", ylab="amylase level", col="pink")

** Analysis of Variance of data**

res.aov <- aov(amylase~group,data=ind.dat3)
summary(res.aov)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## group        1  58698   58698   17.26 0.000137 ***
## Residuals   47 159856    3401                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Find the pair with diffrence mean of amylase level

pairwise.t.test(ind.dat3$amylase,ind.dat3$group, p.adjust.method="bonferroni")
## 
##  Pairwise comparisons using t tests with pooled SD 
## 
## data:  ind.dat3$amylase and ind.dat3$group 
## 
##   1       2      
## 2 0.44781 -      
## 3 0.00032 0.00727
## 
## P value adjustment method: bonferroni

Checking normality of the distribution of data

plot(res.aov)

Homogeneity of the data

  library(car)
## Loading required package: carData
bartlett.test(amylase~group, data=ind.dat3)
## 
##  Bartlett test of homogeneity of variances
## 
## data:  amylase by group
## Bartlett's K-squared = 8.4709, df = 2, p-value = 0.01447

RESULT

Descriptives

Group N Mean Min Max
1 15 66.0 29 135
2 22 94.55 12 200
3 12 161.5 78 344

Hypothesis

H0 μ1 = μ2 = μ3
H1 Not all means are equal

Analysis of Variance

The P-value is 0.000137 which less than significant level of 0.05. The null hypothesis is rejected. Therefore, there are significant difference between the groups.

Df Sum of Squares Mean Squares F-value P-value
Between Groups 1 58,698 58,698 17.26 0.000137
Within Groups 47 159,856 3,401
Total 48 218,554 62,099

Normality of the distribution

According to the plot of the fitted againts residuals and the normal QQ, the data are random and independant and are normally distributed.

Multiple comparisons T-test

The P-value of pairing group 1 againts group 3 (0.00032) and group 2 againts group 3 (0.00032) is less than the significant level of 0.05. Therefore, mean of group 1 and group 2 and mean of group 2 and group 3 are significantly different.There are no evidence that mean of group 1 and group 3 are difference asthe P-value is more than the significant level of 0.05.

Pair P-value
Group 1 Group 2 0.44781
Group 3 0.00032
Group 2 Group 3 0.00727

Bartlett test of homogeneity of variances

The P-value is 0.01447 which is less than the significant level of 0.05. This is the evidence of the variance across groups are statistically significantly difference. Therefore, we can assume the heterogeneity of varience in the diffrence groups of patients.

K-squared Df P-value
8.4709 2 0.01447