Datos diseño experimental

Los siguientes datos corresponden a un diseño de experimentos de evaluacion de rendimiento de diversos genotipos de papa en varios ambientes (zonas con climas diversos).

require(ggplot2)
## Loading required package: ggplot2
require(plotly)
## Loading required package: plotly
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
require(agricolae)
## Loading required package: agricolae
data("genxenv")
head(genxenv,3)
##   ENV GEN      YLD
## 1   1   1 17.62333
## 2   1   2 26.98333
## 3   1   3 23.55000
#y=YLD (yield=rendimiento -toneladas por hectareas)
#x1=GEN (Genotype= variedad)
#x2=ENV (enviroment-ambiente)
genxenv$ENV=as.factor(genxenv$ENV)
genxenv$GEN=as.factor(genxenv$GEN)

ggplot(genxenv, aes(x=YLD))+geom_histogram()+theme_bw()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

ggplot(genxenv, aes(x=YLD,fill=ENV))+geom_histogram()+theme_bw()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

ggplot(genxenv, aes(y=YLD,x=ENV,fill=ENV))+geom_boxplot()+theme_bw()

Se observa que la variable rendimiento presenta gran variabilidad de acuerdo al histograma y muestra un comportamiento de subgrupos. Cuando realizamos la comparación por ambientes se logra observar que parte de esas diferencias de los grupos se debe a los ambientes. Por ejemplo el 1 y 2 presentan bajos rendimientos y el 4 y 5 son más altos.

Modelo para comparar solo ambientes

mod1.0=lm(YLD~ENV, data=genxenv)
anova(mod1.0)
## Analysis of Variance Table
## 
## Response: YLD
##            Df Sum Sq Mean Sq F value    Pr(>F)    
## ENV         4 242922   60731  695.09 < 2.2e-16 ***
## Residuals 245  21406      87                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(mod1.0)
## 
## Call:
## lm(formula = YLD ~ ENV, data = genxenv)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -37.359  -4.555   0.040   4.232  32.125 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   24.047      1.322  18.191  < 2e-16 ***
## ENV2          -7.505      1.869  -4.015 7.91e-05 ***
## ENV3          54.383      1.869  29.090  < 2e-16 ***
## ENV4          70.295      1.869  37.602  < 2e-16 ***
## ENV5           8.813      1.869   4.714 4.07e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 9.347 on 245 degrees of freedom
## Multiple R-squared:  0.919,  Adjusted R-squared:  0.9177 
## F-statistic: 695.1 on 4 and 245 DF,  p-value: < 2.2e-16

La tabla anova nos muestra que existen diferencias significativas entre los ambientes con el resumen podemos observar que algunos se destacan más que otros como el 3 y 4. Sin embargo, para contrastar todas las combinaciones y obtener los mejores ambientes debemos usar una prueba postanova.

post1=LSD.test(mod1.0, "ENV")
post1
## $statistics
##    MSerror  Df     Mean       CV  t.value      LSD
##   87.37046 245 49.24373 18.98153 1.969694 3.682231
## 
## $parameters
##         test p.ajusted name.t ntr alpha
##   Fisher-LSD      none    ENV   5  0.05
## 
## $means
##        YLD       std  r      LCL      UCL      Min       Max      Q25      Q50
## 1 24.04653  7.340494 50 21.44280 26.65026 12.65667  42.47000 18.55583 22.80167
## 2 16.54113  3.192049 50 13.93740 19.14486  9.90000  26.13000 14.19250 17.13833
## 3 78.42927  9.398327 50 75.82554 81.03300 58.09000 100.79667 72.75083 78.33500
## 4 94.34200 16.242465 50 91.73827 96.94573 56.98333 126.46667 84.28500 97.17167
## 5 32.85973  4.542469 50 30.25600 35.46346 23.39667  48.00667 29.26250 32.81000
##         Q75
## 1  27.44333
## 2  18.63750
## 3  84.74917
## 4 101.56500
## 5  35.84833
## 
## $comparison
## NULL
## 
## $groups
##        YLD groups
## 4 94.34200      a
## 3 78.42927      b
## 5 32.85973      c
## 1 24.04653      d
## 2 16.54113      e
## 
## attr(,"class")
## [1] "group"
bar.group(post1$groups, ylim=c(0,120))

Se observa en el postanova que los ambientes 4 y 3 son los de mayor rendimiento mientras que el 2 es el menos favorable para la productividad de la papa.

Modelos para comparar genotipos teniendo en cuenta el ambiente

mod2.0=lm(YLD~ENV+GEN, data=genxenv)
anova(mod2.0)
## Analysis of Variance Table
## 
## Response: YLD
##            Df Sum Sq Mean Sq  F value    Pr(>F)    
## ENV         4 242922   60731 876.7745 < 2.2e-16 ***
## GEN        49   7830     160   2.3069 2.833e-05 ***
## Residuals 196  13576      69                       
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
post2=LSD.test(mod2.0, "GEN")
post2
## $statistics
##    MSerror  Df     Mean       CV  t.value      LSD
##   69.26587 196 49.24373 16.90085 1.972141 10.38072
## 
## $parameters
##         test p.ajusted name.t ntr alpha
##   Fisher-LSD      none    GEN  50  0.05
## 
## $means
##         YLD      std r      LCL      UCL       Min       Max      Q25      Q50
## 1  44.73733 32.55482 5 37.39705 52.07761 17.216667  82.85333 17.62333 28.94000
## 10 49.12000 40.48756 5 41.77972 56.46028 13.493333  99.30333 20.24333 26.00667
## 11 51.56800 30.84790 5 44.22772 58.90828 19.290000  93.99667 35.60667 35.86333
## 12 52.51733 35.94814 5 45.17705 59.85761 15.406667 105.09667 34.25667 35.34000
## 13 57.65067 43.27937 5 50.31039 64.99095 17.623333 115.90333 26.97333 36.69000
## 14 64.09733 45.74939 5 56.75705 71.43761 21.623333 125.92333 31.50667 42.47000
## 15 52.62067 38.08023 5 45.28039 59.96095 18.986667 103.66333 27.31333 30.18667
## 16 48.59400 37.48420 5 41.25372 55.93428 12.826667 100.56667 17.38333 39.46667
## 17 43.45400 30.58004 5 36.11372 50.79428 15.513333  83.68333 20.12000 29.79333
## 18 49.40933 29.50659 5 42.06905 56.74961 17.916667  83.28000 23.02667 48.00667
## 19 52.11800 38.79318 5 44.77772 59.45828 18.546667  98.24000 19.70000 34.51000
## 2  41.30933 26.25397 5 33.96905 48.64961 13.530000  73.83667 26.98333 27.71000
## 20 36.84867 25.66660 5 29.50839 44.18895  9.933333  67.17333 12.65667 37.49667
## 21 53.49600 41.25961 5 46.15572 60.83628 17.206667 108.85333 22.73333 32.76000
## 22 46.17067 34.89814 5 38.83039 53.51095 15.666667  98.92667 21.58333 30.74667
## 23 47.99933 30.50167 5 40.65905 55.33961 15.970000  81.68000 29.39333 33.33333
## 24 51.72800 35.76393 5 44.38772 59.06828 18.560000  93.37667 27.44333 31.64000
## 25 44.28533 31.68427 5 36.94505 51.62561 12.070000  81.48667 18.89000 35.24667
## 26 44.66800 36.89362 5 37.32772 52.00828 10.216667  86.38000 17.13000 26.93333
## 27 55.91267 38.47252 5 48.57239 63.25295 18.783333 108.54667 31.05000 37.03667
## 28 55.01400 45.72438 5 47.67372 62.35428 14.310000 119.46667 17.81000 38.53333
## 29 51.27000 43.61796 5 43.92972 58.61028 14.200000 108.40667 17.81667 28.27667
## 3  39.73800 23.44033 5 32.39772 47.07828 17.733333  71.78000 23.55000 28.56667
## 30 53.61667 48.21166 5 46.27639 60.95695 13.886667 126.46667 19.86667 28.70667
## 31 44.21600 33.28330 5 36.87572 51.55628  9.900000  87.70000 22.46333 30.38000
## 32 50.18867 30.00424 5 42.84839 57.52895 17.096667  93.79333 35.67333 38.30000
## 33 50.08400 35.97018 5 42.74372 57.42428 18.366667  97.54333 25.59667 29.16667
## 34 53.06600 44.81368 5 45.72572 60.40628 14.190000 117.64000 22.22333 29.30000
## 35 47.95667 31.64728 5 40.61639 55.29695 15.706667  84.62000 27.44333 32.86000
## 36 44.87800 35.30855 5 37.53772 52.21828 13.946667  90.73333 13.98667 32.30000
## 37 56.21200 32.37567 5 48.87172 63.55228 22.750000  98.92333 36.38000 41.51000
## 38 53.11600 38.60790 5 45.77572 60.45628 19.313333 101.00000 22.87000 33.98333
## 39 49.98400 36.97341 5 42.64372 57.32428 13.893333 100.31667 23.20333 35.80333
## 4  49.17867 32.27384 5 41.83839 56.51895 20.080000  88.26667 24.50333 33.33667
## 40 51.01133 35.81602 5 43.67105 58.35161 18.786667 100.99667 27.10000 31.68667
## 41 43.11400 30.96953 5 35.77372 50.45428 14.600000  84.17333 14.78333 36.68333
## 42 50.19867 36.14306 5 42.85839 57.53895 18.583333  98.85667 20.02000 36.01667
## 43 52.61333 40.78926 5 45.27305 59.95361 15.990000 101.75333 17.40000 37.49000
## 44 46.83600 34.78686 5 39.49572 54.17628 13.086667  86.79667 15.41667 39.44333
## 45 50.23933 35.09432 5 42.89905 57.57961 17.180000  99.40000 22.03333 39.74000
## 46 38.99600 27.77105 5 31.65572 46.33628 14.446667  77.47667 15.71667 29.25000
## 47 49.96933 36.64249 5 42.62905 57.30961 17.483333 104.58333 28.35667 28.91000
## 48 50.18533 32.24445 5 42.84505 57.52561 22.240000  94.51667 26.13000 33.96333
## 49 43.69333 26.76515 5 36.35305 51.03361 18.663333  80.75333 21.84333 35.56667
## 5  35.21400 25.26154 5 27.87372 42.55428 13.690000  65.74000 14.10667 23.39667
## 50 46.10933 32.40048 5 38.76905 53.44961 17.013333  85.18000 24.25667 26.77000
## 6  54.46800 38.67896 5 47.12772 61.80828 16.620000 100.51333 31.12333 32.27667
## 7  51.20667 32.50882 5 43.86639 58.54695 17.986667  96.80000 34.08333 34.34000
## 8  50.75667 33.79318 5 43.41639 58.09695 18.923333  91.75000 29.48667 30.84667
## 9  60.75200 49.47199 5 53.41172 68.09228 14.436667 126.08000 27.37667 35.07000
##          Q75
## 1   77.05333
## 10  86.55333
## 11  73.08333
## 12  72.48667
## 13  91.06333
## 14  98.96333
## 15  82.95333
## 16  72.72667
## 17  68.16000
## 18  74.81667
## 19  89.59333
## 2   64.48667
## 20  56.98333
## 21  85.92667
## 22  63.93000
## 23  79.62000
## 24  87.62000
## 25  73.73333
## 26  82.68000
## 27  84.14667
## 28  84.95000
## 29  87.65000
## 3   57.06000
## 30  79.15667
## 31  70.63667
## 32  66.08000
## 33  79.74667
## 34  81.97667
## 35  79.15333
## 36  73.42333
## 37  81.49667
## 38  88.41333
## 39  76.70333
## 4   79.70667
## 40  76.48667
## 41  65.33000
## 42  77.51667
## 43  90.43333
## 44  79.43667
## 45  72.84333
## 46  58.09000
## 47  70.51333
## 48  74.07667
## 49  61.64000
## 5   59.13667
## 50  77.32667
## 6   91.80667
## 7   72.82333
## 8   82.77667
## 9  100.79667
## 
## $comparison
## NULL
## 
## $groups
##         YLD    groups
## 14 64.09733         a
## 9  60.75200        ab
## 13 57.65067       abc
## 37 56.21200      abcd
## 27 55.91267      abcd
## 28 55.01400     abcde
## 6  54.46800    abcdef
## 30 53.61667    bcdefg
## 21 53.49600    bcdefg
## 38 53.11600   bcdefgh
## 34 53.06600   bcdefgh
## 15 52.62067   bcdefgh
## 43 52.61333   bcdefgh
## 12 52.51733   bcdefgh
## 19 52.11800   bcdefgh
## 24 51.72800   bcdefgh
## 11 51.56800  bcdefghi
## 29 51.27000  bcdefghi
## 7  51.20667  bcdefghi
## 40 51.01133  bcdefghi
## 8  50.75667  bcdefghi
## 45 50.23933   cdefghi
## 42 50.19867   cdefghi
## 32 50.18867   cdefghi
## 48 50.18533   cdefghi
## 33 50.08400  cdefghij
## 39 49.98400  cdefghij
## 47 49.96933  cdefghij
## 18 49.40933  cdefghij
## 4  49.17867 cdefghijk
## 10 49.12000 cdefghijk
## 16 48.59400 cdefghijk
## 23 47.99933 cdefghijk
## 35 47.95667 cdefghijk
## 44 46.83600 defghijkl
## 22 46.17067 defghijkl
## 50 46.10933 defghijkl
## 36 44.87800 efghijklm
## 1  44.73733 efghijklm
## 26 44.66800 efghijklm
## 25 44.28533  fghijklm
## 31 44.21600  fghijklm
## 49 43.69333   ghijklm
## 17 43.45400   ghijklm
## 41 43.11400    hijklm
## 2  41.30933     ijklm
## 3  39.73800      jklm
## 46 38.99600       klm
## 20 36.84867        lm
## 5  35.21400         m
## 
## attr(,"class")
## [1] "group"
bar.group(post2$groups, xlim=c(0,90),horiz = T, las=2)

Se observan diferencias significativas entre los genotipos, destacando el 14 como el de mejor desempeño y el 5 de menor desempeño. Sin embargo, algunos adicionales como el 13 y 9 presentaron desempeños similares al 14.

Datos de Irrigación

En una prueba de campo agrícola, el objetivo fue determinar los efectos de dos variedades de cultivos y cuatro métodos de riego diferentes. Había ocho campos disponibles, pero solo se puede aplicar un tipo de riego a cada campo. Los campos se pueden dividir en dos partes con una variedad diferente plantada en cada mitad. El factor de la parcela completa es el método de riego, que debe asignarse al azar a los campos. Dentro de cada campo, la variedad se asigna aleatoriamente.

require(faraway)
## Loading required package: faraway
data("irrigation")
irrigation
##    field irrigation variety yield
## 1     f1         i1      v1  35.4
## 2     f1         i1      v2  37.9
## 3     f2         i2      v1  36.7
## 4     f2         i2      v2  38.2
## 5     f3         i3      v1  34.8
## 6     f3         i3      v2  36.4
## 7     f4         i4      v1  39.5
## 8     f4         i4      v2  40.0
## 9     f5         i1      v1  41.6
## 10    f5         i1      v2  40.3
## 11    f6         i2      v1  42.7
## 12    f6         i2      v2  41.6
## 13    f7         i3      v1  43.6
## 14    f7         i3      v2  42.8
## 15    f8         i4      v1  44.5
## 16    f8         i4      v2  47.6
irrigation$irrigation=as.factor(irrigation$irrigation)

ggplot(irrigation, aes(y=yield,x= irrigation,fill=irrigation))+geom_boxplot()+theme_bw()+ggtitle("Gráfico 1")

ggplot(irrigation, aes(y=yield,x= variety ,fill=variety))+geom_boxplot()+theme_bw()+ggtitle("Gráfico 2")

Como se observa en el gráfico 1 no existe una clara diferencia en los modelos de irrigación, aunque cabe resaltar que el modelo de irrigació 4 (i4) es el de mayor rendimiento. En el gráfico 2 se observa que la variedad 1 tiene mayor dispersión de datos que la variedad 2, pero tienen medias similares.

Modelo de diseño para Irrigación

irrigation$irrigation=as.factor(irrigation$irrigation)
mod1.1=lm(yield~irrigation, data=irrigation)
anova(mod1.1)
## Analysis of Variance Table
## 
## Response: yield
##            Df Sum Sq Mean Sq F value Pr(>F)
## irrigation  3  40.19  13.397  1.0699 0.3984
## Residuals  12 150.26  12.522
summary(mod1.1)
## 
## Call:
## lm(formula = yield ~ irrigation, data = irrigation)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -4.600 -3.025  0.300  2.825  4.700 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    38.800      1.769  21.930 4.75e-11 ***
## irrigationi2    1.000      2.502   0.400    0.696    
## irrigationi3    0.600      2.502   0.240    0.815    
## irrigationi4    4.100      2.502   1.639    0.127    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.539 on 12 degrees of freedom
## Multiple R-squared:  0.211,  Adjusted R-squared:  0.01378 
## F-statistic:  1.07 on 3 and 12 DF,  p-value: 0.3984
post1.0=LSD.test(mod1.1, "irrigation")
post1.0
## $statistics
##    MSerror Df   Mean       CV  t.value      LSD
##   12.52167 12 40.225 8.797009 2.178813 5.451751
## 
## $parameters
##         test p.ajusted     name.t ntr alpha
##   Fisher-LSD      none irrigation   4  0.05
## 
## $means
##    yield      std r      LCL      UCL  Min  Max    Q25   Q50    Q75
## i1  38.8 2.736177 4 34.94503 42.65497 35.4 41.6 37.275 39.10 40.625
## i2  39.8 2.817801 4 35.94503 43.65497 36.7 42.7 37.825 39.90 41.875
## i3  39.4 4.448221 4 35.54503 43.25497 34.8 43.6 36.000 39.60 43.000
## i4  42.9 3.856596 4 39.04503 46.75497 39.5 47.6 39.875 42.25 45.275
## 
## $comparison
## NULL
## 
## $groups
##    yield groups
## i4  42.9      a
## i2  39.8      a
## i3  39.4      a
## i1  38.8      a
## 
## attr(,"class")
## [1] "group"

No se observan diferencias significativas en los modelos de irrigación frente al rendimiento del cultivo. Aunque nuevamente cabe resaltar que el modelo de irrigación 4 tiene mayor porcentaje.

Modelo de diseño para la variedad

irrigation$variety=as.factor(irrigation$variety)
mod2.1=lm(yield~variety, data=irrigation)
anova(mod2.1)
## Analysis of Variance Table
## 
## Response: yield
##           Df Sum Sq Mean Sq F value Pr(>F)
## variety    1   2.25   2.250  0.1674 0.6886
## Residuals 14 188.20  13.443
summary(mod2.1)
## 
## Call:
## lm(formula = yield ~ variety, data = irrigation)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -5.050 -2.812 -0.325  2.362  7.000 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   39.850      1.296  30.742 2.98e-14 ***
## varietyv2      0.750      1.833   0.409    0.689    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.666 on 14 degrees of freedom
## Multiple R-squared:  0.01181,    Adjusted R-squared:  -0.05877 
## F-statistic: 0.1674 on 1 and 14 DF,  p-value: 0.6886
post2.1=LSD.test(mod2.1, "Variety")
post2.1
## NULL

Como se logra observar en la tabla de datos obtenidos, no existe diferencia significativa en las variedades de los cultivos que influya en el rendimiento.