0% found this document useful (0 votes)
40 views

DCA Script

The document describes a completely randomized design (CRD) experiment with 5 treatments and 20 observations total. Linear regression and ANOVA models are fit to analyze the effect of treatments on weight. Diagnostic plots and tests indicate the models meet assumptions of normality and equal variances. Post hoc tests including LSD and Tukey HSD find some treatments have significantly different mean weights while others do not differ.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

DCA Script

The document describes a completely randomized design (CRD) experiment with 5 treatments and 20 observations total. Linear regression and ANOVA models are fit to analyze the effect of treatments on weight. Diagnostic plots and tests indicate the models meet assumptions of normality and equal variances. Post hoc tests including LSD and Tukey HSD find some treatments have significantly different mean weights while others do not differ.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Diseño completamente al azar (DCA)

Wilmer Bermudez Pino

20/01/2022
setwd("F:/Sesion Practica")
library(readxl)
DCA_Montgomery <- read_excel("F:/Sesion Practica/DCA_Montgomery.xlsx",
sheet = "DCA", col_types = c("numeric",
"numeric"))
head(DCA_Montgomery)

## # A tibble: 6 x 2
## Tratamientos Peso
## <dbl> <dbl>
## 1 1 7
## 2 1 7
## 3 1 15
## 4 1 11
## 5 1 9
## 6 2 12

attach(DCA_Montgomery)
TRAT <- factor(Tratamientos)
Y <- as.numeric(as.vector(Peso))
modelo2 <- lm(Y ~ TRAT)
##diagrama de cajas
boxplot(Peso ~ Tratamientos, xlab="Tratamiento", ylab="Peso")
#Verificación de Supuestos
par(mfrow=c(2,2))
plot(modelo2)

##normalidad
residuals(modelo2)1

## 1 2 3 4 5 6 7 8 9 10 11 12 13 14
15 16
## -2.8 -2.8 5.2 1.2 -0.8 -3.4 1.6 -3.4 2.6 2.6 -3.6 0.4 0.4 1.4
1.4 -2.6
## 17 18 19 20 21 22 23 24 25
## 3.4 0.4 -2.6 1.4 -3.8 -0.8 0.2 4.2 0.2

library(nortest)
lillie.test(residuals(modelo2))

##
## Lilliefors (Kolmogorov-Smirnov) normality test
##
## data: residuals(modelo2)
## D = 0.16212, p-value = 0.08889

#ks.test(Peso,"pnorm", mean(Peso), sd(Peso))

##Igualdad de varianzas
library(car)

## Loading required package: carData


leveneTest(modelo2, center = "median")

## Levene's Test for Homogeneity of Variance (center = "median")


## Df F value Pr(>F)
## group 4 0.3179 0.8626
## 20

#Independencia
library(zoo)

##
## Attaching package: 'zoo'

## The following objects are masked from 'package:base':


##
## as.Date, as.Date.numeric

library(lmtest)
dwtest(modelo2)

##
## Durbin-Watson test
##
## data: modelo2
## DW = 2.4022, p-value = 0.5808
## alternative hypothesis: true autocorrelation is greater than 0

anova(modelo2)

## Analysis of Variance Table


##
## Response: Y
## Df Sum Sq Mean Sq F value Pr(>F)
## TRAT 4 475.76 118.94 14.757 9.128e-06 ***
## Residuals 20 161.20 8.06
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

#Comparacion de medias
library(agricolae)
Grupos<- LSD.test(y = modelo2, trt = "TRAT", group = T, console = T)

##
## Study: modelo2 ~ "TRAT"
##
## LSD t Test for Y
##
## Mean Square Error: 8.06
##
## TRAT, means and individual ( 95 %) CI
##
## Y std r LCL UCL Min Max
## 1 9.8 3.346640 5 7.151566 12.44843 7 15
## 2 15.4 3.130495 5 12.751566 18.04843 12 18
## 3 17.6 2.073644 5 14.951566 20.24843 14 19
## 4 21.6 2.607681 5 18.951566 24.24843 19 25
## 5 10.8 2.863564 5 8.151566 13.44843 7 15
##
## Alpha: 0.05 ; DF Error: 20
## Critical Value of t: 2.085963
##
## least Significant Difference: 3.745452
##
## Treatments with the same letter are not significantly different.
##
## Y groups
## 4 21.6 a
## 3 17.6 b
## 2 15.4 b
## 5 10.8 c
## 1 9.8 c

Grupos<- LSD.test(y = modelo2, trt = "TRAT", group = F, console = T)

##
## Study: modelo2 ~ "TRAT"
##
## LSD t Test for Y
##
## Mean Square Error: 8.06
##
## TRAT, means and individual ( 95 %) CI
##
## Y std r LCL UCL Min Max
## 1 9.8 3.346640 5 7.151566 12.44843 7 15
## 2 15.4 3.130495 5 12.751566 18.04843 12 18
## 3 17.6 2.073644 5 14.951566 20.24843 14 19
## 4 21.6 2.607681 5 18.951566 24.24843 19 25
## 5 10.8 2.863564 5 8.151566 13.44843 7 15
##
## Alpha: 0.05 ; DF Error: 20
## Critical Value of t: 2.085963
##
## Comparison between treatments means
##
## difference pvalue signif. LCL UCL
## 1 - 2 -5.6 0.0054 ** -9.3454518 -1.8545482
## 1 - 3 -7.8 0.0003 *** -11.5454518 -4.0545482
## 1 - 4 -11.8 0.0000 *** -15.5454518 -8.0545482
## 1 - 5 -1.0 0.5838 -4.7454518 2.7454518
## 2 - 3 -2.2 0.2347 -5.9454518 1.5454518
## 2 - 4 -6.2 0.0025 ** -9.9454518 -2.4545482
## 2 - 5 4.6 0.0186 * 0.8545482 8.3454518
## 3 - 4 -4.0 0.0375 * -7.7454518 -0.2545482
## 3 - 5 6.8 0.0012 ** 3.0545482 10.5454518
## 4 - 5 10.8 0.0000 *** 7.0545482 14.5454518
#Prueba de tukey
outHSD<-HSD.test(modelo2, "TRAT",console=TRUE)

##
## Study: modelo2 ~ "TRAT"
##
## HSD Test for Y
##
## Mean Square Error: 8.06
##
## TRAT, means
##
## Y std r Min Max
## 1 9.8 3.346640 5 7 15
## 2 15.4 3.130495 5 12 18
## 3 17.6 2.073644 5 14 19
## 4 21.6 2.607681 5 19 25
## 5 10.8 2.863564 5 7 15
##
## Alpha: 0.05 ; DF Error: 20
## Critical Value of Studentized Range: 4.231857
##
## Minimun Significant Difference: 5.372958
##
## Treatments with the same letter are not significantly different.
##
## Y groups
## 4 21.6 a
## 3 17.6 ab
## 2 15.4 bc
## 5 10.8 cd
## 1 9.8 d

You might also like