WL<-data.frame(Pre= c(6.9, 4.8, 16.4, 19.8, 16.2, 21.1, 15, 14.9, 9.4, 16.5, 21.6, 19.3, 7.1, 31.7, 24.7, 9.8, 19.1, 3.3, 15.4, 17.9, 18.2, 19, 6.4, 3.7, 24.5, 15.9, 9.6, 29.9, 18.2, 30.6, 22.4, 21.7, 6.5, 1.4, 28.9, 13.9, 7.6, 12.9, 17, 35.8, 23.1, 14.9, 18.3, -0.1, 7.4, 10.6, 21.7, 4.1, 9.1, -1.9, 32, 3.9, 30.3, 23.5, 23.6, 21, 9, 29.6, 12, 15.6, 11.4, 11.3, 35.4, 20.1, 10.1, 15.2, 6.3, 14.3, 29.2, 15.5, 8.3, -8.2, 4.5, 11.7, 14.1, -1.2, 23.9, 10.7, 23.8, 17.2, 25.6, 8.4, 12.7, 15, 15.8, 34.4, 30, 19.6, 23, 13.2, 1, 31.7, 18.9, -1.5, 30.2, 8.8, 27.2, 22.5, 27, 8.8), Post = c(18.3, 13.4, 5.1, 8.4, 8.6, 26.2, 26.2, 21, 14, 9.1, 21.7, 9.5, 25.9, 26.7, 8.9, 9.4, 14.9, 13.6, 29.2, 10.4, 13.3, 18.4, 8, 8.2, 5.3, 27.7, 18.9, -0.9, 22, 11.5, 4.3, 26.9, 30, 13.6, 22, 15.4, 8.7, 11.7, 33, 31.3, 21.6, 25.7, 15.3, 17, 10, 32.8, 26.4, 19.4, 15.3, 25.4, 22.6, 10, 17.4, 27.9, 26, 24.7, 16.1, 21.3, 22, 5.6, 14.7, 23, 23.3, 31.1, 21.3, 24.5, 12.6, 13.9, 18.7, 18.5, 10, 17.5, 20.6, 22, 19.4, 14.3, 15.5, 12, 19.4, 15, 22.8, 9.2, 22.4, 22.9, 16.3, 23.2, 28.8, 15.3, 18, 13.6, 25.8, 28.7, 19.7, 17.5, 14.8, 9.5, 16, 29.1, 11.1, 18.2))
head(WL)
## Pre Post
## 1 6.9 18.3
## 2 4.8 13.4
## 3 16.4 5.1
## 4 19.8 8.4
## 5 16.2 8.6
## 6 21.1 26.2
summary(WL)
## Pre Post
## Min. :-8.200 Min. :-0.90
## 1st Qu.: 9.075 1st Qu.:13.12
## Median :15.700 Median :18.10
## Mean :16.086 Mean :18.02
## 3rd Qu.:22.625 3rd Qu.:23.05
## Max. :35.800 Max. :33.00
# Calculate the standard deviation of each column
Std <- apply(WL, 2,sd )
Std
## Pre Post
## 9.454164 7.309774
# Compute difference scores
diff <- WL$Post - WL$Pre
# mean
Mean_diff<- mean(diff)
Mean_diff
## [1] 1.939
# standard deviation
std_diff<- sd(diff)
std_diff
## [1] 10.87832
# Histogram
hist(diff)
# Normal probability plot
qqnorm(diff); qqline(diff)
# Welch Two Sample t-test
t.test(WL$Pre, WL$Post, alternative = "two.sided")
##
## Welch Two Sample t-test
##
## data: WL$Pre and WL$Post
## t = -1.6225, df = 186.2, p-value = 0.1064
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -4.2965745 0.4185745
## sample estimates:
## mean of x mean of y
## 16.086 18.025
# Paired t-test
t.test(WL$Pre, WL$Post, paired = TRUE)
##
## Paired t-test
##
## data: WL$Pre and WL$Post
## t = -1.7824, df = 99, p-value = 0.07774
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## -4.0974939 0.2194939
## sample estimates:
## mean difference
## -1.939
library(tidyverse) # for data cleaning and EDA
Fert<-read.csv("C:/Users/user/Desktop/FACTUALS/crop.data_.anova_/crop.data.csv", header=T)
head(Fert)
## density block fertilizer yield
## 1 1 1 1 177.2287
## 2 2 2 1 177.5500
## 3 1 3 1 176.4085
## 4 2 4 1 177.7036
## 5 1 1 1 177.1255
## 6 2 2 1 176.7783
Fert$fertilizer<-as.factor(Fert$fertilizer)
Fert$density<-as.factor(Fert$density)
Fert$block<-as.factor(Fert$block)
glimpse(Fert)
## Rows: 96
## Columns: 4
## $ density <fct> 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2,…
## $ block <fct> 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,…
## $ fertilizer <fct> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ yield <dbl> 177.2287, 177.5500, 176.4085, 177.7036, 177.1255, 176.7783,…
summary(Fert)
## density block fertilizer yield
## 1:48 1:24 1:32 Min. :175.4
## 2:48 2:24 2:32 1st Qu.:176.5
## 3:24 3:32 Median :177.1
## 4:24 Mean :177.0
## 3rd Qu.:177.4
## Max. :179.1
#standard deviation
sd_yield<-sd(Fert$yield)
sd_yield
## [1] 0.6645476
attach(Fert)
mod<-aov(yield~fertilizer)
summary(mod)
## Df Sum Sq Mean Sq F value Pr(>F)
## fertilizer 2 6.07 3.0340 7.863 7e-04 ***
## Residuals 93 35.89 0.3859
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(mod)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = yield ~ fertilizer)
##
## $fertilizer
## diff lwr upr p adj
## 2-1 0.1761687 -0.19371896 0.5460564 0.4954705
## 3-1 0.5991256 0.22923789 0.9690133 0.0006125
## 3-2 0.4229569 0.05306916 0.7928445 0.0208735
Your comments and recommendations are highly appreciated↩︎