#######################
##### Cid Edson #######
#######################

Gabriel

bw_ps <- list(
  plot.symbol = list(col = 1),
  box.dot = list(pch = "|"),
  box.umbrella = list(col = 1, lty = 1),
  box.rectangle = list(col = 1, fill = "seagreen")
)


dados <- read_excel("brutos.xlsx")

dados$planta <- factor(dados$planta,
                       c("P1G5", "P2G5", "P3G5", "P1G4", "P2G4", "P3G4"))

bwplot(
  area.cm ~ planta,
  dados,
  ylab = "AFR (cm²)",
  aspect = "fill",
  main = "Plantas",
  do.out = FALSE,
  par.settings = bw_ps
)

bwplot(
  area.cm ~ genotipo,
  dados,
  ylab = "AFR (cm²)",
  aspect = "fill",
  main = "Genotipo",
  do.out = FALSE,
  par.settings = bw_ps
)

g5 <-  subset(dados, planta %in% c("P1G5", "P2G5", "P3G5"))
g4 <-  subset(dados, planta %in% c("P1G4", "P2G4", "P3G4"))

bwplot(
  area.cm ~ planta,
  g4,
  ylab = "AFR (cm²)",
  aspect = "fill",
  main = "Plantas",
  do.out = FALSE,
  par.settings = bw_ps
)

bwplot(
  area.cm ~ planta,
  g5,
  ylab = "AFR (cm²)",
  aspect = "fill",
  main = "Plantas",
  do.out = FALSE,
  par.settings = bw_ps
)

comp1 <- lm(area.cm ~ comp1.cm + I(comp1.cm ^ 2), dados)
plot(
  area.cm ~ comp1.cm,
  data = dados,
  ylab = "AFR (cm²)",
  xlab = "Comprimento",
  main = "Geral",
  col = rgb(0.4, 0.4, 0.8, 0.6),
  pch = 16 ,
  cex = 1.3
)
lgraph(comp1, 2)

## 
## Call:
## lm(formula = area.cm ~ comp1.cm + I(comp1.cm^2), data = dados)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -18.1800  -1.5565   0.0145   1.7650  15.8718 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   -1.32627    1.15445  -1.149    0.251    
## comp1.cm       0.15373    0.25417   0.605    0.546    
## I(comp1.cm^2)  0.38152    0.01312  29.079   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.678 on 560 degrees of freedom
## Multiple R-squared:  0.9769, Adjusted R-squared:  0.9768 
## F-statistic: 1.182e+04 on 2 and 560 DF,  p-value: < 2.2e-16
larg1 <- lm(area.cm ~ larg1.cm + I(larg1.cm ^ 2), dados)
plot(
  area.cm ~ larg1.cm,
  data = dados,
  ylab = "AFR (cm²)",
  xlab = "Largura",
  main = "Geral",
  col = rgb(0.4, 0.4, 0.8, 0.6),
  pch = 16 ,
  cex = 1.3
)
lgraph(larg1, 2)

## 
## Call:
## lm(formula = area.cm ~ larg1.cm + I(larg1.cm^2), data = dados)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -22.2725  -1.5126  -0.0517   1.5862  15.6815 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    0.05492    0.87445   0.063   0.9499    
## larg1.cm       0.84337    0.40057   2.105   0.0357 *  
## I(larg1.cm^2)  1.42866    0.04271  33.451   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.406 on 560 degrees of freedom
## Multiple R-squared:  0.9802, Adjusted R-squared:  0.9801 
## F-statistic: 1.383e+04 on 2 and 560 DF,  p-value: < 2.2e-16
comp2 <- lm(area.cm ~ comp2.cm + I(comp2.cm ^ 2), dados)
plot(
  area.cm ~ comp2.cm,
  data = dados,
  ylab = "AFR (cm²)",
  xlab = "Comprimento",
  main = "Geral",
  col = rgb(0.4, 0.4, 0.8, 0.6),
  pch = 16 ,
  cex = 1.3
)
lgraph(comp2, 2)

## 
## Call:
## lm(formula = area.cm ~ comp2.cm + I(comp2.cm^2), data = dados)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -16.9155  -2.4601  -0.6251   2.3301  28.4228 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   -0.03888    1.49553  -0.026    0.979    
## comp2.cm       0.21659    0.30674   0.706    0.480    
## I(comp2.cm^2)  0.30967    0.01466  21.128   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.008 on 560 degrees of freedom
## Multiple R-squared:  0.9571, Adjusted R-squared:  0.957 
## F-statistic:  6249 on 2 and 560 DF,  p-value: < 2.2e-16
larg2 <- lm(area.cm ~ larg2.cm + I(larg2.cm ^ 2), dados)
plot(
  area.cm ~ larg2.cm,
  data = dados,
  ylab = "AFR (cm²)",
  xlab = "Largura",
  main = "Geral",
  col = rgb(0.4, 0.4, 0.8, 0.6),
  pch = 16 ,
  cex = 1.3
)
lgraph(larg2, 2)

## 
## Call:
## lm(formula = area.cm ~ larg2.cm + I(larg2.cm^2), data = dados)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -121.809   -2.959   -0.343    2.797   36.461 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   -11.68529    1.99567  -5.855 8.12e-09 ***
## larg2.cm        7.93674    0.88767   8.941  < 2e-16 ***
## I(larg2.cm^2)   0.53157    0.09192   5.783 1.22e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 8.333 on 560 degrees of freedom
## Multiple R-squared:  0.8812, Adjusted R-squared:  0.8808 
## F-statistic:  2078 on 2 and 560 DF,  p-value: < 2.2e-16
rlcl2 <- lm(area.cm ~ c2xl2, dados)
plot(
  area.cm ~ c2xl2,
  data = dados,
  ylab = "AFR (cm²)",
  xlab = "Comprimento x Largura",
  main = "Geral",
  col = rgb(0.4, 0.4, 0.8, 0.6),
  pch = 16 ,
  cex = 1.3
)
lgraph(rlcl2)

## 
## Call:
## lm(formula = area.cm ~ c2xl2, data = dados)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -18.5653  -1.3403  -0.2471   1.1636  25.4951 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 1.096686   0.226638   4.839 1.69e-06 ***
## c2xl2       0.703648   0.003783 186.000  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.052 on 561 degrees of freedom
## Multiple R-squared:  0.984,  Adjusted R-squared:  0.984 
## F-statistic: 3.46e+04 on 1 and 561 DF,  p-value: < 2.2e-16
t.dados <- dados[, c(2, 4, 7, 8, 9, 13, 14, 15)]
round(cor(t.dados[2:8]), 5) %>% kable
area.cm comp1.cm larg1.cm c1xl1 comp2.cm larg2.cm c2xl2
area.cm 1.00000 0.97054 0.96980 1.00000 0.96069 0.93496 0.99199
comp1.cm 0.97054 1.00000 0.96215 0.97054 0.98543 0.92391 0.96029
larg1.cm 0.96980 0.96215 1.00000 0.96980 0.95052 0.96204 0.96030
c1xl1 1.00000 0.97054 0.96980 1.00000 0.96069 0.93496 0.99199
comp2.cm 0.96069 0.98543 0.95052 0.96069 1.00000 0.91120 0.96438
larg2.cm 0.93496 0.92391 0.96204 0.93496 0.91120 1.00000 0.94837
c2xl2 0.99199 0.96029 0.96030 0.99199 0.96438 0.94837 1.00000
# Análise Geral

n.dados <- dados[, c(2, 4, 17, 20, 23)]
round(cor(n.dados[2:5]), 5) %>% kable
area.cm mod.partelli mod.barros mod.ant
area.cm 1.00000 0.97828 0.99199 0.99198
mod.partelli 0.97828 1.00000 0.98278 0.98277
mod.barros 0.99199 0.98278 1.00000 0.99999
mod.ant 0.99198 0.98277 0.99999 1.00000
partelli <- lm(area.cm ~ mod.partelli, n.dados)
plot(
  area.cm ~ mod.partelli,
  data = n.dados,
  ylab = "AFR (cm²)",
  xlab = "Modelo de Partelli",
  main = "Geral",
  col = rgb(0.4, 0.4, 0.8, 0.6),
  pch = 16 ,
  cex = 1.3
)
lgraph(partelli)

## 
## Call:
## lm(formula = area.cm ~ mod.partelli, data = n.dados)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -17.2582  -2.4650  -0.6044   2.3123  28.1486 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   1.19354    0.37469   3.185  0.00153 ** 
## mod.partelli  1.16729    0.01044 111.794  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.007 on 561 degrees of freedom
## Multiple R-squared:  0.957,  Adjusted R-squared:  0.957 
## F-statistic: 1.25e+04 on 1 and 561 DF,  p-value: < 2.2e-16
barros <- lm(area.cm ~ mod.barros, n.dados)
plot(
  area.cm ~ mod.barros,
  data = n.dados,
  ylab = "AFR (cm²)",
  xlab = "Modelo de Barros",
  main = "Geral",
  col = rgb(0.4, 0.4, 0.8, 0.6),
  pch = 16 ,
  cex = 1.3
)
lgraph(barros)

## 
## Call:
## lm(formula = area.cm ~ mod.barros, data = n.dados)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -18.5653  -1.3403  -0.2471   1.1636  25.4951 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 1.096686   0.226638   4.839 1.69e-06 ***
## mod.barros  1.054944   0.005672 186.000  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.052 on 561 degrees of freedom
## Multiple R-squared:  0.984,  Adjusted R-squared:  0.984 
## F-statistic: 3.46e+04 on 1 and 561 DF,  p-value: < 2.2e-16
ant <- lm(area.cm ~ mod.ant, n.dados)
plot(
  area.cm ~ mod.ant,
  data = n.dados,
  ylab = "AFR (cm²)",
  xlab = "Modelo de Antunes",
  main = "Geral",
  col = rgb(0.4, 0.4, 0.8, 0.6),
  pch = 16 ,
  cex = 1.3
)
lgraph(ant)

## 
## Call:
## lm(formula = area.cm ~ mod.ant, data = n.dados)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -18.4967  -1.3755  -0.2706   1.1817  25.4028 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 1.454754   0.225132   6.462 2.25e-10 ***
## mod.ant     1.001808   0.005388 185.936  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.053 on 561 degrees of freedom
## Multiple R-squared:  0.984,  Adjusted R-squared:  0.984 
## F-statistic: 3.457e+04 on 1 and 561 DF,  p-value: < 2.2e-16
# Genotipo 5

n.g5 <-  subset(n.dados, genotipo %in% "G5")
round(cor(n.g5[2:5]), 5) %>% kable
area.cm mod.partelli mod.barros mod.ant
area.cm 1.00000 0.98087 0.99470 0.99464
mod.partelli 0.98087 1.00000 0.98391 0.98396
mod.barros 0.99470 0.98391 1.00000 0.99999
mod.ant 0.99464 0.98396 0.99999 1.00000
part.g5 <- lm(area.cm ~ mod.partelli, n.g5)
plot(
  area.cm ~ mod.partelli,
  data = n.g5,
  ylab = "AFR (cm²)",
  xlab = "Modelo de Partelli",
  main = "G5",
  col = rgb(0.4, 0.4, 0.8, 0.6),
  pch = 16 ,
  cex = 1.3
)
lgraph(part.g5)

## 
## Call:
## lm(formula = area.cm ~ mod.partelli, data = n.g5)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -9.655 -2.512 -0.538  2.351 15.258 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   1.25558    0.46822   2.682  0.00774 ** 
## mod.partelli  1.17269    0.01348  86.992  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.405 on 298 degrees of freedom
## Multiple R-squared:  0.9621, Adjusted R-squared:  0.962 
## F-statistic:  7568 on 1 and 298 DF,  p-value: < 2.2e-16
barros.g5 <- lm(area.cm ~ mod.barros, n.g5)
plot(
  area.cm ~ mod.barros,
  data = n.g5,
  ylab = "AFR (cm²)",
  xlab = "Modelo de Barros",
  main = "G5",
  col = rgb(0.4, 0.4, 0.8, 0.6),
  pch = 16 ,
  cex = 1.3
)
lgraph(barros.g5)

## 
## Call:
## lm(formula = area.cm ~ mod.barros, data = n.g5)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -16.338  -1.186  -0.159   1.083   8.162 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 1.201309   0.245284   4.898 1.59e-06 ***
## mod.barros  1.050661   0.006294 166.937  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.328 on 298 degrees of freedom
## Multiple R-squared:  0.9894, Adjusted R-squared:  0.9894 
## F-statistic: 2.787e+04 on 1 and 298 DF,  p-value: < 2.2e-16
ant.g5 <- lm(area.cm ~ mod.ant, n.g5)
plot(
  area.cm ~ mod.ant,
  data = n.g5,
  ylab = "Area em cm²",
  xlab = "Modelo de Antunes",
  main = "G5",
  col = rgb(0.4, 0.4, 0.8, 0.6),
  pch = 16 ,
  cex = 1.3
)
lgraph(ant.g5)

## 
## Call:
## lm(formula = area.cm ~ mod.ant, data = n.g5)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -16.2813  -1.1767  -0.1404   1.1236   8.2283 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 1.539787   0.244940   6.286 1.15e-09 ***
## mod.ant     0.998470   0.006014 166.014  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.341 on 298 degrees of freedom
## Multiple R-squared:  0.9893, Adjusted R-squared:  0.9893 
## F-statistic: 2.756e+04 on 1 and 298 DF,  p-value: < 2.2e-16
# Genotipo 4

n.g4 <-  subset(n.dados, genotipo %in% "G4")
round(cor(n.g4[2:5]), 5)  %>% kable
area.cm mod.partelli mod.barros mod.ant
area.cm 1.00000 0.97611 0.98963 0.98967
mod.partelli 0.97611 1.00000 0.98197 0.98189
mod.barros 0.98963 0.98197 1.00000 0.99999
mod.ant 0.98967 0.98189 0.99999 1.00000
part.g4 <- lm(area.cm ~ mod.partelli, n.g4)

plot(
  area.cm ~ mod.partelli,
  data = n.g4,
  ylab = "AFR (cm²)",
  xlab = "Modelo de Partelli",
  main = "G4",
  col = rgb(0.4, 0.4, 0.8, 0.6),
  pch = 16 ,
  cex = 1.3
)
lgraph(part.g4)

## 
## Call:
## lm(formula = area.cm ~ mod.partelli, data = n.g4)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -16.8149  -2.7079  -0.7533   2.0936  28.3016 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   1.06773    0.59540   1.793   0.0741 .  
## mod.partelli  1.16316    0.01602  72.584   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.622 on 261 degrees of freedom
## Multiple R-squared:  0.9528, Adjusted R-squared:  0.9526 
## F-statistic:  5268 on 1 and 261 DF,  p-value: < 2.2e-16
barros.g4 <- lm(area.cm ~ mod.barros, n.g4)
plot(
  area.cm ~ mod.barros,
  data = n.g4,
  ylab = "AFR (cm²)",
  xlab = "Modelo de Barros",
  main = "G4",
  col = rgb(0.4, 0.4, 0.8, 0.6),
  pch = 16 ,
  cex = 1.3
)
lgraph(barros.g4)

## 
## Call:
## lm(formula = area.cm ~ mod.barros, data = n.g4)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -18.5749  -1.5553  -0.5546   1.2580  25.5466 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 1.010525   0.390483   2.588   0.0102 *  
## mod.barros  1.058737   0.009511 111.315   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.716 on 261 degrees of freedom
## Multiple R-squared:  0.9794, Adjusted R-squared:  0.9793 
## F-statistic: 1.239e+04 on 1 and 261 DF,  p-value: < 2.2e-16
ant.g4 <- lm(area.cm ~ mod.ant, n.g4)
plot(
  area.cm ~ mod.ant,
  data = n.g4,
  ylab = "AFR (cm²)",
  xlab = "Modelo de Antunes",
  main = "G4",
  col = rgb(0.4, 0.4, 0.8, 0.6),
  pch = 16 ,
  cex = 1.3
)
lgraph(ant.g4)

## 
## Call:
## lm(formula = area.cm ~ mod.ant, data = n.g4)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -18.504  -1.556  -0.550   1.326  25.445 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1.38495    0.38708   3.578 0.000413 ***
## mod.ant      1.00475    0.00901 111.513  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.71 on 261 degrees of freedom
## Multiple R-squared:  0.9794, Adjusted R-squared:  0.9794 
## F-statistic: 1.244e+04 on 1 and 261 DF,  p-value: < 2.2e-16
# Médias

exper <- aggregate(area.cm ~ planta + genotipo, dados, "mean")
exper1 <- aggregate(mod.partelli ~ planta + genotipo, dados, "mean")
exper2 <- aggregate(mod.barros ~ planta + genotipo, dados, "mean")
exper3 <- aggregate(mod.ant ~ planta + genotipo, dados, "mean")
exper["mod.partelli"] <- exper1$mod.partelli
exper["mod.barros"] <- exper2$mod.barros
exper["mod.ant"] <- exper3$mod.ant
exper  %>% kable
planta genotipo area.cm mod.partelli mod.barros mod.ant
P1G4 G4 34.68046 28.20471 31.90906 33.24395
P2G4 G4 38.08838 32.18461 35.38572 36.89749
P3G4 G4 35.87663 30.23328 32.50040 33.89551
P1G5 G5 34.64459 28.15157 31.39429 32.67379
P2G5 G5 35.64597 30.05642 32.89590 34.31727
P3G5 G5 36.16997 29.44693 33.65887 35.06601