-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
CIP-RIU
committed
Jun 21, 2018
1 parent
54ef53f
commit 5d76f1e
Showing
90 changed files
with
4,491 additions
and
531 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
title: "`r params$title`" | ||
subtitle: '`r params$subtitle`' | ||
author: '`r params$author`' | ||
date: '`r format(Sys.time(), "%B %d, %Y")`' | ||
output: | ||
html_document: | ||
theme: united | ||
toc: true | ||
toc_depth: 3 | ||
pdf_document: | ||
toc: true | ||
toc_depth: 3 | ||
highlight: zenburn | ||
word_document: | ||
toc: true | ||
toc_depth: 3 | ||
highlight: "tango" | ||
params: | ||
traits: "no data" | ||
A: "no data" | ||
B: "no data" | ||
rep: "no data" | ||
design: "no data" | ||
data: "no data" | ||
maxp: "no data" | ||
title: "no data" | ||
subtitle: "no data" | ||
author: "no data" | ||
--- | ||
|
||
```{r, echo = FALSE} | ||
library(knitr) | ||
traits <- params$traits | ||
A <- params$A | ||
B <- params$B | ||
rep <- params$rep | ||
design <- params$design | ||
data <- params$data | ||
maxp <- params$maxp | ||
data[, A] <- as.character(data[, A]) | ||
data[, B] <- as.character(data[, B]) | ||
data[, rep] <- as.character(data[, rep]) | ||
``` | ||
|
||
# 1. Model specification and data description | ||
|
||
The data frame has two factors with `r nlevels(as.factor(data[, A]))` and `r nlevels(as.factor(data[, B]))` levels. The experimental design is a completely randomized design with `r nlevels(as.factor(data[, rep]))` replications. The statistical model is | ||
$$ | ||
y_{ijk} = \mu + \alpha_i + \beta_j + (\alpha\beta)_{ij} + \epsilon_{ijk} | ||
$$ | ||
where | ||
|
||
* $y_{ijk}$ is the observed response with level $i$ of factor A, level $j$ of factor B, and replication $k$. | ||
* $\mu$ is the mean response over all levels of factor A, factor B, and replications. | ||
* $\alpha_i$ is the effect for level $i$ of factor A. | ||
* $\beta_j$ is the effect for level $j$ of factor B. | ||
* $(\alpha\beta)_{ij}$ is the interaction effect between level $i$ of factor A and level $j$ of factor B. | ||
* $\epsilon_{ijk}$ is the error term. | ||
|
||
In this model we assume that the errors are independent and have a normal distribution with common variance, that is, $\epsilon_{ijk} \sim N(0,\sigma_{\epsilon}^2)$. | ||
|
||
```{r, include = FALSE} | ||
out <- NULL | ||
for (i in 1:length(traits)) { | ||
lc <- check.2f(traits[i], A, B, rep, data) | ||
if (lc$c1 == 1 & lc$c2 == 1 & lc$c3 == 1 & lc$pmis <= maxp) | ||
out <- c(out, knit_expand('child_2f.Rmd')) | ||
else | ||
out <- c(out, knit_expand('child_2f_fail.Rmd')) | ||
} | ||
``` | ||
|
||
`r paste(knit(text = out), collapse = '\n')` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--- | ||
title: "`r params$title`" | ||
subtitle: '`r params$subtitle`' | ||
author: '`r params$author`' | ||
date: '`r format(Sys.time(), "%B %d, %Y")`' | ||
output: | ||
html_document: | ||
theme: united | ||
toc: true | ||
toc_depth: 3 | ||
pdf_document: | ||
toc: true | ||
toc_depth: 3 | ||
highlight: zenburn | ||
word_document: | ||
toc: true | ||
toc_depth: 3 | ||
highlight: "tango" | ||
params: | ||
traits: "no data" | ||
A: "no data" | ||
B: "no data" | ||
rep: "no data" | ||
design: "no data" | ||
data: "no data" | ||
maxp: "no data" | ||
title: "no data" | ||
subtitle: "no data" | ||
author: "no data" | ||
--- | ||
|
||
```{r, echo = FALSE} | ||
library(knitr) | ||
traits <- params$traits | ||
A <- params$A | ||
B <- params$B | ||
rep <- params$rep | ||
design <- params$design | ||
data <- params$data | ||
maxp <- params$maxp | ||
data[, A] <- as.character(data[, A]) | ||
data[, B] <- as.character(data[, B]) | ||
data[, rep] <- as.character(data[, rep]) | ||
``` | ||
|
||
# 1. Model specification and data description | ||
|
||
The data frame has two factors with `r nlevels(as.factor(data[, A]))` and `r nlevels(as.factor(data[, B]))` levels. The experimental design is a randomized complete block design with `r nlevels(as.factor(data[, rep]))` blocks. The statistical model is | ||
$$ | ||
y_{ijk} = \mu + \alpha_i + \beta_j + (\alpha\beta)_{ij} + \gamma_k + \epsilon_{ijk} | ||
$$ | ||
where | ||
|
||
* $y_{ijk}$ is the observed response with level $i$ of factor A, level $j$ of factor B, and block $k$. | ||
* $\mu$ is the mean response over all levels of factor A, factor B, and blocks. | ||
* $\alpha_i$ is the effect for level $i$ of factor A. | ||
* $\beta_j$ is the effect for level $j$ of factor B. | ||
* $(\alpha\beta)_{ij}$ is the interaction effect between level $i$ of factor A and level $j$ of factor B. | ||
* $\gamma_k$ is the effect of block $k$. | ||
* $\epsilon_{ijk}$ is the error term. | ||
|
||
In this model we assume that the errors are independent and have a normal distribution with common variance, that is, $\epsilon_{ijk} \sim N(0,\sigma_{\epsilon}^2)$. | ||
|
||
```{r, include = FALSE} | ||
out <- NULL | ||
for (i in 1:length(traits)) { | ||
lc <- check.2f(traits[i], A, B, rep, data) | ||
if (lc$c1 == 1 & lc$c2 == 1 & lc$c3 == 1 & lc$pmis <= maxp) | ||
out <- c(out, knit_expand('child_2f.Rmd')) | ||
else | ||
out <- c(out, knit_expand('child_2f_fail.Rmd')) | ||
} | ||
``` | ||
|
||
`r paste(knit(text = out), collapse = '\n')` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
title: "Report for an aov or lm object" | ||
author: '`r params$author`' | ||
date: '`r format(Sys.time(), "%B %d, %Y")`' | ||
output: | ||
html_document: | ||
theme: united | ||
pdf_document: | ||
toc: true | ||
highlight: zenburn | ||
word_document: | ||
highlight: "tango" | ||
params: | ||
x: "no data" | ||
author: "no data" | ||
--- | ||
|
||
Congratulations! You have fitted a linear model. The ANOVA table for your model is | ||
```{r, echo = FALSE} | ||
anova(params$x) | ||
noterms <- dim(anova(params$x))[1] - 1 | ||
pvalues <- anova(params$x)[1:noterms, 5] | ||
``` | ||
|
||
`r if(noterms == 1 & sum(pvalues < 0.05) > 0) {"Your model has 1 term and it is significant. That is really good! Have you checked your assumptions?"}` | ||
|
||
`r if(noterms > 1 & sum(pvalues < 0.05) > 0) {paste("Your model has", noterms, "terms and some of them are significant. That is really good! Have you checked your assumptions?")}` | ||
|
||
`r if(noterms == 1 & sum(pvalues < 0.05) == 0) {"Your model has 1 term but it is not significant. I am really sorry, but don't forget that p-values are a function of sample size, so maybe you can try with more replications or a larger sample size next time."}` | ||
|
||
`r if(noterms > 1 & sum(pvalues < 0.05) == 0) {paste("Your model has", noterms, "terms but none of them are significant. I am really sorry, but don't forget that p-values are a function of sample size, so maybe you can try with more replications or a larger sample size next time.")}` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- | ||
title: "ANOVA for a MET with a RCBD" | ||
author: '`r params$author`' | ||
date: '`r format(Sys.time(), "%B %d, %Y")`' | ||
output: | ||
html_document: | ||
theme: united | ||
pdf_document: | ||
toc: true | ||
highlight: zenburn | ||
word_document: | ||
highlight: "tango" | ||
params: | ||
trait: "no data" | ||
geno: "no data" | ||
env: "no data" | ||
rep: "no data" | ||
data: "no data" | ||
maxp: "no data" | ||
author: "no data" | ||
--- | ||
|
||
```{r, echo = FALSE} | ||
trait <- params$trait | ||
geno <- params$geno | ||
env <- params$env | ||
rep <- params$rep | ||
data <- params$data | ||
maxp <- params$maxp | ||
lc <- check.2f(trait, geno, env, rep, data) | ||
at <- suppressWarnings(aov.met(trait, geno, env, rep, data, maxp)) | ||
if (lc$c4 == 0) | ||
data[, trait] <- mve.met(trait, geno, env, rep, data, maxp)[, 5] | ||
model <- aov(data[, trait] ~ data[, geno] + data[, env] | ||
+ data[, rep] %in% data[, env] + data[, geno]:data[, env]) | ||
``` | ||
|
||
`r if(lc$c1 == 1 & lc$c2 == 1) {"You have fitted a linear model for a multi environment trial (MET) with a RCBD in each environment. The ANOVA table for your model is:"}` | ||
|
||
```{r, echo = FALSE} | ||
at | ||
``` | ||
|
||
`r if(lc$c4 == 0) paste("You have some missing values (", format(lc$pmis * 100, digits = 3), "%) and they have been estimated before running ANOVA.")` | ||
|
||
The p-values for your model are: | ||
|
||
- `r format(at[1, 5], digits = 4)` for genotypes `r if(at[1, 5] < 0.05) {"which is significant at the 5% level."} else {"which is not significant at the 5% level."}` | ||
- `r format(at[2, 5], digits = 4)` for environments `r if(at[2, 5] < 0.05) {"which is significant at the 5% level."} else {"which is not significant at the 5% level."}` | ||
- `r format(at[4, 5], digits = 4)` for the genotypes by environments interaction `r if(at[4, 5] < 0.05) {"which is significant at the 5% level."} else {"which is not significant at the 5% level."}` | ||
|
||
`r if(at[4, 5] < 0.05) {"Because interaction is significant you should want to run a stability analysis. Keep also in mind that a significant interaction means that the differences in response of the genotypes are not the same in all the environments. Therefore, on an individual analysis you could find significant differences among genotypes for some environments and non-significant differences for some others, and the difference for any pair of genotypes could be in different directions and magnitudes depending on the environment."}` | ||
|
||
Below you can see a table of means for genotypes, environments, and interaction: | ||
|
||
```{r, echo = FALSE} | ||
tapply(data[, trait], data[, geno], mean) | ||
tapply(data[, trait], data[, env], mean) | ||
tapply(data[, trait], list(data[, geno], data[, env]), mean) | ||
``` | ||
|
||
Don't forget the assumptions of the model. It is supposed that the error has a normal distribution with the same variance for all the genotypes and evironments. The following plots must help you evaluate this: | ||
|
||
```{r, echo = FALSE, fig.height = 5, fig.width = 10} | ||
par(mfrow = c(1, 2)) | ||
plot(model, which = 1) | ||
plot(model, which = 2) | ||
``` | ||
|
||
Funnel shapes for the first plot may suggest heterogeneity of variances while departures from the theoretical normal line are symptoms of lack of normality. |
Oops, something went wrong.