library(readxl)
golf <- read_excel("C:/Users/win10/Desktop/lab4 DBCA/golf.xlsx")
View(golf)
attach(golf) ### no se necesita usar el $ para llamar variables
golf
## # A tibble: 20 x 3
## cesped terreno distancia
## <chr> <chr> <dbl>
## 1 AgrTenuis(1) B1 1.3
## 2 AgrCanina(2) B2 2.2
## 3 Pasnotatum(3) B3 1.8
## 4 Vaginatum(4) B4 3.9
## 5 AgrTenuis(1) B1 1.6
## 6 AgrCanina(2) B2 2.4
## 7 Pasnotatum(3) B3 1.7
## 8 Vaginatum(4) B4 4.4
## 9 AgrTenuis(1) B1 0.5
## 10 AgrCanina(2) B2 0.4
## 11 Pasnotatum(3) B3 0.6
## 12 Vaginatum(4) B4 2
## 13 AgrTenuis(1) B1 1.2
## 14 AgrCanina(2) B2 2
## 15 Pasnotatum(3) B3 1.5
## 16 Vaginatum(4) B4 4.1
## 17 AgrTenuis(1) B1 1.1
## 18 AgrCanina(2) B2 1.8
## 19 Pasnotatum(3) B3 1.3
## 20 Vaginatum(4) B4 3.4
library("ggplot2")
ggplot(golf, aes(x = cesped, y = distancia)) +
geom_boxplot(fill = "grey80", colour = "blue") +
scale_x_discrete() + xlab("Cesped") +
ylab("Distancias")
BLOQUES
library("ggplot2")
ggplot(golf, aes(x = terreno, y = distancia)) +
geom_boxplot(fill = "grey80", colour = "blue") +
scale_x_discrete() + xlab("Terrenos") +
ylab("Distancias")
anova.golf = aov(distancia ~ cesped+terreno, data=golf)
e<-anova.golf$residuals ##### residuales
t.test(e,mu=0) ### Se verifica si la suma de residuales es igual a cero
##
## One Sample t-test
##
## data: e
## t = 1.1996e-16, df = 19, p-value = 1
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
## -0.2968539 0.2968539
## sample estimates:
## mean of x
## 1.701384e-17
shapiro.test(e)
##
## Shapiro-Wilk normality test
##
## data: e
## W = 0.87137, p-value = 0.01242
hist(e, freq=FALSE)
curve(dnorm(x,mean(e), sd(e)), xlim=c(-3,3), add=TRUE, col=2)
library(carData)
library(car)
leveneTest(e ~ as.factor(cesped), data =golf, center = "median") #####homogeneidad
## Levene's Test for Homogeneity of Variance (center = "median")
## Df F value Pr(>F)
## group 3 0.4517 0.7197
## 16
library(randtests)
runs.test(e)
##
## Runs Test
##
## data: e
## statistic = -2.2973, runs = 6, n1 = 10, n2 = 10, n = 20, p-value =
## 0.0216
## alternative hypothesis: nonrandomness
kruskal.test(e ~ as.factor(cesped), data =golf)
##
## Kruskal-Wallis rank sum test
##
## data: e by as.factor(cesped)
## Kruskal-Wallis chi-squared = 0.57714, df = 3, p-value = 0.9016
library(agricolae)
LSD.test(anova.golf,"cesped",console=TRUE)
##
## Study: anova.golf ~ "cesped"
##
## LSD t Test for distancia
##
## Mean Square Error: 0.47775
##
## cesped, means and individual ( 95 %) CI
##
## distancia std r LCL UCL Min Max
## AgrCanina(2) 1.76 0.7924645 5 1.1047126 2.415287 0.4 2.4
## AgrTenuis(1) 1.14 0.4037326 5 0.4847126 1.795287 0.5 1.6
## Pasnotatum(3) 1.38 0.4764452 5 0.7247126 2.035287 0.6 1.8
## Vaginatum(4) 3.56 0.9449868 5 2.9047126 4.215287 2.0 4.4
##
## Alpha: 0.05 ; DF Error: 16
## Critical Value of t: 2.119905
##
## least Significant Difference: 0.9267163
##
## Treatments with the same letter are not significantly different.
##
## distancia groups
## Vaginatum(4) 3.56 a
## AgrCanina(2) 1.76 b
## Pasnotatum(3) 1.38 b
## AgrTenuis(1) 1.14 b