Walmes Zeviani
Milson Evaldo Serafim
Materiais e métodos
O experimento avaliou 3 fatores:
Os níveis foram completamente cruzados perfazendo 2*2*7=28
combinações
experimentais. O experimento foi instalado em delineamento de blocos
casualizados com 3 blocos.
Em termos de planejamento, blocos com esse tamanho (28 unidades por bloco) dificilmente cumprem com eficiência o seu propósito: ter unidades experimentais uniformes mantidas em condições uniformes durante o período experimental. Experimentos futuros com tantas combinações devem ser intalados em blocos incompletos ou em delineamento inteiramente casualizado. Como será visto, a maioria dos quadros de anova aponta não haver efeito de blocos o que leva a pensar: 1) é necessário fazer blocagem? 2) será que a blocagem foi aplicada com eficiência? Como o tamanho do bloco é grande, parece a segunda questão seja mais apropriada.
Cada variável química do solo foi analisada separadamente (análise
univariada) sendo submetida à análise de variância de acordo com o
modelo experimental correspondente ao fatorial triplo em blocos. O
efeito dos fatores experimentais foi testado pelo valor de F da análise
de variância. Análise dos resíduos foi feita para certificar-se do
atendimento dos pressupostos. Havendo fugas dos pressupostos, baseado no
padrão dos resíduos procedeu-se com 1) tranformação dos dados pela
família de transformações
Box-Cox
ou 2) remoção de observações influentes segundo o critério
DFfits. Na presença de interações
significativas preconizou-se o estudo da interação na seguinte order de
interesse: agregado > família > cinza. Sendo assim, se a interação
agragado e família for significativa, por exemplo, serão estudados os
níveis de agragado para níveis fixados de família. Para comparações
múltiplas considerou-se o método single-step
para correção de
p-valores após os contrastes entre médias. Todas as inferências foram
conduzidas com um nível nominal de significância de 5%.
Referências
Box, G. E. P. and Cox, D. R. (1964). An analysis of transformations, Journal of the Royal Statistical Society, Series B, 26, 211-252.
Cook, R. D. and Weisber,g S. (1982). Residuals and Influence in Regression. London: Chapman and Hall.
##-----------------------------------------------------------------------------
## Definições da sessão, pacotes a serem usados.
pkg <- c("lattice", "latticeExtra", "reshape",
"doBy", "multcomp",
"plyr", "wzRfun")
sapply(pkg, library, character.only=TRUE, logical.return=TRUE)
## lattice latticeExtra reshape doBy multcomp plyr
## TRUE TRUE TRUE TRUE TRUE TRUE
## wzRfun
## TRUE
source("lattice_setup.R")
##-----------------------------------------------------------------------------
## Informações sobre as versões dos pacotes.
sessionInfo()
## R version 3.1.1 (2014-07-10)
## Platform: i686-pc-linux-gnu (32-bit)
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=pt_BR.UTF-8
## [4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=pt_BR.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=pt_BR.UTF-8 LC_NAME=C LC_ADDRESS=C
## [10] LC_TELEPHONE=C LC_MEASUREMENT=pt_BR.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] splines stats graphics grDevices utils datasets base
##
## other attached packages:
## [1] wzRfun_0.1 plyr_1.8.1 multcomp_1.3-3 TH.data_1.0-3
## [5] mvtnorm_0.9-99992 doBy_4.5-10 MASS_7.3-33 survival_2.37-7
## [9] reshape_0.8.5 latticeExtra_0.6-26 RColorBrewer_1.0-5 lattice_0.20-29
## [13] knitr_1.5
##
## loaded via a namespace (and not attached):
## [1] evaluate_0.5.5 formatR_0.10 grid_3.1.1 lme4_1.1-6
## [5] Matrix_1.1-4 methods_3.1.1 minqa_1.2.3 nlme_3.1-117
## [9] Rcpp_0.11.1 RcppEigen_0.3.2.1.2 sandwich_2.3-0 stringr_0.6.2
## [13] tools_3.1.1 zoo_1.7-11
## obs: Para instalar um pacote faça:
## install.packages("nome_do_pacote", dependencies=TRUE)
Leitura e análise preliminar dos dados
##-----------------------------------------------------------------------------
## Ler.
url <- "http://www.leg.ufpr.br/~walmes/data/maracuja_cinza.txt"
da <- read.table(url, header=TRUE, sep="\t")
str(da)
## 'data.frame': 84 obs. of 22 variables:
## $ agreg : Factor w/ 2 levels "[0,2]","[4,10]": 2 2 2 2 2 2 2 2 2 2 ...
## $ fam : Factor w/ 2 levels "F29","F48": 1 1 1 1 1 1 1 1 1 1 ...
## $ cinz : num 0 0 0 1.5 1.5 1.5 3 3 3 6 ...
## $ bloc : int 1 2 3 1 2 3 1 2 3 1 ...
## $ mfpa : num 43.5 31.8 36.4 28 52.2 ...
## $ mspa : num 11.1 8.24 9.04 6.25 13.12 ...
## $ ds : num 1.24 1.23 1.27 1.27 1.01 1.26 1.24 1.24 1.25 1.2 ...
## $ agua : int 6470 9446 8468 8550 5679 7657 5801 6298 6754 5644 ...
## $ phh2o : num 6.6 6.5 6.7 6.4 6.5 6.7 6.4 6.6 6.6 6.7 ...
## $ phkcl : num 4.5 5.1 5.3 4.6 5.1 5.3 4.7 5.1 5.3 4.8 ...
## $ pcz : num 2.4 3.7 3.9 2.8 3.7 3.9 3 3.6 4 2.9 ...
## $ P : num 88 64.6 145.9 68.4 63.5 ...
## $ K : num 58 78.4 68.1 40.8 56.1 ...
## $ CaMg : num 4.9 4.9 5.5 6.3 6.3 5.3 5.5 5.5 5.7 5.9 ...
## $ Ca : num 3.8 3.9 3.8 5.2 4.1 3.6 4.3 4.2 3.8 4.9 ...
## $ Mg : num 1.1 1 1.7 1.1 2.2 1.7 1.2 1.3 1.9 1 ...
## $ Hal : num 3.6 3.3 3.6 3.2 3.3 3.6 4.5 3.3 3.7 4 ...
## $ mo : num 0.8 0.9 0.7 0.9 0.9 0.9 0.9 1.1 1.1 1 ...
## $ sb : num 5.05 5.1 5.67 6.4 6.44 5.5 5.7 5.67 5.92 6.04 ...
## $ ctc7 : num 8.67 8.42 9.27 9.64 9.76 ...
## $ ctcefet: num 5.05 5.1 5.67 6.4 6.44 5.5 5.7 5.67 5.92 6.04 ...
## $ V : num 58.3 60.6 61.2 66.4 66 ...
##-----------------------------------------------------------------------------
## Editar.
da$bloc <- factor(da$bloc)
da$Cinz <- factor(da$cinz)
##-----------------------------------------------------------------------------
## Escala com níveis equidistântes para o efeito de cinza.
un <- sort(unique(da$cinz))/(1.5/2)
base <- 2
cbind(un, "log"=log(un, base=base),
"log*"=ifelse(un>0, log(un, base=base), 0))
## un log log*
## [1,] 0 -Inf 0
## [2,] 2 1 1
## [3,] 4 2 2
## [4,] 8 3 3
## [5,] 16 4 4
## [6,] 32 5 5
## [7,] 64 6 6
## Logaritmo da cinza na base 2.
da$lcinz <- ifelse(da$cinz>0, log(da$cinz/(1.5/2), base=base), 0)
##-----------------------------------------------------------------------------
## Tabela de frequência dos fatores.
ftable(cinz~fam+agreg, data=da)
## cinz 0 1.5 3 6 12 24 48
## fam agreg
## F29 [0,2] 3 3 3 3 3 3 3
## [4,10] 3 3 3 3 3 3 3
## F48 [0,2] 3 3 3 3 3 3 3
## [4,10] 3 3 3 3 3 3 3
##-----------------------------------------------------------------------------
## Legenda dos fatores nos gráficos.
lab.fam <- "Família de maracujá"
lab.agreg <- expression("Tamanho de agregados"~(mm))
lab.cinz <- expression("Dose de cinza"~(ton~ha^{-1}))
lab.lcinz <- expression(log[2]~"da dose de cinza/0.75"~(ton~ha^{-1}))
##-----------------------------------------------------------------------------
## Preliminar.
ylab <- "pH em água"
da$y <- da$phh2o
db <- da[!is.na(da$y),]
xyplot(y~lcinz|agreg, groups=fam, data=db,
auto.key=list(columns=2, title=lab.fam, cex.title=1.1),
jitter.x=TRUE, type=c("p","a"), layout=c(2,NA),
ylab=ylab, xlab=lab.lcinz)
##-----------------------------------------------------------------------------
## Modelo.
m0 <- lm(y~bloc+agreg*fam*Cinz, data=db)
m1 <- lm(y~bloc+agreg*fam*lcinz, data=db)
## Diagnóstico dos resíduos.
par(mfrow=c(2,2)); plot(m0); layout(1)
## Quadro de anova.
anova(m0)
## Analysis of Variance Table
##
## Response: y
## Df Sum Sq Mean Sq F value Pr(>F)
## bloc 2 0.011 0.0057 0.43 0.654
## agreg 1 0.008 0.0076 0.57 0.454
## fam 1 0.039 0.0386 2.89 0.095 .
## Cinz 6 0.080 0.0133 0.99 0.439
## agreg:fam 1 0.012 0.0119 0.89 0.350
## agreg:Cinz 6 0.061 0.0101 0.76 0.607
## fam:Cinz 6 0.120 0.0200 1.49 0.198
## agreg:fam:Cinz 6 0.060 0.0100 0.75 0.616
## Residuals 54 0.722 0.0134
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(m0, m1)
## Analysis of Variance Table
##
## Model 1: y ~ bloc + agreg * fam * Cinz
## Model 2: y ~ bloc + agreg * fam * lcinz
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 54 0.722
## 2 74 0.926 -20 -0.204 0.76 0.74
##-----------------------------------------------------------------------------
## Médias ajustadas e comparações múltiplas.
lsma <- LSmeans(m0, effect="agreg")
lsma <- cbind(lsma$grid, lsma$coef)
lsma <- equallevels(lsma, db)
lsma
## agreg estimate se df t.stat p.value lwr upr
## 1 [0,2] 6.519 0.01784 54 365.4 2.596e-93 6.483 6.555
## 2 [4,10] 6.538 0.01784 54 366.5 2.218e-93 6.502 6.574
lsmf <- LSmeans(m0, effect="fam")
lsmf <- cbind(lsmf$grid, lsmf$coef)
lsmf <- equallevels(lsmf, db)
lsmf
## fam estimate se df t.stat p.value lwr upr
## 1 F29 6.550 0.01784 54 367.1 2.011e-93 6.514 6.586
## 2 F48 6.507 0.01784 54 364.7 2.866e-93 6.471 6.543
lsmc <- LSmeans(m0, effect="Cinz")
lsmc <- cbind(lsmc$grid, lsmc$coef)
lsmc <- equallevels(lsmc, db)
lsmc
## Cinz estimate se df t.stat p.value lwr upr
## 1 0 6.542 0.03338 54 196.0 1.027e-78 6.475 6.609
## 2 1.5 6.567 0.03338 54 196.7 8.358e-79 6.500 6.634
## 3 3 6.550 0.03338 54 196.2 9.586e-79 6.483 6.617
## 4 6 6.550 0.03338 54 196.2 9.586e-79 6.483 6.617
## 5 12 6.483 0.03338 54 194.2 1.664e-78 6.416 6.550
## 6 24 6.483 0.03338 54 194.2 1.664e-78 6.416 6.550
## 7 48 6.525 0.03338 54 195.5 1.178e-78 6.458 6.592
##-----------------------------------------------------------------------------
## Gráficos.
p1 <-
segplot(agreg~lwr+upr, centers=estimate,
data=lsma, draw=FALSE,
xlab=ylab, ylab=lab.agreg)
p2 <-
segplot(fam~lwr+upr, centers=estimate,
data=lsmf, draw=FALSE,
xlab=ylab, ylab=lab.fam)
p3 <-
segplot(Cinz~lwr+upr, centers=estimate,
data=lsmc, draw=FALSE,
xlab=ylab, ylab=lab.cinz)
plot(p1, split=c(1,1,2,2), more=TRUE)
plot(p2, split=c(2,1,2,2), more=TRUE)
plot(p3, split=c(1,2,1,2), more=FALSE)
##-----------------------------------------------------------------------------
## Preliminar.
ylab <- "pH em KCl"
da$y <- da$phkcl
db <- da[!is.na(da$y),]
xyplot(y~lcinz|agreg, groups=fam, data=db,
auto.key=list(columns=2, title=lab.fam, cex.title=1.1),
jitter.x=TRUE, type=c("p","a"), layout=c(2,NA),
ylab=ylab, xlab=lab.lcinz)
##-----------------------------------------------------------------------------
## Modelo.
m0 <- lm(y~bloc+agreg*fam*Cinz, data=db)
m1 <- lm(y~bloc+agreg*fam*lcinz, data=db)
## Diagnóstico dos resíduos.
par(mfrow=c(2,2)); plot(m0); layout(1)
## Quadro de anova.
anova(m0)
## Analysis of Variance Table
##
## Response: y
## Df Sum Sq Mean Sq F value Pr(>F)
## bloc 2 1.125 0.562 32.96 4.4e-10 ***
## agreg 1 0.322 0.322 18.86 6.2e-05 ***
## fam 1 0.039 0.039 2.26 0.14
## Cinz 6 0.029 0.005 0.28 0.94
## agreg:fam 1 0.008 0.008 0.45 0.51
## agreg:Cinz 6 0.025 0.004 0.24 0.96
## fam:Cinz 6 0.028 0.005 0.27 0.95
## agreg:fam:Cinz 6 0.039 0.007 0.38 0.89
## Residuals 54 0.922 0.017
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(m0, m1)
## Analysis of Variance Table
##
## Model 1: y ~ bloc + agreg * fam * Cinz
## Model 2: y ~ bloc + agreg * fam * lcinz
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 54 0.922
## 2 74 1.022 -20 -0.101 0.3 1
##-----------------------------------------------------------------------------
## Médias ajustadas e comparações múltiplas.
lsma <- LSmeans(m0, effect="agreg")
lsma <- cbind(lsma$grid, lsma$coef)
lsma <- equallevels(lsma, db)
lsma
## agreg estimate se df t.stat p.value lwr upr
## 1 [0,2] 5.155 0.02016 54 255.7 6.036e-85 5.114 5.195
## 2 [4,10] 5.031 0.02016 54 249.6 2.241e-84 4.991 5.071
lsmf <- LSmeans(m0, effect="fam")
lsmf <- cbind(lsmf$grid, lsmf$coef)
lsmf <- equallevels(lsmf, db)
lsmf
## fam estimate se df t.stat p.value lwr upr
## 1 F29 5.071 0.02016 54 251.6 1.454e-84 5.031 5.112
## 2 F48 5.114 0.02016 54 253.7 9.235e-85 5.074 5.155
lsmc <- LSmeans(m0, effect="Cinz")
lsmc <- cbind(lsmc$grid, lsmc$coef)
lsmc <- equallevels(lsmc, db)
lsmc
## Cinz estimate se df t.stat p.value lwr upr
## 1 0 5.092 0.03771 54 135.0 5.430e-70 5.016 5.167
## 2 1.5 5.092 0.03771 54 135.0 5.430e-70 5.016 5.167
## 3 3 5.058 0.03771 54 134.1 7.734e-70 4.983 5.134
## 4 6 5.100 0.03771 54 135.2 4.973e-70 5.024 5.176
## 5 12 5.083 0.03771 54 134.8 5.931e-70 5.008 5.159
## 6 24 5.100 0.03771 54 135.2 4.973e-70 5.024 5.176
## 7 48 5.125 0.03771 54 135.9 3.822e-70 5.049 5.201
##-----------------------------------------------------------------------------
## Gráficos.
p1 <-
segplot(agreg~lwr+upr, centers=estimate,
data=lsma, draw=FALSE,
xlab=ylab, ylab=lab.agreg)
p2 <-
segplot(fam~lwr+upr, centers=estimate,
data=lsmf, draw=FALSE,
xlab=ylab, ylab=lab.fam)
p3 <-
segplot(Cinz~lwr+upr, centers=estimate,
data=lsmc, draw=FALSE,
xlab=ylab, ylab=lab.cinz)
plot(p1, split=c(1,1,2,2), more=TRUE)
plot(p2, split=c(2,1,2,2), more=TRUE)
plot(p3, split=c(1,2,1,2), more=FALSE)
##-----------------------------------------------------------------------------
## Preliminar.
ylab <- "Ponto de carga zero"
da$y <- da$pcz
db <- da[!is.na(da$y),]
xyplot(y~lcinz|agreg, groups=fam, data=db,
auto.key=list(columns=2, title=lab.fam, cex.title=1.1),
jitter.x=TRUE, type=c("p","a"), layout=c(2,NA),
ylab=ylab, xlab=lab.lcinz)
##-----------------------------------------------------------------------------
## Modelo.
m0 <- lm(y~bloc+agreg*fam*Cinz, data=db)
m1 <- lm(y~bloc+agreg*fam*lcinz, data=db)
## Diagnóstico dos resíduos.
par(mfrow=c(2,2)); plot(m0); layout(1)
## Quadro de anova.
anova(m0)
## Analysis of Variance Table
##
## Response: y
## Df Sum Sq Mean Sq F value Pr(>F)
## bloc 2 4.60 2.299 35.23 1.6e-10 ***
## agreg 1 1.49 1.493 22.89 1.4e-05 ***
## fam 1 0.35 0.347 5.32 0.025 *
## Cinz 6 0.23 0.038 0.58 0.744
## agreg:fam 1 0.00 0.004 0.07 0.799
## agreg:Cinz 6 0.23 0.038 0.58 0.742
## fam:Cinz 6 0.18 0.031 0.47 0.827
## agreg:fam:Cinz 6 0.10 0.017 0.26 0.954
## Residuals 54 3.52 0.065
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(m0, m1)
## Analysis of Variance Table
##
## Model 1: y ~ bloc + agreg * fam * Cinz
## Model 2: y ~ bloc + agreg * fam * lcinz
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 54 3.52
## 2 74 4.12 -20 -0.593 0.45 0.97
##-----------------------------------------------------------------------------
## Médias ajustadas e comparações múltiplas.
lsma <- LSmeans(m0, effect="agreg")
lsma <- cbind(lsma$grid, lsma$coef)
lsma <- equallevels(lsma, db)
lsma
## agreg estimate se df t.stat p.value lwr upr
## 1 [0,2] 3.790 0.03941 54 96.18 4.526e-62 3.711 3.869
## 2 [4,10] 3.524 0.03941 54 89.41 2.270e-60 3.445 3.603
lsmf <- LSmeans(m0, effect="fam")
lsmf <- cbind(lsmf$grid, lsmf$coef)
lsmf <- equallevels(lsmf, db)
lsmf
## fam estimate se df t.stat p.value lwr upr
## 1 F29 3.593 0.03941 54 91.16 8.013e-61 3.514 3.672
## 2 F48 3.721 0.03941 54 94.42 1.214e-61 3.642 3.800
lsmc <- LSmeans(m0, effect="Cinz")
lsmc <- cbind(lsmc$grid, lsmc$coef)
lsmc <- equallevels(lsmc, db)
lsmc
## Cinz estimate se df t.stat p.value lwr upr
## 1 0 3.642 0.07373 54 49.39 1.258e-46 3.494 3.789
## 2 1.5 3.617 0.07373 54 49.05 1.810e-46 3.469 3.764
## 3 3 3.567 0.07373 54 48.37 3.776e-46 3.419 3.714
## 4 6 3.650 0.07373 54 49.50 1.115e-46 3.502 3.798
## 5 12 3.683 0.07373 54 49.96 6.894e-47 3.536 3.831
## 6 24 3.717 0.07373 54 50.41 4.281e-47 3.569 3.864
## 7 48 3.725 0.07373 54 50.52 3.802e-47 3.577 3.873
##-----------------------------------------------------------------------------
## Gráficos.
p1 <-
segplot(agreg~lwr+upr, centers=estimate,
data=lsma, draw=FALSE,
xlab=ylab, ylab=lab.agreg)
p2 <-
segplot(fam~lwr+upr, centers=estimate,
data=lsmf, draw=FALSE,
xlab=ylab, ylab=lab.fam)
p3 <-
segplot(Cinz~lwr+upr, centers=estimate,
data=lsmc, draw=FALSE,
xlab=ylab, ylab=lab.cinz)
plot(p1, split=c(1,1,2,2), more=TRUE)
plot(p2, split=c(2,1,2,2), more=TRUE)
plot(p3, split=c(1,2,1,2), more=FALSE)
##-----------------------------------------------------------------------------
## Preliminar.
ylab <- "log do Fósforo"
da$y <- log10(da$P)
db <- da[!is.na(da$y),]
xyplot(y~lcinz|agreg, groups=fam, data=db,
auto.key=list(columns=2, title=lab.fam, cex.title=1.1),
jitter.x=TRUE, type=c("p","a"), layout=c(2,NA),
ylab=ylab, xlab=lab.lcinz)
##-----------------------------------------------------------------------------
## Modelo.
m0 <- lm(y~bloc+agreg*fam*Cinz, data=db)
m1 <- lm(y~bloc+agreg*fam*lcinz, data=db)
## Diagnóstico dos resíduos.
par(mfrow=c(2,2)); plot(m0); layout(1)
## Quadro de anova.
anova(m0)
## Analysis of Variance Table
##
## Response: y
## Df Sum Sq Mean Sq F value Pr(>F)
## bloc 2 0.112 0.0562 2.81 0.0689 .
## agreg 1 0.055 0.0548 2.74 0.1036
## fam 1 0.178 0.1779 8.90 0.0043 **
## Cinz 6 0.152 0.0254 1.27 0.2867
## agreg:fam 1 0.016 0.0159 0.79 0.3767
## agreg:Cinz 6 0.078 0.0129 0.65 0.6924
## fam:Cinz 6 0.125 0.0208 1.04 0.4079
## agreg:fam:Cinz 6 0.046 0.0076 0.38 0.8885
## Residuals 54 1.079 0.0200
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(m0, m1)
## Analysis of Variance Table
##
## Model 1: y ~ bloc + agreg * fam * Cinz
## Model 2: y ~ bloc + agreg * fam * lcinz
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 54 1.08
## 2 74 1.37 -20 -0.288 0.72 0.79
##-----------------------------------------------------------------------------
## Médias ajustadas e comparações múltiplas.
lsma <- LSmeans(m0, effect="agreg")
lsma <- cbind(lsma$grid, lsma$coef)
lsma <- equallevels(lsma, db)
lsma
## agreg estimate se df t.stat p.value lwr upr
## 1 [0,2] 1.963 0.02181 54 90.02 1.581e-60 1.920 2.007
## 2 [4,10] 1.912 0.02181 54 87.67 6.496e-60 1.869 1.956
lsmf <- LSmeans(m0, effect="fam")
lsmf <- cbind(lsmf$grid, lsmf$coef)
lsmf <- equallevels(lsmf, db)
lsmf
## fam estimate se df t.stat p.value lwr upr
## 1 F29 1.892 0.02181 54 86.74 1.157e-59 1.848 1.936
## 2 F48 1.984 0.02181 54 90.95 9.057e-61 1.940 2.028
lsmc <- LSmeans(m0, effect="Cinz")
lsmc <- cbind(lsmc$grid, lsmc$coef)
lsmc <- equallevels(lsmc, db)
lsmc
## Cinz estimate se df t.stat p.value lwr upr
## 1 0 1.938 0.04081 54 47.49 1.001e-45 1.856 2.020
## 2 1.5 1.886 0.04081 54 46.21 4.195e-45 1.804 1.968
## 3 3 1.868 0.04081 54 45.78 6.895e-45 1.786 1.950
## 4 6 1.975 0.04081 54 48.40 3.674e-46 1.893 2.057
## 5 12 1.993 0.04081 54 48.85 2.248e-46 1.912 2.075
## 6 24 1.963 0.04081 54 48.11 5.026e-46 1.881 2.045
## 7 48 1.942 0.04081 54 47.58 9.001e-46 1.860 2.024
##-----------------------------------------------------------------------------
## Gráficos.
p1 <-
segplot(agreg~lwr+upr, centers=estimate,
data=lsma, draw=FALSE,
xlab=ylab, ylab=lab.agreg)
p2 <-
segplot(fam~lwr+upr, centers=estimate,
data=lsmf, draw=FALSE,
xlab=ylab, ylab=lab.fam)
p3 <-
segplot(Cinz~lwr+upr, centers=estimate,
data=lsmc, draw=FALSE,
xlab=ylab, ylab=lab.cinz)
plot(p1, split=c(1,1,2,2), more=TRUE)
plot(p2, split=c(2,1,2,2), more=TRUE)
plot(p3, split=c(1,2,1,2), more=FALSE)
##-----------------------------------------------------------------------------
## Preliminar.
ylab <- "log do Potássio"
da$y <- log10(da$K)
db <- da[!is.na(da$y),]
xyplot(y~lcinz|agreg, groups=fam, data=db,
auto.key=list(columns=2, title=lab.fam, cex.title=1.1),
jitter.x=TRUE, type=c("p","a"), layout=c(2,NA),
ylab=ylab, xlab=lab.lcinz)
##-----------------------------------------------------------------------------
## Modelo.
m0 <- lm(y~bloc+agreg*fam*Cinz, data=db)
m1 <- lm(y~bloc+agreg*fam*lcinz, data=db)
## Diagnóstico dos resíduos.
par(mfrow=c(2,2)); plot(m0); layout(1)
## Quadro de anova.
anova(m0)
## Analysis of Variance Table
##
## Response: y
## Df Sum Sq Mean Sq F value Pr(>F)
## bloc 2 0.003 0.002 0.09 0.9178
## agreg 1 0.014 0.014 0.75 0.3917
## fam 1 0.744 0.744 39.69 5.6e-08 ***
## Cinz 6 0.417 0.069 3.71 0.0037 **
## agreg:fam 1 0.027 0.027 1.45 0.2338
## agreg:Cinz 6 0.055 0.009 0.49 0.8105
## fam:Cinz 6 0.241 0.040 2.14 0.0635 .
## agreg:fam:Cinz 6 0.118 0.020 1.05 0.4039
## Residuals 54 1.012 0.019
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(m0, m1)
## Analysis of Variance Table
##
## Model 1: y ~ bloc + agreg * fam * Cinz
## Model 2: y ~ bloc + agreg * fam * lcinz
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 54 1.01
## 2 74 1.37 -20 -0.358 0.96 0.53
anova(m1)
## Analysis of Variance Table
##
## Response: y
## Df Sum Sq Mean Sq F value Pr(>F)
## bloc 2 0.003 0.002 0.09 0.917
## agreg 1 0.014 0.014 0.75 0.388
## fam 1 0.744 0.744 40.17 1.6e-08 ***
## lcinz 1 0.359 0.359 19.40 3.5e-05 ***
## agreg:fam 1 0.027 0.027 1.47 0.230
## agreg:lcinz 1 0.000 0.000 0.00 0.947
## fam:lcinz 1 0.064 0.064 3.46 0.067 .
## agreg:fam:lcinz 1 0.049 0.049 2.66 0.107
## Residuals 74 1.370 0.019
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##-----------------------------------------------------------------------------
## Médias ajustadas e comparações múltiplas.
lsma <- LSmeans(m0, effect="agreg")
lsma <- cbind(lsma$grid, lsma$coef)
lsma <- equallevels(lsma, db)
lsma
## agreg estimate se df t.stat p.value lwr upr
## 1 [0,2] 1.961 0.02112 54 92.84 3.008e-61 1.919 2.003
## 2 [4,10] 1.935 0.02112 54 91.62 6.121e-61 1.893 1.977
lsmf <- LSmeans(m0, effect="fam")
lsmf <- cbind(lsmf$grid, lsmf$coef)
lsmf <- equallevels(lsmf, db)
lsmf
## fam estimate se df t.stat p.value lwr upr
## 1 F29 1.854 0.02112 54 87.78 6.103e-60 1.812 1.896
## 2 F48 2.042 0.02112 54 96.69 3.407e-62 2.000 2.084
lsmc <- LSmeans(m0, effect="Cinz")
lsmc <- cbind(lsmc$grid, lsmc$coef)
lsmc <- equallevels(lsmc, db)
lsmc
## Cinz estimate se df t.stat p.value lwr upr
## 1 0 1.865 0.03951 54 47.21 1.363e-45 1.786 1.945
## 2 1.5 1.876 0.03951 54 47.48 1.015e-45 1.797 1.955
## 3 3 1.883 0.03951 54 47.65 8.348e-46 1.804 1.962
## 4 6 1.946 0.03951 54 49.24 1.473e-46 1.867 2.025
## 5 12 1.997 0.03951 54 50.54 3.743e-47 1.918 2.076
## 6 24 2.058 0.03951 54 52.08 7.604e-48 1.979 2.137
## 7 48 2.011 0.03951 54 50.90 2.553e-47 1.932 2.091
##-----------------------------------------------------------------------------
## Estimativas com bandas.
pred <- with(da,
expand.grid(
fam=levels(fam),
agreg=levels(agreg),
bloc=levels(bloc)[1],
lcinz=seq(0, 5, length.out=25)))
aux <- predict(m1, newdata=pred, interval="confidence")
pred <- cbind(pred, aux)
str(pred)
## 'data.frame': 100 obs. of 7 variables:
## $ fam : Factor w/ 2 levels "F29","F48": 1 2 1 2 1 2 1 2 1 2 ...
## $ agreg: Factor w/ 2 levels "[0,2]","[4,10]": 1 1 2 2 1 1 2 2 1 1 ...
## $ bloc : Factor w/ 1 level "1": 1 1 1 1 1 1 1 1 1 1 ...
## $ lcinz: num 0 0 0 0 0.208 ...
## $ fit : num 1.83 1.9 1.77 1.92 1.83 ...
## $ lwr : num 1.72 1.79 1.66 1.8 1.72 ...
## $ upr : num 1.95 2.02 1.89 2.03 1.94 ...
##-----------------------------------------------------------------------------
## Gráficos.
p1 <-
segplot(agreg~lwr+upr, centers=estimate,
data=lsma, draw=FALSE,
xlab=ylab, ylab=lab.agreg)
p2 <-
segplot(fam~lwr+upr, centers=estimate,
data=lsmf, draw=FALSE,
xlab=ylab, ylab=lab.fam)
p3 <-
segplot(Cinz~lwr+upr, centers=estimate,
data=lsmc, draw=FALSE,
xlab=ylab, ylab=lab.cinz)
plot(p1, split=c(1,1,2,2), more=TRUE)
plot(p2, split=c(2,1,2,2), more=TRUE)
plot(p3, split=c(1,2,1,2), more=FALSE)
##-----------------------------------------------------------------------------
## Gráficos.
xyplot(fit~lcinz|agreg, groups=fam, data=pred, type="l",
auto.key=list(columns=2, title=lab.fam, cex.title=1.1),
layout=c(NA,1),
xlab=lab.lcinz, ylab=ylab,
cty="bands", alpha=0.2,
ly=pred$lwr, uy=pred$upr,
prepanel=prepanel.cbH,
panel=panel.superpose,
panel.groups=panel.cbH)
##-----------------------------------------------------------------------------
## Preliminar.
ylab <- "Cálcio"
da$y <- da$Ca
db <- da[!is.na(da$y),]
xyplot(y~lcinz|agreg, groups=fam, data=db,
auto.key=list(columns=2, title=lab.fam, cex.title=1.1),
jitter.x=TRUE, type=c("p","a"), layout=c(2,NA),
ylab=ylab, xlab=lab.lcinz)
##-----------------------------------------------------------------------------
## Modelo.
m0 <- lm(y~bloc+agreg*fam*Cinz, data=db)
m1 <- lm(y~bloc+agreg*fam*lcinz, data=db)
## Diagnóstico dos resíduos.
par(mfrow=c(2,2)); plot(m0); layout(1)
## Quadro de anova.
anova(m0)
## Analysis of Variance Table
##
## Response: y
## Df Sum Sq Mean Sq F value Pr(>F)
## bloc 2 4.70 2.350 10.31 0.00016 ***
## agreg 1 0.76 0.762 3.34 0.07308 .
## fam 1 0.01 0.008 0.03 0.85564
## Cinz 6 0.66 0.110 0.48 0.81777
## agreg:fam 1 0.00 0.000 0.00 0.96372
## agreg:Cinz 6 1.61 0.268 1.18 0.33318
## fam:Cinz 6 1.99 0.332 1.46 0.21080
## agreg:fam:Cinz 6 1.36 0.227 1.00 0.43742
## Residuals 54 12.31 0.228
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(m0, m1)
## Analysis of Variance Table
##
## Model 1: y ~ bloc + agreg * fam * Cinz
## Model 2: y ~ bloc + agreg * fam * lcinz
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 54 12.3
## 2 74 17.0 -20 -4.7 1.03 0.45
##-----------------------------------------------------------------------------
## Médias ajustadas e comparações múltiplas.
lsma <- LSmeans(m0, effect="agreg")
lsma <- cbind(lsma$grid, lsma$coef)
lsma <- equallevels(lsma, db)
lsma
## agreg estimate se df t.stat p.value lwr upr
## 1 [0,2] 3.917 0.07368 54 53.16 2.573e-48 3.769 4.064
## 2 [4,10] 4.107 0.07368 54 55.74 2.072e-49 3.959 4.255
lsmf <- LSmeans(m0, effect="fam")
lsmf <- cbind(lsmf$grid, lsmf$coef)
lsmf <- equallevels(lsmf, db)
lsmf
## fam estimate se df t.stat p.value lwr upr
## 1 F29 4.002 0.07368 54 54.32 8.163e-49 3.855 4.150
## 2 F48 4.021 0.07368 54 54.58 6.346e-49 3.874 4.169
lsmc <- LSmeans(m0, effect="Cinz")
lsmc <- cbind(lsmc$grid, lsmc$coef)
lsmc <- equallevels(lsmc, db)
lsmc
## Cinz estimate se df t.stat p.value lwr upr
## 1 0 3.892 0.1378 54 28.23 5.170e-34 3.615 4.168
## 2 1.5 4.025 0.1378 54 29.20 9.357e-35 3.749 4.301
## 3 3 4.017 0.1378 54 29.14 1.040e-34 3.740 4.293
## 4 6 4.067 0.1378 54 29.50 5.541e-35 3.790 4.343
## 5 12 3.908 0.1378 54 28.35 4.163e-34 3.632 4.185
## 6 24 4.175 0.1378 54 30.29 1.451e-35 3.899 4.451
## 7 48 4.000 0.1378 54 29.02 1.284e-34 3.724 4.276
##-----------------------------------------------------------------------------
## Gráficos.
p1 <-
segplot(agreg~lwr+upr, centers=estimate,
data=lsma, draw=FALSE,
xlab=ylab, ylab=lab.agreg)
p2 <-
segplot(fam~lwr+upr, centers=estimate,
data=lsmf, draw=FALSE,
xlab=ylab, ylab=lab.fam)
p3 <-
segplot(Cinz~lwr+upr, centers=estimate,
data=lsmc, draw=FALSE,
xlab=ylab, ylab=lab.cinz)
plot(p1, split=c(1,1,2,2), more=TRUE)
plot(p2, split=c(2,1,2,2), more=TRUE)
plot(p3, split=c(1,2,1,2), more=FALSE)
##-----------------------------------------------------------------------------
## Preliminar.
ylab <- "Magnésio"
da$y <- da$Mg
db <- da[!is.na(da$y),]
xyplot(y~lcinz|agreg, groups=fam, data=db,
auto.key=list(columns=2, title=lab.fam, cex.title=1.1),
jitter.x=TRUE, type=c("p","a"), layout=c(2,NA),
ylab=ylab, xlab=lab.lcinz)
##-----------------------------------------------------------------------------
## Modelo.
m0 <- lm(y~bloc+agreg*fam*Cinz, data=db)
m1 <- lm(y~bloc+agreg*fam*lcinz, data=db)
## Diagnóstico dos resíduos.
par(mfrow=c(2,2)); plot(m0); layout(1)
## Quadro de anova.
anova(m0)
## Analysis of Variance Table
##
## Response: y
## Df Sum Sq Mean Sq F value Pr(>F)
## bloc 2 4.22 2.110 8.63 0.00056 ***
## agreg 1 0.29 0.286 1.17 0.28446
## fam 1 0.00 0.000 0.00 0.98248
## Cinz 6 2.09 0.348 1.42 0.22247
## agreg:fam 1 0.00 0.003 0.01 0.91257
## agreg:Cinz 6 1.95 0.325 1.33 0.25996
## fam:Cinz 6 2.17 0.361 1.48 0.20356
## agreg:fam:Cinz 6 3.29 0.549 2.24 0.05271 .
## Residuals 54 13.21 0.245
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(m0, m1)
## Analysis of Variance Table
##
## Model 1: y ~ bloc + agreg * fam * Cinz
## Model 2: y ~ bloc + agreg * fam * lcinz
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 54 13.2
## 2 74 21.0 -20 -7.78 1.59 0.09 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##-----------------------------------------------------------------------------
## Médias ajustadas e comparações múltiplas.
lsma <- LSmeans(m0, effect="agreg")
lsma <- cbind(lsma$grid, lsma$coef)
lsma <- equallevels(lsma, db)
lsma
## agreg estimate se df t.stat p.value lwr upr
## 1 [0,2] 1.679 0.07631 54 22.00 1.265e-28 1.526 1.832
## 2 [4,10] 1.562 0.07631 54 20.47 4.107e-27 1.409 1.715
lsmf <- LSmeans(m0, effect="fam")
lsmf <- cbind(lsmf$grid, lsmf$coef)
lsmf <- equallevels(lsmf, db)
lsmf
## fam estimate se df t.stat p.value lwr upr
## 1 F29 1.619 0.07631 54 21.22 7.285e-28 1.466 1.772
## 2 F48 1.621 0.07631 54 21.25 6.786e-28 1.468 1.774
lsmc <- LSmeans(m0, effect="Cinz")
lsmc <- cbind(lsmc$grid, lsmc$coef)
lsmc <- equallevels(lsmc, db)
lsmc
## Cinz estimate se df t.stat p.value lwr upr
## 1 0 1.483 0.1428 54 10.39 1.732e-14 1.197 1.770
## 2 1.5 1.875 0.1428 54 13.13 1.898e-18 1.589 2.161
## 3 3 1.442 0.1428 54 10.10 4.827e-14 1.155 1.728
## 4 6 1.842 0.1428 54 12.90 3.972e-18 1.555 2.128
## 5 12 1.575 0.1428 54 11.03 1.883e-15 1.289 1.861
## 6 24 1.542 0.1428 54 10.80 4.195e-15 1.255 1.828
## 7 48 1.583 0.1428 54 11.09 1.542e-15 1.297 1.870
##-----------------------------------------------------------------------------
## Gráficos.
p1 <-
segplot(agreg~lwr+upr, centers=estimate,
data=lsma, draw=FALSE,
xlab=ylab, ylab=lab.agreg)
p2 <-
segplot(fam~lwr+upr, centers=estimate,
data=lsmf, draw=FALSE,
xlab=ylab, ylab=lab.fam)
p3 <-
segplot(Cinz~lwr+upr, centers=estimate,
data=lsmc, draw=FALSE,
xlab=ylab, ylab=lab.cinz)
plot(p1, split=c(1,1,2,2), more=TRUE)
plot(p2, split=c(2,1,2,2), more=TRUE)
plot(p3, split=c(1,2,1,2), more=FALSE)
##-----------------------------------------------------------------------------
## Preliminar.
ylab <- "H+Al"
da$y <- da$Hal
db <- da[!is.na(da$y),]
xyplot(y~lcinz|agreg, groups=fam, data=db,
auto.key=list(columns=2, title=lab.fam, cex.title=1.1),
jitter.x=TRUE, type=c("p","a"), layout=c(2,NA),
ylab=ylab, xlab=lab.lcinz)
##-----------------------------------------------------------------------------
## Modelo.
m0 <- lm(y~bloc+agreg*fam*Cinz, data=db)
m1 <- lm(y~bloc+agreg*fam*lcinz, data=db)
## Diagnóstico dos resíduos.
par(mfrow=c(2,2)); plot(m0); layout(1)
## Quadro de anova.
anova(m0)
## Analysis of Variance Table
##
## Response: y
## Df Sum Sq Mean Sq F value Pr(>F)
## bloc 2 0.01 0.003 0.03 0.9669
## agreg 1 0.92 0.922 9.32 0.0035 **
## fam 1 0.06 0.058 0.58 0.4486
## Cinz 6 0.16 0.026 0.26 0.9512
## agreg:fam 1 0.21 0.210 2.12 0.1508
## agreg:Cinz 6 0.37 0.061 0.62 0.7131
## fam:Cinz 6 0.12 0.019 0.20 0.9769
## agreg:fam:Cinz 6 0.41 0.068 0.69 0.6578
## Residuals 54 5.34 0.099
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(m0, m1)
## Analysis of Variance Table
##
## Model 1: y ~ bloc + agreg * fam * Cinz
## Model 2: y ~ bloc + agreg * fam * lcinz
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 54 5.34
## 2 74 6.08 -20 -0.742 0.38 0.99
##-----------------------------------------------------------------------------
## Médias ajustadas e comparações múltiplas.
lsma <- LSmeans(m0, effect="agreg")
lsma <- cbind(lsma$grid, lsma$coef)
lsma <- equallevels(lsma, db)
lsma
## agreg estimate se df t.stat p.value lwr upr
## 1 [0,2] 3.329 0.04852 54 68.60 3.283e-54 3.231 3.426
## 2 [4,10] 3.538 0.04852 54 72.92 1.258e-55 3.441 3.635
lsmf <- LSmeans(m0, effect="fam")
lsmf <- cbind(lsmf$grid, lsmf$coef)
lsmf <- equallevels(lsmf, db)
lsmf
## fam estimate se df t.stat p.value lwr upr
## 1 F29 3.460 0.04852 54 71.30 4.179e-55 3.362 3.557
## 2 F48 3.407 0.04852 54 70.22 9.443e-55 3.310 3.504
lsmc <- LSmeans(m0, effect="Cinz")
lsmc <- cbind(lsmc$grid, lsmc$coef)
lsmc <- equallevels(lsmc, db)
lsmc
## Cinz estimate se df t.stat p.value lwr upr
## 1 0 3.417 0.09078 54 37.64 1.968e-40 3.235 3.599
## 2 1.5 3.375 0.09078 54 37.18 3.727e-40 3.193 3.557
## 3 3 3.475 0.09078 54 38.28 8.149e-41 3.293 3.657
## 4 6 3.483 0.09078 54 38.37 7.193e-41 3.301 3.665
## 5 12 3.475 0.09078 54 38.28 8.149e-41 3.293 3.657
## 6 24 3.375 0.09078 54 37.18 3.727e-40 3.193 3.557
## 7 48 3.433 0.09078 54 37.82 1.528e-40 3.251 3.615
##-----------------------------------------------------------------------------
## Gráficos.
p1 <-
segplot(agreg~lwr+upr, centers=estimate,
data=lsma, draw=FALSE,
xlab=ylab, ylab=lab.agreg)
p2 <-
segplot(fam~lwr+upr, centers=estimate,
data=lsmf, draw=FALSE,
xlab=ylab, ylab=lab.fam)
p3 <-
segplot(Cinz~lwr+upr, centers=estimate,
data=lsmc, draw=FALSE,
xlab=ylab, ylab=lab.cinz)
plot(p1, split=c(1,1,2,2), more=TRUE)
plot(p2, split=c(2,1,2,2), more=TRUE)
plot(p3, split=c(1,2,1,2), more=FALSE)
##-----------------------------------------------------------------------------
## Preliminar.
ylab <- "log da Matéria orgânica"
da$y <- log10(da$mo)
db <- da[!is.na(da$y),]
xyplot(y~lcinz|agreg, groups=fam, data=db,
auto.key=list(columns=2, title=lab.fam, cex.title=1.1),
jitter.x=TRUE, type=c("p","a"), layout=c(2,NA),
ylab=ylab, xlab=lab.lcinz)
##-----------------------------------------------------------------------------
## Modelo.
m0 <- lm(y~bloc+agreg*fam*Cinz, data=db)
m1 <- lm(y~bloc+agreg*fam*lcinz, data=db)
## Diagnóstico dos resíduos.
par(mfrow=c(2,2)); plot(m0); layout(1)
## Quadro de anova.
anova(m0)
## Analysis of Variance Table
##
## Response: y
## Df Sum Sq Mean Sq F value Pr(>F)
## bloc 2 0.021 0.010 0.90 0.412
## agreg 1 0.033 0.033 2.86 0.097 .
## fam 1 1.949 1.949 168.14 < 2e-16 ***
## Cinz 6 0.840 0.140 12.08 1.7e-08 ***
## agreg:fam 1 0.003 0.003 0.24 0.629
## agreg:Cinz 6 0.044 0.007 0.63 0.702
## fam:Cinz 6 0.459 0.077 6.60 3.0e-05 ***
## agreg:fam:Cinz 6 0.068 0.011 0.97 0.451
## Residuals 53 0.614 0.012
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(m0, m1)
## Analysis of Variance Table
##
## Model 1: y ~ bloc + agreg * fam * Cinz
## Model 2: y ~ bloc + agreg * fam * lcinz
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 53 0.614
## 2 73 0.907 -20 -0.293 1.26 0.24
##-----------------------------------------------------------------------------
## Médias ajustadas e comparações múltiplas.
lsma <- LSmeans(m0, effect="agreg")
lsma <- cbind(lsma$grid, lsma$coef)
lsma <- equallevels(lsma, db)
lsma
## agreg estimate se df t.stat p.value lwr upr
## 1 [0,2] 0.1979 0.01692 53 11.698 2.638e-16 0.1640 0.2319
## 2 [4,10] 0.1593 0.01661 53 9.586 3.610e-13 0.1259 0.1926
##-----------------------------------------------------------------------------
## Estimativas com bandas.
pred <- with(da,
expand.grid(
fam=levels(fam),
agreg=levels(agreg),
bloc=levels(bloc)[1],
lcinz=seq(0, 5, length.out=25)))
aux <- predict(m1, newdata=pred, interval="confidence")
pred <- cbind(pred, aux)
str(pred)
## 'data.frame': 100 obs. of 7 variables:
## $ fam : Factor w/ 2 levels "F29","F48": 1 2 1 2 1 2 1 2 1 2 ...
## $ agreg: Factor w/ 2 levels "[0,2]","[4,10]": 1 1 2 2 1 1 2 2 1 1 ...
## $ bloc : Factor w/ 1 level "1": 1 1 1 1 1 1 1 1 1 1 ...
## $ lcinz: num 0 0 0 0 0.208 ...
## $ fit : num 0.0188 0.1155 -0.1064 0.0599 0.0194 ...
## $ lwr : num -0.0814 0.0216 -0.2004 -0.034 -0.0765 ...
## $ upr : num 0.119 0.2095 -0.0125 0.1538 0.1154 ...
##-----------------------------------------------------------------------------
## Gráficos.
p1 <-
segplot(agreg~lwr+upr, centers=estimate,
data=lsma, draw=FALSE,
xlab=ylab, ylab=lab.agreg)
plot(p1)
##-----------------------------------------------------------------------------
## Gráficos.
xyplot(fit~lcinz|agreg, groups=fam, data=pred, type="l",
auto.key=list(columns=2, title=lab.fam, cex.title=1.1),
layout=c(NA,1),
xlab=lab.lcinz, ylab=ylab,
cty="bands", fil=1, alpha=0.2,
ly=pred$lwr, uy=pred$upr,
prepanel=prepanel.cbH,
panel=panel.superpose,
panel.groups=panel.cbH)
##-----------------------------------------------------------------------------
## Preliminar.
ylab <- "CTC em pH 7"
da$y <- da$ctc7
db <- da[!is.na(da$y),]
xyplot(y~lcinz|agreg, groups=fam, data=db,
auto.key=list(columns=2, title=lab.fam, cex.title=1.1),
jitter.x=TRUE, type=c("p","a"), layout=c(2,NA),
ylab=ylab, xlab=lab.lcinz)
##-----------------------------------------------------------------------------
## Modelo.
m0 <- lm(y~bloc+agreg*fam*Cinz, data=db)
m1 <- lm(y~bloc+agreg*fam*lcinz, data=db)
## Diagnóstico dos resíduos.
par(mfrow=c(2,2)); plot(m0); layout(1)
## Quadro de anova.
anova(m0)
## Analysis of Variance Table
##
## Response: y
## Df Sum Sq Mean Sq F value Pr(>F)
## bloc 2 4.14 2.070 8.02 0.00089 ***
## agreg 1 1.59 1.591 6.16 0.01619 *
## fam 1 0.19 0.190 0.74 0.39418
## Cinz 6 3.76 0.627 2.43 0.03761 *
## agreg:fam 1 0.56 0.564 2.18 0.14539
## agreg:Cinz 6 4.95 0.825 3.19 0.00932 **
## fam:Cinz 6 1.93 0.321 1.24 0.29907
## agreg:fam:Cinz 6 3.84 0.641 2.48 0.03417 *
## Residuals 54 13.94 0.258
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(m0, m1)
## Analysis of Variance Table
##
## Model 1: y ~ bloc + agreg * fam * Cinz
## Model 2: y ~ bloc + agreg * fam * lcinz
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 54 13.9
## 2 74 26.3 -20 -12.4 2.39 0.0057 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##-----------------------------------------------------------------------------
## Médias ajustadas e comparações múltiplas.
X <- LSmatrix(m0, effect=c("agreg","fam","Cinz"))
grid <- attr(X, "grid")
L <- with(grid, by(X, INDICES=interaction(fam, Cinz, sep="|"),
FUN=as.matrix))
L <- lapply(L, "rownames<-", levels(da$agreg))
lsma <- lapply(L, desdobr.glht, m0=m0, focus="agreg")
## Error: object 'desdobr.glht' not found
lsma
## agreg estimate se df t.stat p.value lwr upr
## 1 [0,2] 0.1979 0.01692 53 11.698 2.638e-16 0.1640 0.2319
## 2 [4,10] 0.1593 0.01661 53 9.586 3.610e-13 0.1259 0.1926
lsma <- ldply(lsma)
aux <- do.call(rbind, strsplit(lsma$.id, "\\|"))
colnames(aux) <- c("fam","Cinz")
## Error: length of 'dimnames' [2] not equal to array extent
lsma <- cbind(lsma, aux)
lsma <- equallevels(lsma, db)
##-----------------------------------------------------------------------------
## Gráficos.
l <- levels(db$agreg)
key <- list(columns=length(l),
title=lab.agreg, cex.title=1.1,
points=list(pch=1:length(l)),
text=list(l))
segplot(Cinz~lwr+upr|fam, centers=estimate,
data=lsma, draw=FALSE,
xlab=ylab, ylab=lab.cinz,
by=lsma$agreg, pch=as.integer(lsma$agreg),
key=key,
f=0.1, panel=segplot.by)
## Error: object 'estimate' not found
##-----------------------------------------------------------------------------
## Preliminar.
ylab <- "CTC efetiva"
da$y <- da$ctcefet
db <- da[!is.na(da$y),]
xyplot(y~lcinz|agreg, groups=fam, data=db,
auto.key=list(columns=2, title=lab.fam, cex.title=1.1),
jitter.x=TRUE, type=c("p","a"), layout=c(2,NA),
ylab=ylab, xlab=lab.lcinz)
##-----------------------------------------------------------------------------
## Modelo.
m0 <- lm(y~bloc+agreg*fam*Cinz, data=db)
m1 <- lm(y~bloc+agreg*fam*lcinz, data=db)
## Diagnóstico dos resíduos.
par(mfrow=c(2,2)); plot(m0); layout(1)
## Quadro de anova.
anova(m0)
## Analysis of Variance Table
##
## Response: y
## Df Sum Sq Mean Sq F value Pr(>F)
## bloc 2 3.88 1.941 13.20 2.2e-05 ***
## agreg 1 0.07 0.065 0.44 0.5084
## fam 1 0.40 0.403 2.74 0.1035
## Cinz 6 3.71 0.618 4.20 0.0015 **
## agreg:fam 1 0.06 0.057 0.38 0.5377
## agreg:Cinz 6 4.28 0.714 4.86 0.0005 ***
## fam:Cinz 6 1.59 0.266 1.81 0.1150
## agreg:fam:Cinz 6 3.55 0.592 4.03 0.0021 **
## Residuals 54 7.94 0.147
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(m0, m1)
## Analysis of Variance Table
##
## Model 1: y ~ bloc + agreg * fam * Cinz
## Model 2: y ~ bloc + agreg * fam * lcinz
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 54 7.94
## 2 74 19.46 -20 -11.5 3.92 3.3e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##-----------------------------------------------------------------------------
## Médias ajustadas e comparações múltiplas.
X <- LSmatrix(m0, effect=c("agreg","fam","Cinz"))
grid <- attr(X, "grid")
L <- with(grid, by(X, INDICES=interaction(fam, Cinz, sep="|"),
FUN=as.matrix))
L <- lapply(L, "rownames<-", levels(da$agreg))
lsma <- lapply(L, desdobr.glht, m0=m0, focus="agreg")
## Error: object 'desdobr.glht' not found
lsma
## .id V1 V2 aux
## 1 agreg 1.000e+00 2.000e+00 agreg
## 2 estimate 1.979e-01 1.593e-01 estimate
## 3 se 1.692e-02 1.661e-02 se
## 4 df 5.300e+01 5.300e+01 df
## 5 t.stat 1.170e+01 9.586e+00 t.stat
## 6 p.value 2.638e-16 3.610e-13 p.value
## 7 lwr 1.640e-01 1.259e-01 lwr
## 8 upr 2.319e-01 1.926e-01 upr
lsma <- ldply(lsma)
aux <- do.call(rbind, strsplit(lsma$.id, "\\|"))
colnames(aux) <- c("fam","Cinz")
## Error: length of 'dimnames' [2] not equal to array extent
lsma <- cbind(lsma, aux)
lsma <- equallevels(lsma, db)
##-----------------------------------------------------------------------------
## Gráficos.
l <- levels(db$agreg)
key <- list(columns=length(l),
title=lab.agreg, cex.title=1.1,
points=list(pch=1:length(l)),
text=list(l))
segplot(Cinz~lwr+upr|fam, centers=estimate,
data=lsma, draw=FALSE,
xlab=ylab, ylab=lab.cinz,
by=lsma$agreg, pch=as.integer(lsma$agreg),
key=key,
f=0.1, panel=segplot.by)
## Error: object 'estimate' not found
##-----------------------------------------------------------------------------
## Preliminar.
ylab <- "Saturação por bases (%)"
da$y <- da$V
db <- da[!is.na(da$y),]
xyplot(y~lcinz|agreg, groups=fam, data=db,
auto.key=list(columns=2, title=lab.fam, cex.title=1.1),
jitter.x=TRUE, type=c("p","a"), layout=c(2,NA),
ylab=ylab, xlab=lab.lcinz)
##-----------------------------------------------------------------------------
## Modelo.
m0 <- lm(y~bloc+agreg*fam*Cinz, data=db)
m1 <- lm(y~bloc+agreg*fam*lcinz, data=db)
## Diagnóstico dos resíduos.
par(mfrow=c(2,2)); plot(m0); layout(1)
## Quadro de anova.
anova(m0)
## Analysis of Variance Table
##
## Response: y
## Df Sum Sq Mean Sq F value Pr(>F)
## bloc 2 52 25.8 3.89 0.026 *
## agreg 1 35 34.6 5.22 0.026 *
## fam 1 12 12.0 1.80 0.185
## Cinz 6 65 10.9 1.64 0.153
## agreg:fam 1 7 6.6 0.99 0.325
## agreg:Cinz 6 75 12.5 1.89 0.100 .
## fam:Cinz 6 23 3.8 0.58 0.746
## agreg:fam:Cinz 6 67 11.2 1.69 0.140
## Residuals 54 358 6.6
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(m0, m1)
## Analysis of Variance Table
##
## Model 1: y ~ bloc + agreg * fam * Cinz
## Model 2: y ~ bloc + agreg * fam * lcinz
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 54 358
## 2 74 562 -20 -204 1.54 0.11
##-----------------------------------------------------------------------------
## Médias ajustadas e comparações múltiplas.
lsma <- LSmeans(m0, effect="agreg")
lsma <- cbind(lsma$grid, lsma$coef)
lsma <- equallevels(lsma, db)
lsma
## agreg estimate se df t.stat p.value lwr upr
## 1 [0,2] 63.68 0.3974 54 160.2 5.341e-74 62.88 64.47
## 2 [4,10] 62.39 0.3974 54 157.0 1.601e-73 61.60 63.19
lsmf <- LSmeans(m0, effect="fam")
lsmf <- cbind(lsmf$grid, lsmf$coef)
lsmf <- equallevels(lsmf, db)
lsmf
## fam estimate se df t.stat p.value lwr upr
## 1 F29 62.66 0.3974 54 157.7 1.274e-73 61.86 63.46
## 2 F48 63.41 0.3974 54 159.6 6.684e-74 62.62 64.21
lsmc <- LSmeans(m0, effect="Cinz")
lsmc <- cbind(lsmc$grid, lsmc$coef)
lsmc <- equallevels(lsmc, db)
lsmc
## Cinz estimate se df t.stat p.value lwr upr
## 1 0 62.10 0.7435 54 83.53 8.738e-59 60.61 63.59
## 2 1.5 64.19 0.7435 54 86.34 1.476e-59 62.70 65.69
## 3 3 61.91 0.7435 54 83.27 1.029e-58 60.42 63.40
## 4 6 63.70 0.7435 54 85.67 2.241e-59 62.21 65.19
## 5 12 62.26 0.7435 54 83.74 7.607e-59 60.77 63.75
## 6 24 64.00 0.7435 54 86.08 1.738e-59 62.51 65.49
## 7 48 63.09 0.7435 54 84.86 3.740e-59 61.60 64.58
##-----------------------------------------------------------------------------
## Gráficos.
p1 <-
segplot(agreg~lwr+upr, centers=estimate,
data=lsma, draw=FALSE,
xlab=ylab, ylab=lab.agreg)
p2 <-
segplot(fam~lwr+upr, centers=estimate,
data=lsmf, draw=FALSE,
xlab=ylab, ylab=lab.fam)
p3 <-
segplot(Cinz~lwr+upr, centers=estimate,
data=lsmc, draw=FALSE,
xlab=ylab, ylab=lab.cinz)
plot(p1, split=c(1,1,2,2), more=TRUE)
plot(p2, split=c(2,1,2,2), more=TRUE)
plot(p3, split=c(1,2,1,2), more=FALSE)