`
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
TRATAMIENTO <- as.factor(cesped)
PATOLOGIA <- as.factor(terreno)
summary(cesped)
## Length Class Mode
## 20 character character
summary(terreno)
## Length Class Mode
## 20 character character
library("ggplot2")
ggplot(golf, aes(x = cesped, y = distancia)) +
geom_boxplot(fill = "grey80", colour = "blue") +
scale_x_discrete() + xlab("Cesped") +
ylab("Distancias")
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)
##
## 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) #### prueba Normalidad
##
## 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
anova.golf = aov(distancia ~ cesped+terreno, data=golf)
summary(anova.golf)
## Df Sum Sq Mean Sq F value Pr(>F)
## cesped 3 18.044 6.015 12.59 0.000176 ***
## Residuals 16 7.644 0.478
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
library(agricolae) #### PAQUETE DE PRUEBAS POST-ANOVA
##### PRUEBA TUKEY
HSD.test(anova.golf,"cesped", alpha=0.05, console=TRUE, group=FALSE)
##
## Study: anova.golf ~ "cesped"
##
## HSD Test for distancia
##
## Mean Square Error: 0.47775
##
## cesped, means
##
## distancia std r Min Max
## AgrCanina(2) 1.76 0.7924645 5 0.4 2.4
## AgrTenuis(1) 1.14 0.4037326 5 0.5 1.6
## Pasnotatum(3) 1.38 0.4764452 5 0.6 1.8
## Vaginatum(4) 3.56 0.9449868 5 2.0 4.4
##
## Alpha: 0.05 ; DF Error: 16
## Critical Value of Studentized Range: 4.046093
##
## Comparison between treatments means
##
## difference pvalue signif. LCL UCL
## AgrCanina(2) - AgrTenuis(1) 0.62 0.5066 -0.6306944 1.8706944
## AgrCanina(2) - Pasnotatum(3) 0.38 0.8205 -0.8706944 1.6306944
## AgrCanina(2) - Vaginatum(4) -1.80 0.0040 ** -3.0506944 -0.5493056
## AgrTenuis(1) - Pasnotatum(3) -0.24 0.9455 -1.4906944 1.0106944
## AgrTenuis(1) - Vaginatum(4) -2.42 0.0002 *** -3.6706944 -1.1693056
## Pasnotatum(3) - Vaginatum(4) -2.18 0.0007 *** -3.4306944 -0.9293056
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
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