enero 21, 2013

Pruebas de homogeneidad de varianza (R)

Sintaxis de R para obtener Levene’s Test y Brown and Forsythe's Test (Tabla 2.3 en Procedimientos Estadísticos para Investigaciones Agrícolas. 1984. Gómez, K.A.; Gómez, A.A. pp. 17-20)

## Levene's test para Diseño Completamente al Azar (DCA) con replicas desiguales

# Cargando datos
arrozDES = read.csv("C:/Users/Administrator/Desktop/table2.3.csv", header = T)
arrozDES
      tipo proporcion DDS rendimiento
1  hA/hB21   2.0/0.25  21        3187
2  hA/hB21   2.0/0.25  21        4610
3  hA/hB21   2.0/0.25  21        3562
4  hA/hB21   2.0/0.25  21        3217
5  hA/hC28   3.0/1.00  28        3390
6  hA/hC28   3.0/1.00  28        2875
7  hA/hC28   3.0/1.00  28        2775
8  hA/hC28   3.0/1.00  28          NA
9  hA/hB14   2.0/0.25  14        2797
10 hA/hB14   2.0/0.25  14        3001
11 hA/hB14   2.0/0.25  14        2505
12 hA/hB14   2.0/0.25  14        3490
13 hA/hD14   2.0/0.50  14        2832
14 hA/hD14   2.0/0.50  14        3103
15 hA/hD14   2.0/0.50  14        3448
16 hA/hD14   2.0/0.50  14        2255
17 hA/hE21   3.0/1.50  21        2233
18 hA/hE21   3.0/1.50  21        2743
19 hA/hE21   3.0/1.50  21        2727
20 hA/hE21   3.0/1.50  21          NA
21      hF        1.5  14        2952
22      hF        1.5  14        2272
23      hF        1.5  14        2470
24      hF        1.5  14          NA
25 hA/hB28   2.0/0.25  28        2858
26 hA/hB28   2.0/0.25  28        2895
27 hA/hB28   2.0/0.25  28        2458
28 hA/hB28   2.0/0.25  28        1723
29 hA/hG28   3.0/1.00  28        2308
30 hA/hG28   3.0/1.00  28        2335
31 hA/hG28   3.0/1.00  28        1975
32 hA/hG28   3.0/1.00  28          NA
33 hA/hD28   2.0/0.50  28        2013
34 hA/hD28   2.0/0.50  28        1788
35 hA/hD28   2.0/0.50  28        2248
36 hA/hD28   2.0/0.50  28        2115
37  Manual    15-y-35  NA        3202
38  Manual    15-y-36  NA        3060
39  Manual    15-y-37  NA        2240
40  Manual    15-y-38  NA        2690
41 Control             NA        1192
42 Control             NA        1652
43 Control             NA        1075
44 Control             NA        1030

# Analisis de varianza 
anova.arrozDES = aov(rendimiento ~ tipo, data=arrozDES)
summary(anova.arrozDES)
            Df   Sum Sq Mean Sq F value  Pr(>F)    
tipo        10 15090304 1509030    8.55 2.6e-06 ***
Residuals   29  5119419  176532                    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
4 observations deleted due to missingness

##Levene's test para homogenidad de varianza
require(car)
Loading required package: car
Loading required package: MASS
Loading required package: nnet
# Levene's test-desviacion absoluta de grupos de medias
leveneTest(anova.arrozDES, center=mean)
Levene's Test for Homogeneity of Variance (center = mean)
      Df F value Pr(>F)
group 10    0.88   0.57
      29               

# Brown and Forsythe's test-desviacion absoluta de grupos de medianas
leveneTest(anova.arrozDES)
Levene's Test for Homogeneity of Variance (center = median)
      Df F value Pr(>F)
group 10    0.53   0.85
      29               


En los resultados, ambas pruebas no son significativas. (Levene’s test: F10,29  = .88, p  = .56; Brown and Forsythes’s test F10,29  = .53,  = .85). Entonces, se asume que existe homogeneidad de varianzas.




No hay comentarios.: