The lettuce dataset
In a previous tutorial, we analysed the dataset on lettuce plants using ANOVA. However, it was not clear if all the assumptions of ANOVA were met. Indeed, with only 7 datapoints per group, it is very hard to assess the assumptions of normality and equal variances.
Therefore, we will re-analyse the dataset by using the non-parametric alternative to ANOVA, the Kruskal-Wallis test
. We will first give a concise overview of what we saw in the ANOVA analysis, which can be found in the ANOVA_lettuce_plants.Rmd
file.
The researchers want to find out if biochar, compost and a combination of both biochar and compost have an influence on the growth of lettuce plants. To this end, they grew up lettuce plants in a greenhouse. The pots were filled with one of four soil types;
- Soil only (control)
- Soil supplemented with biochar (refoak)
- Soil supplemented with compost (compost)
- Soil supplemented with both biochar and compost (cobc)
The dataset freshweight_lettuce.txt
contains the freshweight (in grams) for 28 lettuce plants (7 per condition).
Load the required libraries
Data import
lettuce <- read_csv("https://raw.githubusercontent.com/statOmics/PSLSData/main/freshweight_lettuce.txt")
## Rows: 28 Columns: 3
## ── Column specification ──────────────────────────────────────────────
## Delimiter: ","
## chr (1): treatment
## dbl (2): id, freshweight
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Take a glimpse at the data
## Rows: 28
## Columns: 3
## $ id <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1…
## $ treatment <chr> "control", "control", "control", "control", "con…
## $ freshweight <dbl> 38, 34, 41, 43, 43, 29, 38, 59, 64, 57, 56, 50, …
Data tidying
## set treatment to factor
## ...
Data exploration
## Count the number of observations per treatment
Now let’s make a boxplot displaying the freshweight of each treatment condition:
Interpret the visualization!
In the analysis in chapter 7 (ANOVA_lettuce_plants_half.rmd
file), we accepted the assumptions for analyzing the data with an ANOVA. However, it was not clear if all the assumptions of ANOVA were met. Indeed, with only 7 values per group, it is very hard to assess the assumptions of normality and equal variances.
Therefore, we will re-analyse the dataset by using the non-parametric alternative to ANOVA: the Kruskal-Wallis test.
Kruskal-Wallis rank test
Hypotheses
Formulate a correct null and alternative hypothesis for the Kruskal-Wallis test in this analysis.
Analysis
# set.seed(1)
# kw <- kruskal_test(...)
# kw
Interpret the results!
Post-hoc analysis
We will perform a post-hoc analysis with pairwise Wilcoxon rank sum test. As we did not want to assume the location shift, we will interpret the outcome in terms of probabilistic indices. Note that after the analysis, we will need to correct the acquired p-values for multiple testing.
Hypotheses
Formulate a correct null and alternative hypothesis for the Wilcoxon test post-hoc analysis.
Analysis
## pairwise.wilcox.test(...)
What do you observe?
## Alternative: caluculate the p-value for each treatment combination with wilcoxon_test
treatments <- levels(lettuce$treatment)
freshweight <- lettuce$freshweight
pvalues <- combn(treatments,2,function(x){
## Pairwise Wilcoxon test
test = wilcox_test(freshweight~treatment,subset(lettuce,treatment%in%x), distribution = 'exact')
## Get and store p-value of test
pvalue(test)
})
## Adjust for multiple testing
pvalues_bonf = p.adjust(pvalues,method = 'bonferroni')
## link the p-value with the correct pairwise test
names(pvalues_bonf) <- combn(levels(lettuce$treatment),2,paste,collapse="_VS_")
pvalues_bonf
Interpret.
Based on the chunk of code above, can extract the point estimates for the probabilistic indices? Interpret those as well.
Conclusion
Formulate a proper conclusion that answers the research hypothesis.
LS0tCnRpdGxlOiAiRXhlcmNpc2UgOS4yOiBOb24tcGFyYW1ldHJpYyB0ZXN0IG9uIHRoZSBsZXR0dWNlIGRhdGFzZXQiCmF1dGhvcjogIkxpZXZlbiBDbGVtZW50IGFuZCBKZXJvZW4gR2lsaXMiCmRhdGU6ICJzdGF0T21pY3MsIEdoZW50IFVuaXZlcnNpdHkgKGh0dHBzOi8vc3RhdG9taWNzLmdpdGh1Yi5pbykiCi0tLQoKIyBUaGUgbGV0dHVjZSBkYXRhc2V0CgpJbiBhIHByZXZpb3VzIHR1dG9yaWFsLCB3ZSBhbmFseXNlZCB0aGUgZGF0YXNldCBvbgpsZXR0dWNlIHBsYW50cyB1c2luZyBBTk9WQS4gSG93ZXZlciwgaXQgd2FzIG5vdCBjbGVhcgppZiBhbGwgdGhlIGFzc3VtcHRpb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