library(readxl)
METANOL <- read_excel("METANOL.xlsx")
summary(METANOL)
## EMPRESAS EDADES METANOL
## Length:12 Length:12 Min. :0.6000
## Class :character Class :character 1st Qu.:0.6750
## Mode :character Mode :character Median :0.7000
## Mean :0.7083
## 3rd Qu.:0.7250
## Max. :0.9000
attach(METANOL)
## The following object is masked _by_ .GlobalEnv:
##
## METANOL
sustancia <- as.factor(EMPRESAS)
summary(EMPRESAS)
## Length Class Mode
## 12 character character
library(ggplot2)
ggplot(METANOL, aes(x = EMPRESAS, y = METANOL)) +
geom_boxplot(fill = "grey80", colour = "blue") +
scale_x_discrete() + xlab("Empresas") +
ylab("Mediciones de Metanol")
ggplot(METANOL, aes(x = EDADES, y = METANOL)) +
geom_boxplot(fill = "grey80", colour = "blue") +
scale_x_discrete() + xlab("Edades") +
ylab("Mediciones de Metanol")
########### SUPUESTOS ANOVA
anova.METANOL = aov(METANOL ~ EMPRESAS+EDADES, data=METANOL)
e<-anova.METANOL$residuals ##### residuales
NORMALIDAD si p_valor > 0,05 se cumple supuesto
shapiro.test(e) #### Normalidad
##
## Shapiro-Wilk normality test
##
## data: e
## W = 0.92434, p-value = 0.324
hist(e, freq=FALSE)
curve(dnorm(x,mean(e), sd(e)), xlim=c(-1.3,1.3), add=TRUE, col=2)
################### HOMOGENEIDAD VARIANZAS si p_valor es mayor a 0,05 se cumple supuesto
library(carData)
library(car)
#####HOMOGENEIDAD
leveneTest(e ~ as.factor(EMPRESAS), data = METANOL, center = "median")
## Levene's Test for Homogeneity of Variance (center = "median")
## Df F value Pr(>F)
## group 2 0.7222 0.5118
## 9
ANOVA
anova.METANOL = aov(METANOL ~ EMPRESAS+EDADES, data=METANOL)
summary(anova.METANOL)
## Df Sum Sq Mean Sq F value Pr(>F)
## EMPRESAS 2 0.00167 0.000833 0.097 0.909
## EDADES 3 0.03583 0.011944 1.387 0.334
## Residuals 6 0.05167 0.008611
library(agricolae) ## LIBRERIA POST ANOVA
HSD.test(anova.METANOL,"EMPRESAS", alpha=0.05,
console=TRUE, group=FALSE)
##
## Study: anova.METANOL ~ "EMPRESAS"
##
## HSD Test for METANOL
##
## Mean Square Error: 0.008611111
##
## EMPRESAS, means
##
## METANOL std r Min Max
## A 0.725 0.12583057 4 0.6 0.9
## B 0.700 0.08164966 4 0.6 0.8
## C 0.700 0.08164966 4 0.6 0.8
##
## Alpha: 0.05 ; DF Error: 6
## Critical Value of Studentized Range: 4.339195
##
## Comparison between treatments means
##
## difference pvalue signif. LCL UCL
## A - B 0.025 0.9241 -0.1763301 0.2263301
## A - C 0.025 0.9241 -0.1763301 0.2263301
## B - C 0.000 1.0000 -0.2013301 0.2013301