This analysis evaluates the effect of different dietary treatments on serum biochemical parameters and growth performance of broiler chickens using one-way ANOVA.
The variables analyzed include:
library(tidyverse)
library(car)
library(agricolae)
library(emmeans)
library(readxl)
library(readr)
serum <- read.csv("serum_data.csv")
view(serum)
##viewing data set
head(serum)
## Bird_ID Treatment Cholesterol_mg_dL Glucose_mg_dL Total_Protein_g_dL
## 1 B001 Control 184.97 218.34 4.99
## 2 B002 Control 177.66 217.19 5.27
## 3 B003 Control 175.31 226.51 4.66
## 4 B004 Control 182.42 197.04 4.28
## 5 B005 Control 169.87 223.77 4.53
## 6 B006 Control 194.66 217.29 4.82
## Final_Weight_kg
## 1 2.13
## 2 2.02
## 3 1.83
## 4 1.82
## 5 1.69
## 6 1.69
summary(serum)
## Bird_ID Treatment Cholesterol_mg_dL Glucose_mg_dL
## Length:60 Length:60 Min. :129.8 Min. :177.6
## Class :character Class :character 1st Qu.:152.4 1st Qu.:201.7
## Mode :character Mode :character Median :160.5 Median :208.8
## Mean :161.6 Mean :209.4
## 3rd Qu.:172.0 3rd Qu.:216.7
## Max. :194.7 Max. :246.2
## Total_Protein_g_dL Final_Weight_kg
## Min. :4.280 Min. :1.690
## 1st Qu.:4.900 1st Qu.:2.015
## Median :5.120 Median :2.130
## Mean :5.128 Mean :2.141
## 3rd Qu.:5.420 3rd Qu.:2.312
## Max. :6.040 Max. :2.610
str(serum)
## 'data.frame': 60 obs. of 6 variables:
## $ Bird_ID : chr "B001" "B002" "B003" "B004" ...
## $ Treatment : chr "Control" "Control" "Control" "Control" ...
## $ Cholesterol_mg_dL : num 185 178 175 182 170 ...
## $ Glucose_mg_dL : num 218 217 227 197 224 ...
## $ Total_Protein_g_dL: num 4.99 5.27 4.66 4.28 4.53 4.82 4.45 4.62 5.05 4.4 ...
## $ Final_Weight_kg : num 2.13 2.02 1.83 1.82 1.69 1.69 1.96 2.18 1.72 1.93 ...
##cecking missing values
##Convert Treatment Variable to Factors (levels) to enable ANOvA analysis
serum$Treatment <- as.factor(serum$Treatment)
##summary stastics by Treatment group
descriptive_stat <- serum %>%
group_by(Treatment)%>%
summarise(
mean_cholesterol = mean(Cholesterol_mg_dL),
sd_cholesterol = sd(Cholesterol_mg_dL),
Mean_Glucose = mean(Glucose_mg_dL),
SD_Glucose = sd(Glucose_mg_dL),
Mean_Protein = mean(Total_Protein_g_dL),
SD_Protein = sd(Total_Protein_g_dL),
Mean_Weight = mean(Final_Weight_kg),
SD_Weight = sd(Final_Weight_kg)
)
descriptive_stat
## # A tibble: 4 × 9
## Treatment mean_cholesterol sd_cholesterol Mean_Glucose SD_Glucose Mean_Protein
## <fct> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Control 178. 7.60 215. 10.3 4.76
## 2 Feed_A 163. 5.52 213. 11.4 5.09
## 3 Feed_B 156. 7.95 210. 10.1 5.23
## 4 Feed_C 148. 10.6 200. 16.7 5.44
## # ℹ 3 more variables: SD_Protein <dbl>, Mean_Weight <dbl>, SD_Weight <dbl>
ggplot(serum, aes(x = Treatment,
y = Cholesterol_mg_dL,
fill = Treatment)) +
geom_boxplot() +
labs(
title = "Effect of Feed Treatment on Serum Cholesterol",
x = "Treatment Group",
y = "Cholesterol (mg/dL)"
) +
theme_minimal()
ggplot(serum,
aes(x = Cholesterol_mg_dL,
y = Final_Weight_kg,
color = Treatment)) +
geom_point(size = 3) +
geom_smooth(method = "lm",
se = FALSE) +
labs(
title = "Relationship Between Cholesterol and Weight by Treatment",
x = "Cholesterol (mg/dL)",
y = "Final Weight (kg)"
) +
theme_minimal()
###The scatter plot revealed treatment-specific patterns in the
relationship between serum cholesterol concentration and final body
weight. Birds receiving experimental feed treatments tended to exhibit
lower cholesterol levels alongside improved growth performance.
Does feed treatment significantly affect serum cholesterol concentration?
chol_model <- aov(Cholesterol_mg_dL ~ Treatment, data = serum)
summary(chol_model)
## Df Sum Sq Mean Sq F value Pr(>F)
## Treatment 3 7341 2447.1 37.19 2.34e-13 ***
## Residuals 56 3685 65.8
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
treatment variation and residual variation can be compared using F value which is the ratio of treatment variation and residual= 37.19, meaning Treatment variation is 37 times larger than random error variation(residual).
-One-way ANOVA revealed a highly significant effect of dietary treatment on the measured response variable (F = 37.19, p < 0.001). The results indicate that feed treatment substantially influenced the serum cholesterol of broiler chickens.
###understanding the residuals in the chol_model the difference between the actual observed value and the value predicted by the model.it represent unexplained variation which is used to check normality and equal variance. suppose the actual cholesterol level is 34 and the model predicted 23. the unpredictable value: 34 -23= 11 is the residual. the smaller the values the more correct the model is well fitted.
shapiro.test(residuals(chol_model))
##
## Shapiro-Wilk normality test
##
## data: residuals(chol_model)
## W = 0.98225, p-value = 0.5305
NULL HYPOTHESIS OF SHAPIRO TEST: residuals are normally distributed.
qqnorm(residuals(chol_model))
qqline(residuals(chol_model))
###QQ plot checks whether residuals follow a normal distribution. If points roughly follow the straight line:normality assumption is satisfied. Normal residuals are important for valid ANOVA inference
leveneTest(Cholesterol_mg_dL ~ Treatment, data = serum)
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 3 1.5839 0.2034
## 56
TukeyHSD(chol_model)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = Cholesterol_mg_dL ~ Treatment, data = serum)
##
## $Treatment
## diff lwr upr p adj
## Feed_A-Control -15.091333 -22.93443 -7.2482320 0.0000249
## Feed_B-Control -22.413333 -30.25643 -14.5702320 0.0000000
## Feed_C-Control -29.944000 -37.78710 -22.1008987 0.0000000
## Feed_B-Feed_A -7.322000 -15.16510 0.5211013 0.0755292
## Feed_C-Feed_A -14.852667 -22.69577 -7.0095654 0.0000331
## Feed_C-Feed_B -7.530667 -15.37377 0.3124346 0.0642213
duncan_t<- duncan.test(chol_model, "Treatment")
duncan_t
## $statistics
## MSerror Df Mean CV
## 65.80182 56 161.5558 5.02107
##
## $parameters
## test name.t ntr alpha
## Duncan Treatment 4 0.05
##
## $duncan
## Table CriticalRange
## 2 2.833010 5.933644
## 3 2.980048 6.241610
## 4 3.076937 6.444540
##
## $means
## Cholesterol_mg_dL std r se Min Max Q25 Q50
## Control 178.4180 7.603507 15 2.094466 165.21 194.66 173.610 177.66
## Feed_A 163.3267 5.524253 15 2.094466 150.85 173.13 159.955 164.64
## Feed_B 156.0047 7.950681 15 2.094466 144.38 173.66 150.375 156.00
## Feed_C 148.4740 10.567084 15 2.094466 129.75 173.15 141.900 147.77
## Q75
## Control 182.930
## Feed_A 166.725
## Feed_B 160.545
## Feed_C 154.365
##
## $comparison
## NULL
##
## $groups
## Cholesterol_mg_dL groups
## Control 178.4180 a
## Feed_A 163.3267 b
## Feed_B 156.0047 c
## Feed_C 148.4740 d
##
## attr(,"class")
## [1] "group"
Research question: Does feed treatment significantly affect final body weight? ## 10.1 Fit ANOVA Model
weight_model <- aov(Final_Weight_kg ~ Treatment,
data = serum)
weight_model
## Call:
## aov(formula = Final_Weight_kg ~ Treatment, data = serum)
##
## Terms:
## Treatment Residuals
## Sum of Squares 1.381013 1.384760
## Deg. of Freedom 3 56
##
## Residual standard error: 0.1572509
## Estimated effects may be unbalanced
summary(weight_model)
## Df Sum Sq Mean Sq F value Pr(>F)
## Treatment 3 1.381 0.4603 18.62 1.68e-08 ***
## Residuals 56 1.385 0.0247
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
shapiro.test(residuals(weight_model))
##
## Shapiro-Wilk normality test
##
## data: residuals(weight_model)
## W = 0.97742, p-value = 0.3293
leveneTest(Final_Weight_kg ~ Treatment,
data = serum)
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 3 1.0707 0.369
## 56
TukeyHSD(weight_model)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = Final_Weight_kg ~ Treatment, data = serum)
##
## $Treatment
## diff lwr upr p adj
## Feed_A-Control 0.1760000 0.02395851 0.3280415 0.0171205
## Feed_B-Control 0.2933333 0.14129184 0.4453748 0.0000237
## Feed_C-Control 0.4106667 0.25862518 0.5627082 0.0000000
## Feed_B-Feed_A 0.1173333 -0.03470816 0.2693748 0.1846645
## Feed_C-Feed_A 0.2346667 0.08262518 0.3867082 0.0007928
## Feed_C-Feed_B 0.1173333 -0.03470816 0.2693748 0.1846645
emmeans(chol_model, pairwise ~ Treatment)
## $emmeans
## Treatment emmean SE df lower.CL upper.CL
## Control 178 2.09 56 174 183
## Feed_A 163 2.09 56 159 168
## Feed_B 156 2.09 56 152 160
## Feed_C 148 2.09 56 144 153
##
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df t.ratio p.value
## Control - Feed_A 15.09 2.96 56 5.095 <0.0001
## Control - Feed_B 22.41 2.96 56 7.567 <0.0001
## Control - Feed_C 29.94 2.96 56 10.109 <0.0001
## Feed_A - Feed_B 7.32 2.96 56 2.472 0.0755
## Feed_A - Feed_C 14.85 2.96 56 5.014 <0.0001
## Feed_B - Feed_C 7.53 2.96 56 2.542 0.0642
##
## P value adjustment: tukey method for comparing a family of 4 estimates