Load all experiment output files in the “yield” folder, generated with this version (“Simple crop model”).
file_names <- paste0("yield/", list.files("yield"))
isThisVersion <- grepl("SIMPLE-crop-model_yield", file_names)
yieldData <- do.call(rbind, lapply(file_names[isThisVersion], read.csv))
Preview the data structure
knitr::kable(head(yieldData))
| randomSeed | temperature_annualMaxAt2m | temperature_annualMinAt2m | temperature_meanDailyFluctuation | temperature_dailyLowerDeviation | temperature_dailyUpperDeviation | solar_annualMax | solar_annualMin | solar_meanDailyFluctuation | CO2_annualMin | CO2_annualMax | CO2_meanDailyFluctuation | precipitation_yearlyMean | precipitation_yearlySd | precipitation_dailyCum_nSamples | precipitation_dailyCum_maxSampleSize | precipitation_dailyCum_plateauValue_yearlyMean | precipitation_dailyCum_plateauValue_yearlySd | precipitation_dailyCum_inflection1_yearlyMean | precipitation_dailyCum_inflection1_yearlySd | precipitation_dailyCum_rate1_yearlyMean | precipitation_dailyCum_rate1_yearlySd | precipitation_dailyCum_inflection2_yearlyMean | precipitation_dailyCum_inflection2_yearlySd | precipitation_dailyCum_rate2_yearlyMean | precipitation_dailyCum_rate2_yearlySd | currentYear | currentDayOfYear | precipitation_yearTotal | meanARID | elevation | DC | z | CN | FC | WHC | albedo | crop | T_sum | HI | I_50A | I_50B | T_base | T_opt | RUE | I_50maxH | I_50maxW | T_heat | T_extreme | S_CO2 | S_water | sowingDay | harvestDay | meanARID_grow | yield |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 37 | 12.8 | 2.2 | 6.8 | 7.9 | 24.2 | 9.2 | 3.3 | 245 | 255 | 1 | 639.0508 | 142.2 | 200 | 10 | 0.6291136 | 0.1 | 40 | 5 | 0.07 | 0.02 | 240 | 20 | 0.08 | 0.02 | 0 | 365 | 737.5001 | 0.6886102 | 200 | 0.55 | 400 | 65 | 0.21 | 0.15 | 0.23 | ‘wheat 1’ | 2200 | 0.36 | 480 | 200 | 0 | 15 | 1.24 | 100 | 25 | 34 | 45 | 0.08 | 0.4 | 330 | 105 | NA | 0.0000 |
| 0 | 37 | 12.8 | 2.2 | 6.8 | 7.9 | 24.2 | 9.2 | 3.3 | 245 | 255 | 1 | 639.0508 | 142.2 | 200 | 10 | 0.6291136 | 0.1 | 40 | 5 | 0.07 | 0.02 | 240 | 20 | 0.08 | 0.02 | 0 | 365 | 737.5001 | 0.6886102 | 200 | 0.55 | 400 | 65 | 0.21 | 0.15 | 0.23 | ‘wheat 2’ | 2150 | 0.34 | 280 | 50 | 0 | 15 | 1.24 | 100 | 25 | 34 | 45 | 0.08 | 0.4 | 330 | 105 | NA | 0.0000 |
| 0 | 37 | 12.8 | 2.2 | 6.8 | 7.9 | 24.2 | 9.2 | 3.3 | 245 | 255 | 1 | 639.0508 | 142.2 | 200 | 10 | 0.6291136 | 0.1 | 40 | 5 | 0.07 | 0.02 | 240 | 20 | 0.08 | 0.02 | 0 | 365 | 737.5001 | 0.6886102 | 200 | 0.55 | 400 | 65 | 0.21 | 0.15 | 0.23 | ‘rice’ | 2300 | 0.47 | 850 | 200 | 9 | 26 | 1.24 | 100 | 10 | 34 | 50 | 0.08 | 1.0 | 190 | 330 | 0.7735755 | 222.5149 |
| 0 | 37 | 12.8 | 2.2 | 6.8 | 7.9 | 24.2 | 9.2 | 3.3 | 245 | 255 | 1 | 639.0508 | 142.2 | 200 | 10 | 0.6291136 | 0.1 | 40 | 5 | 0.07 | 0.02 | 240 | 20 | 0.08 | 0.02 | 0 | 365 | 737.5001 | 0.6886102 | 200 | 0.55 | 400 | 65 | 0.21 | 0.15 | 0.23 | ‘maize’ | 2050 | 0.50 | 500 | 50 | 8 | 28 | 2.10 | 100 | 12 | 34 | 50 | 0.01 | 1.2 | 105 | 275 | 0.8494411 | 223.7372 |
| 0 | 37 | 12.8 | 2.2 | 6.8 | 7.9 | 24.2 | 9.2 | 3.3 | 245 | 255 | 1 | 639.0508 | 142.2 | 200 | 10 | 0.6291136 | 0.1 | 40 | 5 | 0.07 | 0.02 | 240 | 20 | 0.08 | 0.02 | 0 | 365 | 737.5001 | 0.6886102 | 200 | 0.55 | 400 | 65 | 0.21 | 0.15 | 0.23 | ‘soybean 1’ | 2500 | 0.35 | 680 | 300 | 6 | 27 | 0.86 | 120 | 20 | 36 | 50 | 0.07 | 0.9 | 150 | 300 | 0.8006312 | 168.4111 |
| 0 | 37 | 12.8 | 2.2 | 6.8 | 7.9 | 24.2 | 9.2 | 3.3 | 245 | 255 | 1 | 639.0508 | 142.2 | 200 | 10 | 0.6291136 | 0.1 | 40 | 5 | 0.07 | 0.02 | 240 | 20 | 0.08 | 0.02 | 0 | 365 | 737.5001 | 0.6886102 | 200 | 0.55 | 400 | 65 | 0.21 | 0.15 | 0.23 | ‘soybean 2’ | 2350 | 0.40 | 600 | 200 | 6 | 27 | 0.86 | 120 | 20 | 36 | 50 | 0.07 | 0.9 | 150 | 300 | 0.8006312 | 194.5738 |
Visualise simulation results for all crops included in Zhao et al. 2019 (except those taking more than a year to reach maturity; i.e. banana, cotton, peanut and cassava). NOTE: banana is already not used for simulations.
Reconstruct cropTable content:
cropTableNames <- c("crop", "T_sum", "HI", "I_50A", "I_50B", "T_base", "T_opt", "RUE", "I_50maxH", "I_50maxW", "T_heat", "T_extreme", "S_CO2", "S_water", "sowingDay", "harvestDay")
cropTable <- data.frame(matrix(ncol=length(cropTableNames),nrow=0, dimnames=list(NULL, cropTableNames)))
for (aCrop in levels(yieldData$crop))
{
cropTable <- rbind(cropTable, yieldData[match(aCrop, yieldData$crop), cropTableNames])
}
Filter out cassava, cotton and peanut:
notAnnualCrops <- c(" 'cassava'", " 'cotton'", " 'peanut'")
notAnnual <- yieldData$crop == " 'cassava'" | yieldData$crop == " 'cotton'" | yieldData$crop == " 'peanut'"
yieldData <- yieldData[!notAnnual,]
# crop factor variable needs resetting levels
yieldData$crop <- factor(yieldData$crop)
Get vector of colours to represent crops:
cropColours <- rainbow(nlevels(yieldData$crop), s = 0.8, end = 0.9)
Scale and centre yield values for each crop:
yieldData$yield_scaledByCrop <- ave(yieldData$yield, yieldData$crop, FUN = function(x) scale(x) )
Precalculate ranges of ARID and yield:
minARID = round(min(c(yieldData$meanARID, yieldData$meanARID_grow), na.rm = TRUE), digits = 2)
maxARID = round(max(c(yieldData$meanARID, yieldData$meanARID_grow), na.rm = TRUE), digits = 2)
minYield = round(min(yieldData$yield), digits = -1)
maxYield = round(max(yieldData$yield), digits = -1)
minYield_scaledByCrop = round(min(yieldData$yield_scaledByCrop), digits = 2)
maxYield_scaledByCrop = round(max(yieldData$yield_scaledByCrop), digits = 2)
minPrecipitation_yearlyMean = round(min(yieldData$precipitation_yearlyMean), digits = -2)
maxPrecipitation_yearlyMean = round(max(yieldData$precipitation_yearlyMean), digits = -2)
minPrecipitation_dailyCum_plateauValue_yearlyMean = round(min(yieldData$precipitation_dailyCum_plateauValue_yearlyMean), digits = 2)
maxPrecipitation_dailyCum_plateauValue_yearlyMean = round(max(yieldData$precipitation_dailyCum_plateauValue_yearlyMean), digits = 2)
yieldData_summary <- tapply(as.numeric(as.character(yieldData$yield)), yieldData$crop, summary)
yieldData_summary <- data.frame(Reduce(rbind, yieldData_summary), row.names = names(yieldData_summary))
knitr::kable(yieldData_summary)
| Min. | X1st.Qu. | Median | Mean | X3rd.Qu. | Max. | |
|---|---|---|---|---|---|---|
| ‘carrot’ | 0.00000 | 0.000000 | 0.00000 | 0.1665815 | 0.00000 | 97.01524 |
| ‘dry bean’ | 35.98054 | 98.241292 | 132.12884 | 129.6697565 | 161.50295 | 247.86020 |
| ‘greenbean’ | 243.13830 | 319.196982 | 336.64848 | 337.8609149 | 355.70153 | 444.89771 |
| ‘maize’ | 0.00000 | 103.998285 | 220.02057 | 235.8267947 | 348.62691 | 831.34122 |
| ‘potato 1’ | 1065.71637 | 1312.172671 | 1366.49519 | 1370.2537533 | 1427.78794 | 1686.03927 |
| ‘potato 2’ | 941.00835 | 1165.985175 | 1216.55767 | 1220.2623508 | 1273.33788 | 1513.11341 |
| ‘potato 3’ | 529.31720 | 655.866661 | 684.31369 | 686.3975723 | 716.25256 | 851.12629 |
| ‘potato 4’ | 529.31720 | 655.866661 | 684.31369 | 686.3975723 | 716.25256 | 851.12629 |
| ‘potato 5’ | 1128.40557 | 1389.359299 | 1446.87726 | 1450.8569152 | 1511.77546 | 1785.21805 |
| ‘potato 6’ | 1135.46595 | 1397.211989 | 1454.61066 | 1458.7070872 | 1519.59710 | 1793.55309 |
| ‘rice’ | 0.00000 | 150.427378 | 208.95435 | 201.8079730 | 257.90527 | 436.30553 |
| ‘soybean 1’ | 69.11485 | 151.944920 | 187.00416 | 183.8261480 | 217.16658 | 348.47066 |
| ‘soybean 2’ | 81.06928 | 176.096536 | 216.35914 | 212.8927633 | 251.26748 | 403.68122 |
| ‘sweetcorn’ | 0.00000 | 8.261427 | 47.08890 | 55.6329928 | 90.63476 | 275.10819 |
| ‘tomato 1’ | 0.00000 | 1.901455 | 33.05194 | 41.0741315 | 69.46324 | 238.57088 |
| ‘tomato 2’ | 0.00000 | 1.398129 | 24.29444 | 30.2004091 | 51.07591 | 175.41976 |
| ‘wheat 1’ | 0.00000 | 317.291874 | 377.43914 | 309.3555905 | 412.33549 | 480.86284 |
| ‘wheat 2’ | 0.00000 | 329.952429 | 388.37947 | 317.9734044 | 422.30297 | 489.28420 |
plotName = "plots/SIMPLE-crop-model/yieldPerCrop.png"
grScale = 2
fontRescale = 0
fontRescaleDay = 0
png(plotName, width = grScale * 500, height = grScale * 300)
par(mar = c(6,5,1,1))
boxplot(yield ~ factor(crop), data = yieldData,#[yieldData$yield > 0,], # show only non-zero yield
ylab = expression(paste("yield (", g/m^2, ")")), xlab = "",
las = 2,
col = cropColours)
dev.off()
## png
## 2
knitr::include_graphics(plotName)
plotName = "plots/SIMPLE-crop-model/yield_scaledPerCrop.png"
grScale = 2
fontRescale = 0
fontRescaleDay = 0
png(plotName, width = grScale * 500, height = grScale * 300)
par(mar = c(6,5,1,1))
boxplot(yield_scaledByCrop ~ factor(crop), data = yieldData,#[yieldData$yield > 0,], # show only non-zero yield
ylab = expression(paste("scaled yield (", g/m^2, ")")), xlab = "",
las = 2,
col = cropColours)
dev.off()
## png
## 2
knitr::include_graphics(plotName)
Plotting ARID vs precipitation yearly mean:
plotName = "plots/SIMPLE-crop-model/ARIDvsPrecipitation_yearlyMean.png"
grScale = 2
fontRescale = 0.5
png(plotName, width = grScale * 500, height = grScale * 300)
layout(matrix(c(1, 2, 3, 4, 4, 4), nrow = 3, ncol = 2),
heights = c(10, 10, 2), widths = c(10, 3))
par(mar = c(1,5,1,1), cex.lab = 0.8 * grScale)
plot(c(minPrecipitation_yearlyMean, maxPrecipitation_yearlyMean),
c(minARID, maxARID),
xaxt ='n',
xlab = "",
ylab = "mean ARID (current year)")
for (aCrop in levels(yieldData$crop))
{
points(yieldData$precipitation_yearlyMean[yieldData$crop == aCrop],
yieldData$meanARID[yieldData$crop == aCrop],
col = cropColours[match(aCrop, levels(yieldData$crop))],
pch = 20
)
abline(lm(meanARID ~ precipitation_yearlyMean, data = yieldData[yieldData$crop == aCrop,]),
col = cropColours[match(aCrop, levels(yieldData$crop))],
lwd = 2)
}
plot(c(minPrecipitation_yearlyMean, maxPrecipitation_yearlyMean),
c(minARID, maxARID),
xaxt ='n',
xlab = "",
ylab = "mean ARID (grow seasons)")
for (aCrop in levels(yieldData$crop))
{
points(yieldData$precipitation_yearlyMean[yieldData$crop == aCrop],
yieldData$meanARID_grow[yieldData$crop == aCrop],
col = cropColours[match(aCrop, levels(yieldData$crop))],
pch = 20
)
abline(lm(meanARID_grow ~ precipitation_yearlyMean, data = yieldData[yieldData$crop == aCrop,]),
col = cropColours[match(aCrop, levels(yieldData$crop))],
lwd = 2)
}
par(mar = c(1, 1, 1, 0.1))
plot(c(minPrecipitation_yearlyMean, maxPrecipitation_yearlyMean), c(0, 1), ann = F, bty = 'n', type = 'n', xaxt = 'n', yaxt = 'n')
axis(3,
at = seq(minPrecipitation_yearlyMean, maxPrecipitation_yearlyMean, by = 50),
tck = 0, lwd = 0)
mtext("precipitation yearly mean (mm)", side = 1, line = -2)
par(mar = c(0, 0, 0, 0), cex = 0.8 * grScale)
plot(c(0, 1), c(0, 1), ann = F, bty = 'n', type = 'n', xaxt = 'n', yaxt = 'n')
legend(x = 0, y = 1,
legend = stringi::stri_c(cropTable$S_water[!cropTable$crop %in% notAnnualCrops], " (", levels(yieldData$crop), ")"),
title = "S_water (Crop-cultivar)",
fill = cropColours)
dev.off()
## png
## 2
knitr::include_graphics(plotName)
Plotting ARID vs precipitation seasonal balance (plateau value):
plotName = "plots/SIMPLE-crop-model/ARIDvsPrecipitation_dailyCum_plateauValue_yearlyMean.png"
grScale = 2
fontRescale = 0.5
png(plotName, width = grScale * 500, height = grScale * 300)
layout(matrix(c(1, 2, 3, 4, 4, 4), nrow = 3, ncol = 2),
heights = c(10, 10, 2), widths = c(10, 3))
par(mar = c(1,5,1,1), cex.lab = 0.8 * grScale)
plot(c(minPrecipitation_dailyCum_plateauValue_yearlyMean, maxPrecipitation_dailyCum_plateauValue_yearlyMean),
c(minARID, maxARID),
xaxt ='n',
xlab = "",
ylab = "mean ARID (current year)")
for (aCrop in levels(yieldData$crop))
{
points(yieldData$precipitation_dailyCum_plateauValue_yearlyMean[yieldData$crop == aCrop],
yieldData$meanARID[yieldData$crop == aCrop],
col = cropColours[match(aCrop, levels(yieldData$crop))],
pch = 20
)
abline(lm(meanARID ~ precipitation_dailyCum_plateauValue_yearlyMean, data = yieldData[yieldData$crop == aCrop,]),
col = cropColours[match(aCrop, levels(yieldData$crop))],
lwd = 2)
}
#points(yieldData$precipitation_dailyCum_plateauValue_yearlyMean, yieldData$meanARID, pch = 20)
#abline(lm(meanARID ~ precipitation_dailyCum_plateauValue_yearlyMean, data = yieldData), lwd = 2, col = "royalblue")
plot(c(minPrecipitation_dailyCum_plateauValue_yearlyMean, maxPrecipitation_dailyCum_plateauValue_yearlyMean),
c(minARID, maxARID),
xaxt ='n',
xlab = "",
ylab = "mean ARID (grow seasons)")
for (aCrop in levels(yieldData$crop))
{
points(yieldData$precipitation_dailyCum_plateauValue_yearlyMean[yieldData$crop == aCrop],
yieldData$meanARID_grow[yieldData$crop == aCrop],
col = cropColours[match(aCrop, levels(yieldData$crop))],
pch = 20
)
abline(lm(meanARID_grow ~ precipitation_dailyCum_plateauValue_yearlyMean, data = yieldData[yieldData$crop == aCrop,]),
col = cropColours[match(aCrop, levels(yieldData$crop))],
lwd = 2)
}
#points(yieldData$precipitation_dailyCum_plateauValue_yearlyMean, yieldData$meanARID_grow, pch = 20)
#abline(lm(meanARID_grow ~ precipitation_dailyCum_plateauValue_yearlyMean, data = yieldData), lwd = 2, col = "royalblue")
par(mar = c(1, 1, 1, 0.1))
plot(c(minPrecipitation_dailyCum_plateauValue_yearlyMean, maxPrecipitation_dailyCum_plateauValue_yearlyMean), c(0, 1),
ann = F, bty = 'n', type = 'n', xaxt = 'n', yaxt = 'n')
axis(3,
at = seq(minPrecipitation_dailyCum_plateauValue_yearlyMean, maxPrecipitation_dailyCum_plateauValue_yearlyMean, by = 0.1),
tck = 0, lwd = 0)
mtext("precipitation plateau value (i.e. winter / summer) yearly mean (mm)", side = 1, line = -2)
par(mar = c(0, 0, 0, 0), cex = 0.8 * grScale)
plot(c(0, 1), c(0, 1), ann = F, bty = 'n', type = 'n', xaxt = 'n', yaxt = 'n')
legend(x = 0, y = 1,
legend = stringi::stri_c(cropTable$S_water[!cropTable$crop %in% notAnnualCrops], " (", levels(yieldData$crop), ")"),
title = "S_water (Crop-cultivar)",
fill = cropColours)
dev.off()
## png
## 2
knitr::include_graphics(plotName)
Plotting absolute values of yield vs ARID:
plotName = "plots/SIMPLE-crop-model/yieldVsARID.png"
grScale = 2
fontRescale = 0
fontRescaleDay = 0
png(plotName, width = grScale * 500, height = grScale * 300)
layout(matrix(c(1, 2, 3, 3), nrow = 2, ncol = 2, byrow = FALSE),
widths = c(10, 3))
par(mar = c(5,5,1,1), cex.lab = 0.8 * grScale)
plot(c(minARID, maxARID),
c(minYield, maxYield),
xlab = "mean ARID (current year)",
ylab = expression(paste("yield (", g/m^2, ")")))
for (aCrop in levels(yieldData$crop))
{
points(yieldData$meanARID[yieldData$crop == aCrop],
yieldData$yield[yieldData$crop == aCrop],
col = cropColours[match(aCrop, levels(yieldData$crop))],
pch = 20
)
abline(lm(yield ~ meanARID, data = yieldData[yieldData$crop == aCrop,]),
col = cropColours[match(aCrop, levels(yieldData$crop))],
lwd = 2)
}
plot(c(minARID, maxARID),
c(minYield, maxYield),
xlab = "mean ARID (grow season)",
ylab = expression(paste("yield (", g/m^2, ")")))
for (aCrop in levels(yieldData$crop))
{
points(yieldData$meanARID_grow[yieldData$crop == aCrop],
yieldData$yield[yieldData$crop == aCrop],
col = cropColours[match(aCrop, levels(yieldData$crop))],
pch = 20
)
abline(lm(yield ~ meanARID_grow, data = yieldData[yieldData$crop == aCrop,]),
col = cropColours[match(aCrop, levels(yieldData$crop))],
lwd = 2)
}
par(mar = c(0, 0, 0, 0), cex = 0.8 * grScale)
plot(c(0, 1), c(0, 1), ann = F, bty = 'n', type = 'n', xaxt = 'n', yaxt = 'n')
legend(x = 0, y = 1,
legend = stringi::stri_c(cropTable$S_water[!cropTable$crop %in% notAnnualCrops], " (", levels(yieldData$crop), ")"),
title = "S_water (Crop-cultivar)",
fill = cropColours)
dev.off()
## png
## 2
knitr::include_graphics(plotName)
Calculate correlation and linear models fitness:
linearModels.table <- data.frame(
levels(yieldData$crop),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop))
)
names(linearModels.table) <- c("crop", "correlation_Pearson", "intercept", "intercept_p", "speed", "speed_p", "adjrsquared")
for (aCrop in levels(yieldData$crop))
{
linearModels.table$correlation_Pearson[linearModels.table$crop == aCrop] <-
cor(x = yieldData$meanARID_grow[yieldData$crop == aCrop], y = yieldData$yield[yieldData$crop == aCrop], use = "pairwise.complete.obs")
linearModel <- lm(yield ~ meanARID_grow, data = yieldData[yieldData$crop == aCrop,])
linearModels.table$intercept[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[1,1]
linearModels.table$intercept_p[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[1,4]
linearModels.table$speed[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[2,1]
linearModels.table$speed_p[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[2,4]
linearModels.table$adjrsquared[linearModels.table$crop == aCrop] <- summary(linearModel)$adj.r.squared
}
knitr::kable(linearModels.table)
| crop | correlation_Pearson | intercept | intercept_p | speed | speed_p | adjrsquared |
|---|---|---|---|---|---|---|
| ‘carrot’ | -0.0979705 | 2.731434 | 0 | -2.876506 | 0 | 0.0094992 |
| ‘dry bean’ | -0.9674298 | 414.852175 | 0 | -363.574269 | 0 | 0.9359140 |
| ‘greenbean’ | -0.5288370 | 445.241789 | 0 | -133.518588 | 0 | 0.2795965 |
| ‘maize’ | -0.9503277 | 1957.405295 | 0 | -2057.518204 | 0 | 0.9031131 |
| ‘potato 1’ | -0.4629823 | 1779.997291 | 0 | -489.988397 | 0 | 0.2142740 |
| ‘potato 2’ | -0.4637844 | 1602.484342 | 0 | -457.076984 | 0 | 0.2150174 |
| ‘potato 3’ | -0.4637844 | 901.397442 | 0 | -257.105804 | 0 | 0.2150174 |
| ‘potato 4’ | -0.4637844 | 901.397442 | 0 | -257.105804 | 0 | 0.2150174 |
| ‘potato 5’ | -0.4629823 | 1884.703014 | 0 | -518.811244 | 0 | 0.2142740 |
| ‘potato 6’ | -0.4628653 | 1892.867905 | 0 | -519.187598 | 0 | 0.2141657 |
| ‘rice’ | -0.9726496 | 715.349341 | 0 | -682.094685 | 0 | 0.9460419 |
| ‘soybean 1’ | -0.9568653 | 551.341044 | 0 | -468.041358 | 0 | 0.9155828 |
| ‘soybean 2’ | -0.9545098 | 636.502757 | 0 | -539.480165 | 0 | 0.9110800 |
| ‘sweetcorn’ | -0.8946093 | 553.202717 | 0 | -594.662843 | 0 | 0.8003058 |
| ‘tomato 1’ | -0.8322057 | 382.269316 | 0 | -408.015419 | 0 | 0.6925356 |
| ‘tomato 2’ | -0.8321503 | 281.051421 | 0 | -299.978093 | 0 | 0.6924434 |
| ‘wheat 1’ | -0.9287574 | 524.068544 | 0 | -230.506279 | 0 | 0.8625731 |
| ‘wheat 2’ | -0.9424935 | 531.331676 | 0 | -224.618138 | 0 | 0.8882800 |
Plotting scaled values of yield vs ARID:
plotName = "plots/SIMPLE-crop-model/yieldVsARID_scaled.png"
grScale = 2
fontRescale = 0
fontRescaleDay = 0
png(plotName, width = grScale * 500, height = grScale * 300)
layout(matrix(c(1, 2, 3, 3), nrow = 2, ncol = 2, byrow = FALSE),
widths = c(10, 3))
par(mar = c(5,5,1,1), cex.lab = 0.8 * grScale)
plot(c(minARID, maxARID),
c(minYield_scaledByCrop, maxYield_scaledByCrop),
xlab = "mean ARID (current year)",
ylab = expression(paste("scaled yield (", g/m^2, ")")))
for (aCrop in levels(yieldData$crop))
{
points(yieldData$meanARID[yieldData$crop == aCrop],
yieldData$yield_scaledByCrop[yieldData$crop == aCrop],
col = cropColours[match(aCrop, levels(yieldData$crop))],
pch = 20
)
if (max(yieldData$yield_scaledByCrop[yieldData$crop == aCrop], na.rm = T) > 0)
{
abline(lm(yieldData$yield_scaledByCrop[yieldData$crop == aCrop] ~ yieldData$meanARID[yieldData$crop == aCrop]),
col = cropColours[match(aCrop, levels(yieldData$crop))],
lwd = 2)
}
}
plot(c(minARID, maxARID),
c(minYield_scaledByCrop, maxYield_scaledByCrop),
xlab = "mean ARID (grow season)",
ylab = expression(paste("scaled yield (", g/m^2, ")")))
for (aCrop in levels(yieldData$crop))
{
points(yieldData$meanARID_grow[yieldData$crop == aCrop],
yieldData$yield_scaledByCrop[yieldData$crop == aCrop],
col = cropColours[match(aCrop, levels(yieldData$crop))],
pch = 20
)
if (max(yieldData$yield_scaledByCrop[yieldData$crop == aCrop], na.rm = T) > 0)
{
abline(lm(yieldData$yield_scaledByCrop[yieldData$crop == aCrop] ~ yieldData$meanARID_grow[yieldData$crop == aCrop]),
col = cropColours[match(aCrop, levels(yieldData$crop))],
lwd = 2)
}
}
par(mar = c(0, 0, 0, 0), cex = 0.8 * grScale)
plot(c(0, 1), c(0, 1), ann = F, bty = 'n', type = 'n', xaxt = 'n', yaxt = 'n')
legend(x = 0, y = 1,
legend = stringi::stri_c(cropTable$S_water[!cropTable$crop %in% notAnnualCrops], " (", levels(yieldData$crop), ")"),
title = "S_water (Crop-cultivar)",
fill = cropColours)
dev.off()
## png
## 2
knitr::include_graphics(plotName)
Calculate correlation and linear models fitness:
linearModels.table <- data.frame(
levels(yieldData$crop),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop))
)
names(linearModels.table) <- c("crop", "correlation_Pearson", "intercept", "intercept_p", "speed", "speed_p", "adjrsquared")
for (aCrop in levels(yieldData$crop))
{
linearModels.table$correlation_Pearson[linearModels.table$crop == aCrop] <-
cor(x = yieldData$meanARID_grow[yieldData$crop == aCrop], y = yieldData$yield_scaledByCrop[yieldData$crop == aCrop], use = "pairwise.complete.obs")
linearModel <- lm(yield_scaledByCrop ~ meanARID_grow, data = yieldData[yieldData$crop == aCrop,])
linearModels.table$intercept[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[1,1]
linearModels.table$intercept_p[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[1,4]
linearModels.table$speed[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[2,1]
linearModels.table$speed_p[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[2,4]
linearModels.table$adjrsquared[linearModels.table$crop == aCrop] <- summary(linearModel)$adj.r.squared
}
knitr::kable(linearModels.table)
| crop | correlation_Pearson | intercept | intercept_p | speed | speed_p | adjrsquared |
|---|---|---|---|---|---|---|
| ‘carrot’ | -0.0979705 | 0.9319985 | 0 | -1.045245 | 0 | 0.0094992 |
| ‘dry bean’ | -0.9674298 | 6.9539468 | 0 | -8.865470 | 0 | 0.9359140 |
| ‘greenbean’ | -0.5288370 | 4.0249168 | 0 | -5.004627 | 0 | 0.2795965 |
| ‘maize’ | -0.9503277 | 10.5918464 | 0 | -12.658683 | 0 | 0.9031131 |
| ‘potato 1’ | -0.4629823 | 4.8353651 | 0 | -5.782331 | 0 | 0.2142740 |
| ‘potato 2’ | -0.4637844 | 4.8437418 | 0 | -5.792348 | 0 | 0.2150174 |
| ‘potato 3’ | -0.4637844 | 4.8437418 | 0 | -5.792348 | 0 | 0.2150174 |
| ‘potato 4’ | -0.4637844 | 4.8437418 | 0 | -5.792348 | 0 | 0.2150174 |
| ‘potato 5’ | -0.4629823 | 4.8353651 | 0 | -5.782331 | 0 | 0.2142740 |
| ‘potato 6’ | -0.4628653 | 4.8341430 | 0 | -5.780870 | 0 | 0.2141657 |
| ‘rice’ | -0.9726496 | 6.3969064 | 0 | -8.496484 | 0 | 0.9460419 |
| ‘soybean 1’ | -0.9568653 | 7.9521936 | 0 | -10.127360 | 0 | 0.9155828 |
| ‘soybean 2’ | -0.9545098 | 7.9326176 | 0 | -10.102429 | 0 | 0.9110800 |
| ‘sweetcorn’ | -0.8946093 | 9.9708383 | 0 | -11.916495 | 0 | 0.8003058 |
| ‘tomato 1’ | -0.8322057 | 8.6915165 | 0 | -10.393678 | 0 | 0.6925356 |
| ‘tomato 2’ | -0.8321503 | 8.6909380 | 0 | -10.392986 | 0 | 0.6924434 |
| ‘wheat 1’ | -0.9287574 | 1.3511318 | 0 | -1.450515 | 0 | 0.8625731 |
| ‘wheat 2’ | -0.9424935 | 1.3106036 | 0 | -1.379770 | 0 | 0.8882800 |
Plotting absolute values of yield vs precipitation yearly mean:
plotName = "plots/SIMPLE-crop-model/yieldVsprecipitation_yearlyMean.png"
grScale = 2
fontRescale = 0
fontRescaleDay = 0
png(plotName, width = grScale * 500, height = grScale * 300)
layout(matrix(c(1, 2), nrow = 1, ncol = 2, byrow = FALSE),
widths = c(10, 3))
par(mar = c(5,5,1,1), cex.lab = 0.8 * grScale)
plot(c(minPrecipitation_yearlyMean, maxPrecipitation_yearlyMean),
c(minYield, maxYield),
xlab = "precipitation yearly mean (mm)",
ylab = expression(paste("yield (", g/m^2, ")")))
for (aCrop in levels(yieldData$crop))
{
points(yieldData$precipitation_yearlyMean[yieldData$crop == aCrop],
yieldData$yield[yieldData$crop == aCrop],
col = cropColours[match(aCrop, levels(yieldData$crop))],
pch = 20
)
abline(lm(yield ~ precipitation_yearlyMean, data = yieldData[yieldData$crop == aCrop,]),
col = cropColours[match(aCrop, levels(yieldData$crop))],
lwd = 2)
}
par(mar = c(0, 0, 0, 0), cex = 0.8 * grScale)
plot(c(0, 1), c(0, 1), ann = F, bty = 'n', type = 'n', xaxt = 'n', yaxt = 'n')
legend(x = 0, y = 1,
legend = stringi::stri_c(cropTable$S_water[!cropTable$crop %in% notAnnualCrops], " (", levels(yieldData$crop), ")"),
title = "S_water (Crop-cultivar)",
fill = cropColours)
dev.off()
## png
## 2
knitr::include_graphics(plotName)
Calculate correlation and linear models fitness:
linearModels.table <- data.frame(
levels(yieldData$crop),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop))
)
names(linearModels.table) <- c("crop", "correlation_Pearson", "intercept", "intercept_p", "speed", "speed_p", "adjrsquared")
for (aCrop in levels(yieldData$crop))
{
linearModels.table$correlation_Pearson[linearModels.table$crop == aCrop] <-
cor(x = yieldData$precipitation_yearlyMean[yieldData$crop == aCrop], y = yieldData$yield[yieldData$crop == aCrop], use = "pairwise.complete.obs")
linearModel <- lm(yield ~ precipitation_yearlyMean, data = yieldData[yieldData$crop == aCrop,])
linearModels.table$intercept[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[1,1]
linearModels.table$intercept_p[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[1,4]
linearModels.table$speed[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[2,1]
linearModels.table$speed_p[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[2,4]
linearModels.table$adjrsquared[linearModels.table$crop == aCrop] <- summary(linearModel)$adj.r.squared
}
knitr::kable(linearModels.table)
| crop | correlation_Pearson | intercept | intercept_p | speed | speed_p | adjrsquared |
|---|---|---|---|---|---|---|
| ‘carrot’ | 0.0332306 | -0.064567 | 0.3878647 | 0.0003926 | 0.0008888 | 0.0010044 |
| ‘dry bean’ | 0.5028444 | 77.546628 | 0.0000000 | 0.0885327 | 0.0000000 | 0.2527777 |
| ‘greenbean’ | 0.2377100 | 321.831305 | 0.0000000 | 0.0272268 | 0.0000000 | 0.0564117 |
| ‘maize’ | 0.5265678 | 19.497711 | 0.0000002 | 0.3674415 | 0.0000000 | 0.2772013 |
| ‘potato 1’ | 0.2241723 | 1322.239483 | 0.0000000 | 0.0815537 | 0.0000000 | 0.0501582 |
| ‘potato 2’ | 0.2232947 | 1175.725594 | 0.0000000 | 0.0756470 | 0.0000000 | 0.0497655 |
| ‘potato 3’ | 0.2232947 | 661.345647 | 0.0000000 | 0.0425515 | 0.0000000 | 0.0497655 |
| ‘potato 4’ | 0.2232947 | 661.345647 | 0.0000000 | 0.0425515 | 0.0000000 | 0.0497655 |
| ‘potato 5’ | 0.2241723 | 1400.018276 | 0.0000000 | 0.0863510 | 0.0000000 | 0.0501582 |
| ‘potato 6’ | 0.2242794 | 1407.794392 | 0.0000000 | 0.0864768 | 0.0000000 | 0.0502063 |
| ‘rice’ | 0.5472361 | 90.766389 | 0.0000000 | 0.1886075 | 0.0000000 | 0.2993973 |
| ‘soybean 1’ | 0.5841673 | 115.587446 | 0.0000000 | 0.1159055 | 0.0000000 | 0.3411856 |
| ‘soybean 2’ | 0.5833306 | 134.157382 | 0.0000000 | 0.1337344 | 0.0000000 | 0.3402086 |
| ‘sweetcorn’ | 0.5581051 | -14.762316 | 0.0000000 | 0.1195686 | 0.0000000 | 0.3114124 |
| ‘tomato 1’ | 0.5528879 | -13.785126 | 0.0000000 | 0.0931801 | 0.0000000 | 0.3056156 |
| ‘tomato 2’ | 0.5528646 | -10.133796 | 0.0000000 | 0.0685089 | 0.0000000 | 0.3055898 |
| ‘wheat 1’ | 0.1168810 | 262.408352 | 0.0000000 | 0.0797413 | 0.0000000 | 0.0135625 |
| ‘wheat 2’ | 0.1116123 | 272.047700 | 0.0000000 | 0.0780062 | 0.0000000 | 0.0123585 |
Plotting scaled values of yield vs precipitation yearly mean:
plotName = "plots/SIMPLE-crop-model/yield_scaledByCropVsprecipitation_yearlyMean.png"
grScale = 2
fontRescale = 0
fontRescaleDay = 0
png(plotName, width = grScale * 500, height = grScale * 300)
layout(matrix(c(1, 2), nrow = 1, ncol = 2, byrow = FALSE),
widths = c(10, 3))
par(mar = c(5,5,1,1), cex.lab = 0.8 * grScale)
plot(c(minPrecipitation_yearlyMean, maxPrecipitation_yearlyMean),
c(minYield_scaledByCrop, maxYield_scaledByCrop),
xlab = "precipitation yearly mean (mm)",
ylab = expression(paste("scaled yield (", g/m^2, ")")))
for (aCrop in levels(yieldData$crop))
{
points(yieldData$precipitation_yearlyMean[yieldData$crop == aCrop],
yieldData$yield_scaledByCrop[yieldData$crop == aCrop],
col = cropColours[match(aCrop, levels(yieldData$crop))],
pch = 20
)
abline(lm(yield_scaledByCrop ~ precipitation_yearlyMean, data = yieldData[yieldData$crop == aCrop,]),
col = cropColours[match(aCrop, levels(yieldData$crop))],
lwd = 2)
}
par(mar = c(0, 0, 0, 0), cex = 0.8 * grScale)
plot(c(0, 1), c(0, 1), ann = F, bty = 'n', type = 'n', xaxt = 'n', yaxt = 'n')
legend(x = 0, y = 1,
legend = stringi::stri_c(cropTable$S_water[!cropTable$crop %in% notAnnualCrops], " (", levels(yieldData$crop), ")"),
title = "S_water (Crop-cultivar)",
fill = cropColours)
dev.off()
## png
## 2
knitr::include_graphics(plotName)
Calculate correlation and linear models fitness:
linearModels.table <- data.frame(
levels(yieldData$crop),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop))
)
names(linearModels.table) <- c("crop", "correlation_Pearson", "intercept", "intercept_p", "speed", "speed_p", "adjrsquared")
for (aCrop in levels(yieldData$crop))
{
linearModels.table$correlation_Pearson[linearModels.table$crop == aCrop] <-
cor(x = yieldData$precipitation_yearlyMean[yieldData$crop == aCrop], y = yieldData$yield_scaledByCrop[yieldData$crop == aCrop], use = "pairwise.complete.obs")
linearModel <- lm(yield_scaledByCrop ~ precipitation_yearlyMean, data = yieldData[yieldData$crop == aCrop,])
linearModels.table$intercept[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[1,1]
linearModels.table$intercept_p[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[1,4]
linearModels.table$speed[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[2,1]
linearModels.table$speed_p[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[2,4]
linearModels.table$adjrsquared[linearModels.table$crop == aCrop] <- summary(linearModel)$adj.r.squared
}
knitr::kable(linearModels.table)
| crop | correlation_Pearson | intercept | intercept_p | speed | speed_p | adjrsquared |
|---|---|---|---|---|---|---|
| ‘carrot’ | 0.0332306 | -0.0839932 | 0.0019974 | 0.0001427 | 0.0008888 | 0.0010044 |
| ‘dry bean’ | 0.5028444 | -1.2709811 | 0.0000000 | 0.0021588 | 0.0000000 | 0.2527777 |
| ‘greenbean’ | 0.2377100 | -0.6008318 | 0.0000000 | 0.0010205 | 0.0000000 | 0.0564117 |
| ‘maize’ | 0.5265678 | -1.3309439 | 0.0000000 | 0.0022606 | 0.0000000 | 0.2772013 |
| ‘potato 1’ | 0.2241723 | -0.5666142 | 0.0000000 | 0.0009624 | 0.0000000 | 0.0501582 |
| ‘potato 2’ | 0.2232947 | -0.5643960 | 0.0000000 | 0.0009586 | 0.0000000 | 0.0497655 |
| ‘potato 3’ | 0.2232947 | -0.5643960 | 0.0000000 | 0.0009586 | 0.0000000 | 0.0497655 |
| ‘potato 4’ | 0.2232947 | -0.5643960 | 0.0000000 | 0.0009586 | 0.0000000 | 0.0497655 |
| ‘potato 5’ | 0.2241723 | -0.5666142 | 0.0000000 | 0.0009624 | 0.0000000 | 0.0501582 |
| ‘potato 6’ | 0.2242794 | -0.5668850 | 0.0000000 | 0.0009629 | 0.0000000 | 0.0502063 |
| ‘rice’ | 0.5472361 | -1.3831848 | 0.0000000 | 0.0023494 | 0.0000000 | 0.2993973 |
| ‘soybean 1’ | 0.5841673 | -1.4765316 | 0.0000000 | 0.0025079 | 0.0000000 | 0.3411856 |
| ‘soybean 2’ | 0.5833306 | -1.4744167 | 0.0000000 | 0.0025043 | 0.0000000 | 0.3402086 |
| ‘sweetcorn’ | 0.5581051 | -1.4106570 | 0.0000000 | 0.0023960 | 0.0000000 | 0.3114124 |
| ‘tomato 1’ | 0.5528879 | -1.3974703 | 0.0000000 | 0.0023736 | 0.0000000 | 0.3056156 |
| ‘tomato 2’ | 0.5528646 | -1.3974114 | 0.0000000 | 0.0023735 | 0.0000000 | 0.3055898 |
| ‘wheat 1’ | 0.1168810 | -0.2954266 | 0.0000000 | 0.0005018 | 0.0000000 | 0.0135625 |
| ‘wheat 2’ | 0.1116123 | -0.2821095 | 0.0000000 | 0.0004792 | 0.0000000 | 0.0123585 |
Plotting absolute values of yield vs precipitation seasonal balance (plateau value):
plotName = "plots/SIMPLE-crop-model/yieldVsprecipitation_dailyCum_plateauValue_yearlyMean.png"
grScale = 2
fontRescale = 0
fontRescaleDay = 0
png(plotName, width = grScale * 500, height = grScale * 300)
layout(matrix(c(1, 2), nrow = 1, ncol = 2, byrow = FALSE),
widths = c(10, 3))
par(mar = c(5,5,1,1), cex.lab = 0.8 * grScale)
plot(c(minPrecipitation_dailyCum_plateauValue_yearlyMean, maxPrecipitation_dailyCum_plateauValue_yearlyMean),
c(minYield, maxYield),
xlab = "precipitation plateau value (i.e. winter / summer) yearly mean (mm)",
ylab = expression(paste("yield (", g/m^2, ")")))
for (aCrop in levels(yieldData$crop))
{
points(yieldData$precipitation_dailyCum_plateauValue_yearlyMean[yieldData$crop == aCrop],
yieldData$yield[yieldData$crop == aCrop],
col = cropColours[match(aCrop, levels(yieldData$crop))],
pch = 20
)
abline(lm(yield ~ precipitation_dailyCum_plateauValue_yearlyMean, data = yieldData[yieldData$crop == aCrop,]),
col = cropColours[match(aCrop, levels(yieldData$crop))],
lwd = 2)
}
par(mar = c(0, 0, 0, 0), cex = 0.8 * grScale)
plot(c(0, 1), c(0, 1), ann = F, bty = 'n', type = 'n', xaxt = 'n', yaxt = 'n')
legend(x = 0, y = 1,
legend = levels(yieldData$crop),
title = "Crop-cultivar",
fill = cropColours)
dev.off()
## png
## 2
knitr::include_graphics(plotName)
Calculate correlation and linear models fitness:
linearModels.table <- data.frame(
levels(yieldData$crop),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop))
)
names(linearModels.table) <- c("crop", "correlation_Pearson", "intercept", "intercept_p", "speed", "speed_p", "adjrsquared")
for (aCrop in levels(yieldData$crop))
{
linearModels.table$correlation_Pearson[linearModels.table$crop == aCrop] <-
cor(x = yieldData$precipitation_dailyCum_plateauValue_yearlyMean[yieldData$crop == aCrop], y = yieldData$yield[yieldData$crop == aCrop], use = "pairwise.complete.obs")
linearModel <- lm(yield ~ precipitation_dailyCum_plateauValue_yearlyMean, data = yieldData[yieldData$crop == aCrop,])
linearModels.table$intercept[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[1,1]
linearModels.table$intercept_p[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[1,4]
linearModels.table$speed[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[2,1]
linearModels.table$speed_p[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[2,4]
linearModels.table$adjrsquared[linearModels.table$crop == aCrop] <- summary(linearModel)$adj.r.squared
}
knitr::kable(linearModels.table)
| crop | correlation_Pearson | intercept | intercept_p | speed | speed_p | adjrsquared |
|---|---|---|---|---|---|---|
| ‘carrot’ | -0.0378026 | 0.4665989 | 0 | -0.6052557 | 0.0001561 | 0.0013292 |
| ‘dry bean’ | -0.3959118 | 176.4936547 | 0 | -94.4626205 | 0.0000000 | 0.1566618 |
| ‘greenbean’ | -0.1859456 | 352.1674218 | 0 | -28.8619740 | 0.0000000 | 0.0344792 |
| ‘maize’ | -0.4145053 | 430.1223894 | 0 | -391.9722994 | 0.0000000 | 0.1717318 |
| ‘potato 1’ | -0.1624300 | 1409.9479280 | 0 | -80.0791029 | 0.0000000 | 0.0262861 |
| ‘potato 2’ | -0.1653006 | 1257.8795861 | 0 | -75.8890815 | 0.0000000 | 0.0272270 |
| ‘potato 3’ | -0.1653006 | 707.5572672 | 0 | -42.6876084 | 0.0000000 | 0.0272270 |
| ‘potato 4’ | -0.1653006 | 707.5572672 | 0 | -42.6876084 | 0.0000000 | 0.0272270 |
| ‘potato 5’ | -0.1624300 | 1492.8860414 | 0 | -84.7896384 | 0.0000000 | 0.0262861 |
| ‘potato 6’ | -0.1621597 | 1500.7073352 | 0 | -84.7313795 | 0.0000000 | 0.0261984 |
| ‘rice’ | -0.4483065 | 305.5986180 | 0 | -209.3874429 | 0.0000000 | 0.2008988 |
| ‘soybean 1’ | -0.4632393 | 245.5667939 | 0 | -124.5556956 | 0.0000000 | 0.2145121 |
| ‘soybean 2’ | -0.4614171 | 283.9520950 | 0 | -143.3552298 | 0.0000000 | 0.2128270 |
| ‘sweetcorn’ | -0.4639221 | 122.3974114 | 0 | -134.6906640 | 0.0000000 | 0.2151452 |
| ‘tomato 1’ | -0.4679465 | 94.0503848 | 0 | -106.8743933 | 0.0000000 | 0.2188958 |
| ‘tomato 2’ | -0.4679584 | 69.1528045 | 0 | -78.5826359 | 0.0000000 | 0.2189069 |
| ‘wheat 1’ | 0.0980642 | 264.4139541 | 0 | 90.6653419 | 0.0000000 | 0.0095175 |
| ‘wheat 2’ | 0.0924863 | 274.5530706 | 0 | 87.5962633 | 0.0000000 | 0.0084545 |
Plotting scaled values of yield vs precipitation yearly mean:
plotName = "plots/SIMPLE-crop-model/yield_scaledByCropVsprecipitation_dailyCum_plateauValue_yearlyMean.png"
grScale = 2
fontRescale = 0
fontRescaleDay = 0
png(plotName, width = grScale * 500, height = grScale * 300)
layout(matrix(c(1, 2), nrow = 1, ncol = 2, byrow = FALSE),
widths = c(10, 3))
par(mar = c(5,5,1,1), cex.lab = 0.8 * grScale)
plot(c(minPrecipitation_dailyCum_plateauValue_yearlyMean, maxPrecipitation_dailyCum_plateauValue_yearlyMean),
c(minYield_scaledByCrop, maxYield_scaledByCrop),
xlab = "precipitation plateau value (i.e. winter / summer) yearly mean (mm)",
ylab = expression(paste("scaled yield (", g/m^2, ")")))
for (aCrop in levels(yieldData$crop))
{
points(yieldData$precipitation_dailyCum_plateauValue_yearlyMean[yieldData$crop == aCrop],
yieldData$yield_scaledByCrop[yieldData$crop == aCrop],
col = cropColours[match(aCrop, levels(yieldData$crop))],
pch = 20
)
abline(lm(yield_scaledByCrop ~ precipitation_dailyCum_plateauValue_yearlyMean, data = yieldData[yieldData$crop == aCrop,]),
col = cropColours[match(aCrop, levels(yieldData$crop))],
lwd = 2)
}
par(mar = c(0, 0, 0, 0), cex = 0.8 * grScale)
plot(c(0, 1), c(0, 1), ann = F, bty = 'n', type = 'n', xaxt = 'n', yaxt = 'n')
legend(x = 0, y = 1,
legend = levels(yieldData$crop),
title = "Crop-cultivar",
fill = cropColours)
dev.off()
## png
## 2
knitr::include_graphics(plotName)
Calculate correlation and linear models fitness:
linearModels.table <- data.frame(
levels(yieldData$crop),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop))
)
names(linearModels.table) <- c("crop", "correlation_Pearson", "intercept", "intercept_p", "speed", "speed_p", "adjrsquared")
for (aCrop in levels(yieldData$crop))
{
linearModels.table$correlation_Pearson[linearModels.table$crop == aCrop] <-
cor(x = yieldData$precipitation_dailyCum_plateauValue_yearlyMean[yieldData$crop == aCrop], y = yieldData$yield_scaledByCrop[yieldData$crop == aCrop], use = "pairwise.complete.obs")
linearModel <- lm(yield_scaledByCrop ~ precipitation_dailyCum_plateauValue_yearlyMean, data = yieldData[yieldData$crop == aCrop,])
linearModels.table$intercept[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[1,1]
linearModels.table$intercept_p[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[1,4]
linearModels.table$speed[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[2,1]
linearModels.table$speed_p[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[2,4]
linearModels.table$adjrsquared[linearModels.table$crop == aCrop] <- summary(linearModel)$adj.r.squared
}
knitr::kable(linearModels.table)
| crop | correlation_Pearson | intercept | intercept_p | speed | speed_p | adjrsquared |
|---|---|---|---|---|---|---|
| ‘carrot’ | -0.0378026 | 0.1090183 | 0.0003534 | -0.2199336 | 0.0001561 | 0.0013292 |
| ‘dry bean’ | -0.3959118 | 1.1417636 | 0.0000000 | -2.3033960 | 0.0000000 | 0.1566618 |
| ‘greenbean’ | -0.1859456 | 0.5362454 | 0.0000000 | -1.0818225 | 0.0000000 | 0.0344792 |
| ‘maize’ | -0.4145053 | 1.1953850 | 0.0000000 | -2.4115719 | 0.0000000 | 0.1717318 |
| ‘potato 1’ | -0.1624300 | 0.4684292 | 0.0000000 | -0.9450099 | 0.0000000 | 0.0262861 |
| ‘potato 2’ | -0.1653006 | 0.4767077 | 0.0000000 | -0.9617111 | 0.0000000 | 0.0272270 |
| ‘potato 3’ | -0.1653006 | 0.4767077 | 0.0000000 | -0.9617111 | 0.0000000 | 0.0272270 |
| ‘potato 4’ | -0.1653006 | 0.4767077 | 0.0000000 | -0.9617111 | 0.0000000 | 0.0272270 |
| ‘potato 5’ | -0.1624300 | 0.4684292 | 0.0000000 | -0.9450099 | 0.0000000 | 0.0262861 |
| ‘potato 6’ | -0.1621597 | 0.4676498 | 0.0000000 | -0.9434375 | 0.0000000 | 0.0261984 |
| ‘rice’ | -0.4483065 | 1.2928638 | 0.0000000 | -2.6082258 | 0.0000000 | 0.2008988 |
| ‘soybean 1’ | -0.4632393 | 1.3359283 | 0.0000000 | -2.6951044 | 0.0000000 | 0.2145121 |
| ‘soybean 2’ | -0.4614171 | 1.3306733 | 0.0000000 | -2.6845028 | 0.0000000 | 0.2128270 |
| ‘sweetcorn’ | -0.4639221 | 1.3378974 | 0.0000000 | -2.6990767 | 0.0000000 | 0.2151452 |
| ‘tomato 1’ | -0.4679465 | 1.3495032 | 0.0000000 | -2.7224902 | 0.0000000 | 0.2188958 |
| ‘tomato 2’ | -0.4679584 | 1.3495375 | 0.0000000 | -2.7225595 | 0.0000000 | 0.2189069 |
| ‘wheat 1’ | 0.0980642 | -0.2828058 | 0.0000000 | 0.5705330 | 0.0000000 | 0.0095175 |
| ‘wheat 2’ | 0.0924863 | -0.2667197 | 0.0000000 | 0.5380807 | 0.0000000 | 0.0084545 |
Create filter for wheat and rice:
wheatAndRice <- c(" 'wheat 1'", " 'wheat 2'", " 'rice'")
isWheatAndRice <- yieldData$crop == " 'wheat 1'" | yieldData$crop == " 'wheat 2'" | yieldData$crop == " 'rice'"
Apply filter:
yieldData <- yieldData[isWheatAndRice,]
# crop factor variable needs resetting levels
yieldData$crop <- factor(yieldData$crop)
Get vector of colours to represent crops:
cropColours <- rainbow(nlevels(yieldData$crop), s = 0.8, end = 0.9)
Precalculate ranges of ARID and yield:
minARID = round(min(c(yieldData$meanARID, yieldData$meanARID_grow), na.rm = TRUE), digits = 2)
maxARID = round(max(c(yieldData$meanARID, yieldData$meanARID_grow), na.rm = TRUE), digits = 2)
minYield = round(min(yieldData$yield), digits = -1)
maxYield = round(max(yieldData$yield), digits = -1)
minYield_scaledByCrop = round(min(yieldData$yield_scaledByCrop), digits = 2)
maxYield_scaledByCrop = round(max(yieldData$yield_scaledByCrop), digits = 2)
Scale and centre yield values for each crop:
yieldData$yield_scaledByCrop <- ave(yieldData$yield, yieldData$crop, FUN = function(x) scale(x) )
yieldData_summary <- tapply(as.numeric(as.character(yieldData$yield)), yieldData$crop, summary)
yieldData_summary <- data.frame(Reduce(rbind, yieldData_summary), row.names = names(yieldData_summary))
knitr::kable(yieldData_summary)
| Min. | X1st.Qu. | Median | Mean | X3rd.Qu. | Max. | |
|---|---|---|---|---|---|---|
| ‘rice’ | 0 | 150.4274 | 208.9544 | 201.8080 | 257.9053 | 436.3055 |
| ‘wheat 1’ | 0 | 317.2919 | 377.4391 | 309.3556 | 412.3355 | 480.8628 |
| ‘wheat 2’ | 0 | 329.9524 | 388.3795 | 317.9734 | 422.3030 | 489.2842 |
plotName = "plots/SIMPLE-crop-model/yieldPerCrop_wheatVsRice.png"
grScale = 2
fontRescale = 0
fontRescaleDay = 0
png(plotName, width = grScale * 500, height = grScale * 300)
par(mar = c(6,5,1,1))
boxplot(yield ~ factor(crop), data = yieldData,#[yieldData$yield > 0,], # show only non-zero yield
ylab = expression(paste("yield (", g/m^2, ")")), xlab = "",
las = 2,
col = cropColours)
dev.off()
## png
## 2
knitr::include_graphics(plotName)
plotName = "plots/SIMPLE-crop-model/yield_scaledPerCrop_wheatVsRice.png"
grScale = 2
fontRescale = 0
fontRescaleDay = 0
png(plotName, width = grScale * 500, height = grScale * 300)
par(mar = c(6,5,1,1))
boxplot(yield_scaledByCrop ~ factor(crop), data = yieldData,#[yieldData$yield > 0,], # show only non-zero yield
ylab = expression(paste("scaled yield (", g/m^2, ")")), xlab = "",
las = 2,
col = cropColours)
dev.off()
## png
## 2
knitr::include_graphics(plotName)
Plotting ARID vs precipitation yearly mean:
plotName = "plots/SIMPLE-crop-model/ARIDvsPrecipitation_yearlyMean_wheatVsRice.png"
grScale = 2
fontRescale = 0.5
png(plotName, width = grScale * 500, height = grScale * 300)
layout(matrix(c(1, 2, 3), nrow = 3, ncol = 1),
heights = c(10, 10, 2))
par(mar = c(1,5,1,1), cex.lab = 0.8 * grScale)
plot(c(minPrecipitation_yearlyMean, maxPrecipitation_yearlyMean),
c(minARID, maxARID),
xaxt ='n',
xlab = "",
ylab = "mean ARID (current year)")
points(yieldData$precipitation_yearlyMean, yieldData$meanARID, pch = 20)
abline(lm(meanARID ~ precipitation_yearlyMean, data = yieldData), lwd = 2, col = "royalblue")
plot(c(minPrecipitation_yearlyMean, maxPrecipitation_yearlyMean),
c(minARID, maxARID),
xaxt ='n',
xlab = "",
ylab = "mean ARID (grow seasons)")
points(yieldData$precipitation_yearlyMean, yieldData$meanARID_grow, pch = 20)
abline(lm(meanARID_grow ~ precipitation_yearlyMean, data = yieldData), lwd = 2, col = "royalblue")
par(mar = c(1, 1, 1, 0.1))
plot(c(minPrecipitation_yearlyMean, maxPrecipitation_yearlyMean), c(0, 1), ann = F, bty = 'n', type = 'n', xaxt = 'n', yaxt = 'n')
axis(3,
at = seq(minPrecipitation_yearlyMean, maxPrecipitation_yearlyMean, by = 50),
tck = 0, lwd = 0)
mtext("precipitation yearly mean (mm)", side = 1, line = -2)
dev.off()
## png
## 2
knitr::include_graphics(plotName)
Plotting ARID vs precipitation seasonal balance (plateau value):
plotName = "plots/SIMPLE-crop-model/ARIDvsPrecipitation_dailyCum_plateauValue_yearlyMean_wheatVsRice.png"
grScale = 2
fontRescale = 0.5
png(plotName, width = grScale * 500, height = grScale * 300)
layout(matrix(c(1, 2, 3), nrow = 3, ncol = 1),
heights = c(10, 10, 2))
par(mar = c(1,5,1,1), cex.lab = 0.8 * grScale)
plot(c(minPrecipitation_dailyCum_plateauValue_yearlyMean, maxPrecipitation_dailyCum_plateauValue_yearlyMean),
c(minARID, maxARID),
xaxt ='n',
xlab = "",
ylab = "mean ARID (current year)")
points(yieldData$precipitation_dailyCum_plateauValue_yearlyMean, yieldData$meanARID, pch = 20)
abline(lm(meanARID ~ precipitation_dailyCum_plateauValue_yearlyMean, data = yieldData), lwd = 2, col = "royalblue")
plot(c(minPrecipitation_dailyCum_plateauValue_yearlyMean, maxPrecipitation_dailyCum_plateauValue_yearlyMean),
c(minARID, maxARID),
xaxt ='n',
xlab = "",
ylab = "mean ARID (grow seasons)")
points(yieldData$precipitation_dailyCum_plateauValue_yearlyMean, yieldData$meanARID_grow, pch = 20)
abline(lm(meanARID_grow ~ precipitation_dailyCum_plateauValue_yearlyMean, data = yieldData), lwd = 2, col = "royalblue")
par(mar = c(1, 1, 1, 0.1))
plot(c(minPrecipitation_dailyCum_plateauValue_yearlyMean, maxPrecipitation_dailyCum_plateauValue_yearlyMean), c(0, 1),
ann = F, bty = 'n', type = 'n', xaxt = 'n', yaxt = 'n')
axis(3,
at = seq(minPrecipitation_dailyCum_plateauValue_yearlyMean, maxPrecipitation_dailyCum_plateauValue_yearlyMean, by = 0.1),
tck = 0, lwd = 0)
mtext("precipitation plateau value (i.e. winter / summer) yearly mean (mm)", side = 1, line = -2)
dev.off()
## png
## 2
knitr::include_graphics(plotName)
Preparations:
minARID = min(c(yieldData$meanARID, yieldData$meanARID_grow), na.rm = TRUE)
maxARID = max(c(yieldData$meanARID, yieldData$meanARID_grow), na.rm = TRUE)
minYield = min(yieldData$yield)
maxYield = max(yieldData$yield)
Plotting absolute values of yield vs ARID:
plotName = "plots/SIMPLE-crop-model/yieldVsARID_wheatVsRice.png"
grScale = 2
fontRescale = 0
fontRescaleDay = 0
png(plotName, width = grScale * 500, height = grScale * 300)
layout(matrix(c(1, 2, 3, 3), nrow = 2, ncol = 2, byrow = FALSE),
widths = c(10, 3))
par(mar = c(5,5,1,1), cex.lab = 0.8 * grScale)
plot(c(minARID, maxARID),
c(minYield, maxYield),
xlab = "mean ARID (current year)",
ylab = expression(paste("yield (", g/m^2, ")")))
for (aCrop in levels(yieldData$crop))
{
points(yieldData$meanARID[yieldData$crop == aCrop],
yieldData$yield[yieldData$crop == aCrop],
col = cropColours[match(aCrop, levels(yieldData$crop))],
pch = 20
)
abline(lm(yield ~ meanARID, data = yieldData[yieldData$crop == aCrop,]),
col = cropColours[match(aCrop, levels(yieldData$crop))],
lwd = 2)
}
plot(c(minARID, maxARID),
c(minYield, maxYield),
xlab = "mean ARID (grow season)",
ylab = expression(paste("yield (", g/m^2, ")")))
for (aCrop in levels(yieldData$crop))
{
points(yieldData$meanARID_grow[yieldData$crop == aCrop],
yieldData$yield[yieldData$crop == aCrop],
col = cropColours[match(aCrop, levels(yieldData$crop))],
pch = 20
)
abline(lm(yield ~ meanARID_grow, data = yieldData[yieldData$crop == aCrop,]),
col = cropColours[match(aCrop, levels(yieldData$crop))],
lwd = 2)
}
par(mar = c(0, 0, 0, 0), cex = 0.8 * grScale)
plot(c(0, 1), c(0, 1), ann = F, bty = 'n', type = 'n', xaxt = 'n', yaxt = 'n')
legend(x = 0, y = 1,
legend = stringi::stri_c(cropTable$S_water[cropTable$crop %in% wheatAndRice], " (", levels(yieldData$crop), ")"),
title = "S_water (Crop-cultivar)",
fill = cropColours)
dev.off()
## png
## 2
knitr::include_graphics(plotName)
Calculate correlation and linear models fitness:
linearModels.table <- data.frame(
levels(yieldData$crop),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop))
)
names(linearModels.table) <- c("crop", "correlation_Pearson", "intercept", "intercept_p", "speed", "speed_p", "adjrsquared")
for (aCrop in levels(yieldData$crop))
{
linearModels.table$correlation_Pearson[linearModels.table$crop == aCrop] <-
cor(x = yieldData$meanARID_grow[yieldData$crop == aCrop], y = yieldData$yield[yieldData$crop == aCrop], use = "pairwise.complete.obs")
linearModel <- lm(yield ~ meanARID_grow, data = yieldData[yieldData$crop == aCrop,])
linearModels.table$intercept[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[1,1]
linearModels.table$intercept_p[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[1,4]
linearModels.table$speed[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[2,1]
linearModels.table$speed_p[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[2,4]
linearModels.table$adjrsquared[linearModels.table$crop == aCrop] <- summary(linearModel)$adj.r.squared
}
knitr::kable(linearModels.table)
| crop | correlation_Pearson | intercept | intercept_p | speed | speed_p | adjrsquared |
|---|---|---|---|---|---|---|
| ‘rice’ | -0.9726496 | 715.3493 | 0 | -682.0947 | 0 | 0.9460419 |
| ‘wheat 1’ | -0.9287574 | 524.0685 | 0 | -230.5063 | 0 | 0.8625731 |
| ‘wheat 2’ | -0.9424935 | 531.3317 | 0 | -224.6181 | 0 | 0.8882800 |
Plotting scaled values of yield vs ARID:
plotName = "plots/SIMPLE-crop-model/yieldVsARID_scaled_wheatVsRice.png"
grScale = 2
fontRescale = 0
fontRescaleDay = 0
png(plotName, width = grScale * 500, height = grScale * 300)
layout(matrix(c(1, 2, 3, 3), nrow = 2, ncol = 2, byrow = FALSE),
widths = c(10, 3))
par(mar = c(5,5,1,1), cex.lab = 0.8 * grScale)
plot(c(minARID, maxARID),
c(0, 1),
xlab = "mean ARID (current year)",
ylab = expression(paste("scaled yield (", g/m^2, ")")))
for (aCrop in levels(yieldData$crop))
{
points(yieldData$meanARID[yieldData$crop == aCrop],
yieldData$yield_scaledByCrop[yieldData$crop == aCrop],
col = cropColours[match(aCrop, levels(yieldData$crop))],
pch = 20
)
if (max(yieldData$yield_scaledByCrop[yieldData$crop == aCrop], na.rm = T) > 0)
{
abline(lm(yieldData$yield_scaledByCrop[yieldData$crop == aCrop] ~ yieldData$meanARID[yieldData$crop == aCrop]),
col = cropColours[match(aCrop, levels(yieldData$crop))],
lwd = 2)
}
}
plot(c(minARID, maxARID),
c(0, 1),
xlab = "mean ARID (grow season)",
ylab = expression(paste("scaled yield (", g/m^2, ")")))
for (aCrop in levels(yieldData$crop))
{
points(yieldData$meanARID_grow[yieldData$crop == aCrop],
yieldData$yield_scaledByCrop[yieldData$crop == aCrop],
col = cropColours[match(aCrop, levels(yieldData$crop))],
pch = 20
)
if (max(yieldData$yield_scaledByCrop[yieldData$crop == aCrop], na.rm = T) > 0)
{
abline(lm(yieldData$yield_scaledByCrop[yieldData$crop == aCrop] ~ yieldData$meanARID_grow[yieldData$crop == aCrop]),
col = cropColours[match(aCrop, levels(yieldData$crop))],
lwd = 2)
}
}
par(mar = c(0, 0, 0, 0), cex = 0.8 * grScale)
plot(c(0, 1), c(0, 1), ann = F, bty = 'n', type = 'n', xaxt = 'n', yaxt = 'n')
legend(x = 0, y = 1,
legend = stringi::stri_c(cropTable$S_water[cropTable$crop %in% wheatAndRice], " (", levels(yieldData$crop), ")"),
title = "S_water (Crop-cultivar)",
fill = cropColours)
dev.off()
## png
## 2
knitr::include_graphics(plotName)
Calculate correlation and linear models fitness:
linearModels.table <- data.frame(
levels(yieldData$crop),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop))
)
names(linearModels.table) <- c("crop", "correlation_Pearson", "intercept", "intercept_p", "speed", "speed_p", "adjrsquared")
for (aCrop in levels(yieldData$crop))
{
linearModels.table$correlation_Pearson[linearModels.table$crop == aCrop] <-
cor(x = yieldData$meanARID_grow[yieldData$crop == aCrop], y = yieldData$yield_scaledByCrop[yieldData$crop == aCrop], use = "pairwise.complete.obs")
linearModel <- lm(yield_scaledByCrop ~ meanARID_grow, data = yieldData[yieldData$crop == aCrop,])
linearModels.table$intercept[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[1,1]
linearModels.table$intercept_p[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[1,4]
linearModels.table$speed[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[2,1]
linearModels.table$speed_p[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[2,4]
linearModels.table$adjrsquared[linearModels.table$crop == aCrop] <- summary(linearModel)$adj.r.squared
}
knitr::kable(linearModels.table)
| crop | correlation_Pearson | intercept | intercept_p | speed | speed_p | adjrsquared |
|---|---|---|---|---|---|---|
| ‘rice’ | -0.9726496 | 6.396906 | 0 | -8.496484 | 0 | 0.9460419 |
| ‘wheat 1’ | -0.9287574 | 1.351132 | 0 | -1.450515 | 0 | 0.8625731 |
| ‘wheat 2’ | -0.9424935 | 1.310604 | 0 | -1.379770 | 0 | 0.8882800 |
Plotting absolute values of yield vs precipitation yearly mean:
plotName = "plots/SIMPLE-crop-model/yieldVsprecipitation_yearlyMean_wheatVsRice.png"
grScale = 2
fontRescale = 0
fontRescaleDay = 0
png(plotName, width = grScale * 500, height = grScale * 300)
layout(matrix(c(1, 2), nrow = 1, ncol = 2, byrow = FALSE),
widths = c(10, 3))
par(mar = c(5,5,1,1), cex.lab = 0.8 * grScale)
plot(c(minPrecipitation_yearlyMean, maxPrecipitation_yearlyMean),
c(minYield, maxYield),
xlab = "precipitation yearly mean (mm)",
ylab = expression(paste("yield (", g/m^2, ")")))
for (aCrop in levels(yieldData$crop))
{
points(yieldData$precipitation_yearlyMean[yieldData$crop == aCrop],
yieldData$yield[yieldData$crop == aCrop],
col = cropColours[match(aCrop, levels(yieldData$crop))],
pch = 20
)
abline(lm(yield ~ precipitation_yearlyMean, data = yieldData[yieldData$crop == aCrop,]),
col = cropColours[match(aCrop, levels(yieldData$crop))],
lwd = 2)
}
par(mar = c(0, 0, 0, 0), cex = 0.8 * grScale)
plot(c(0, 1), c(0, 1), ann = F, bty = 'n', type = 'n', xaxt = 'n', yaxt = 'n')
legend(x = 0, y = 1,
legend = stringi::stri_c(cropTable$S_water[cropTable$crop %in% wheatAndRice], " (", levels(yieldData$crop), ")"),
title = "S_water (Crop-cultivar)",
fill = cropColours)
dev.off()
## png
## 2
knitr::include_graphics(plotName)
Calculate correlation and linear models fitness:
linearModels.table <- data.frame(
levels(yieldData$crop),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop))
)
names(linearModels.table) <- c("crop", "correlation_Pearson", "intercept", "intercept_p", "speed", "speed_p", "adjrsquared")
for (aCrop in levels(yieldData$crop))
{
linearModels.table$correlation_Pearson[linearModels.table$crop == aCrop] <-
cor(x = yieldData$precipitation_yearlyMean[yieldData$crop == aCrop], y = yieldData$yield[yieldData$crop == aCrop], use = "pairwise.complete.obs")
linearModel <- lm(yield ~ precipitation_yearlyMean, data = yieldData[yieldData$crop == aCrop,])
linearModels.table$intercept[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[1,1]
linearModels.table$intercept_p[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[1,4]
linearModels.table$speed[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[2,1]
linearModels.table$speed_p[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[2,4]
linearModels.table$adjrsquared[linearModels.table$crop == aCrop] <- summary(linearModel)$adj.r.squared
}
knitr::kable(linearModels.table)
| crop | correlation_Pearson | intercept | intercept_p | speed | speed_p | adjrsquared |
|---|---|---|---|---|---|---|
| ‘rice’ | 0.5472361 | 90.76639 | 0 | 0.1886075 | 0 | 0.2993973 |
| ‘wheat 1’ | 0.1168810 | 262.40835 | 0 | 0.0797413 | 0 | 0.0135625 |
| ‘wheat 2’ | 0.1116123 | 272.04770 | 0 | 0.0780062 | 0 | 0.0123585 |
Plotting scaled values of yield vs precipitation yearly mean:
plotName = "plots/SIMPLE-crop-model/yield_scaledByCropVsprecipitation_yearlyMean_wheatVsRice.png"
grScale = 2
fontRescale = 0
fontRescaleDay = 0
png(plotName, width = grScale * 500, height = grScale * 300)
layout(matrix(c(1, 2), nrow = 1, ncol = 2, byrow = FALSE),
widths = c(10, 3))
par(mar = c(5,5,1,1), cex.lab = 0.8 * grScale)
plot(c(minPrecipitation_yearlyMean, maxPrecipitation_yearlyMean),
c(minYield_scaledByCrop, maxYield_scaledByCrop),
xlab = "precipitation yearly mean (mm)",
ylab = expression(paste("scaled yield (", g/m^2, ")")))
for (aCrop in levels(yieldData$crop))
{
points(yieldData$precipitation_yearlyMean[yieldData$crop == aCrop],
yieldData$yield_scaledByCrop[yieldData$crop == aCrop],
col = cropColours[match(aCrop, levels(yieldData$crop))],
pch = 20
)
abline(lm(yield_scaledByCrop ~ precipitation_yearlyMean, data = yieldData[yieldData$crop == aCrop,]),
col = cropColours[match(aCrop, levels(yieldData$crop))],
lwd = 2)
}
par(mar = c(0, 0, 0, 0), cex = 0.8 * grScale)
plot(c(0, 1), c(0, 1), ann = F, bty = 'n', type = 'n', xaxt = 'n', yaxt = 'n')
legend(x = 0, y = 1,
legend = stringi::stri_c(cropTable$S_water[cropTable$crop %in% wheatAndRice], " (", levels(yieldData$crop), ")"),
title = "S_water (Crop-cultivar)",
fill = cropColours)
dev.off()
## png
## 2
knitr::include_graphics(plotName)
Calculate correlation and linear models fitness:
linearModels.table <- data.frame(
levels(yieldData$crop),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop))
)
names(linearModels.table) <- c("crop", "correlation_Pearson", "intercept", "intercept_p", "speed", "speed_p", "adjrsquared")
for (aCrop in levels(yieldData$crop))
{
linearModels.table$correlation_Pearson[linearModels.table$crop == aCrop] <-
cor(x = yieldData$precipitation_yearlyMean[yieldData$crop == aCrop], y = yieldData$yield_scaledByCrop[yieldData$crop == aCrop], use = "pairwise.complete.obs")
linearModel <- lm(yield_scaledByCrop ~ precipitation_yearlyMean, data = yieldData[yieldData$crop == aCrop,])
linearModels.table$intercept[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[1,1]
linearModels.table$intercept_p[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[1,4]
linearModels.table$speed[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[2,1]
linearModels.table$speed_p[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[2,4]
linearModels.table$adjrsquared[linearModels.table$crop == aCrop] <- summary(linearModel)$adj.r.squared
}
knitr::kable(linearModels.table)
| crop | correlation_Pearson | intercept | intercept_p | speed | speed_p | adjrsquared |
|---|---|---|---|---|---|---|
| ‘rice’ | 0.5472361 | -1.3831848 | 0 | 0.0023494 | 0 | 0.2993973 |
| ‘wheat 1’ | 0.1168810 | -0.2954266 | 0 | 0.0005018 | 0 | 0.0135625 |
| ‘wheat 2’ | 0.1116123 | -0.2821095 | 0 | 0.0004792 | 0 | 0.0123585 |
Plotting absolute values of yield vs precipitation seasonal balance (plateau value):
plotName = "plots/SIMPLE-crop-model/yieldVsprecipitation_dailyCum_plateauValue_yearlyMean_wheatVsRice.png"
grScale = 2
fontRescale = 0
fontRescaleDay = 0
png(plotName, width = grScale * 500, height = grScale * 300)
layout(matrix(c(1, 2), nrow = 1, ncol = 2, byrow = FALSE),
widths = c(10, 3))
par(mar = c(5,5,1,1), cex.lab = 0.8 * grScale)
plot(c(minPrecipitation_dailyCum_plateauValue_yearlyMean, maxPrecipitation_dailyCum_plateauValue_yearlyMean),
c(minYield, maxYield),
xlab = "precipitation plateau value (i.e. winter / summer) yearly mean (mm)",
ylab = expression(paste("yield (", g/m^2, ")")))
for (aCrop in levels(yieldData$crop))
{
points(yieldData$precipitation_dailyCum_plateauValue_yearlyMean[yieldData$crop == aCrop],
yieldData$yield[yieldData$crop == aCrop],
col = cropColours[match(aCrop, levels(yieldData$crop))],
pch = 20
)
abline(lm(yield ~ precipitation_dailyCum_plateauValue_yearlyMean, data = yieldData[yieldData$crop == aCrop,]),
col = cropColours[match(aCrop, levels(yieldData$crop))],
lwd = 2)
}
par(mar = c(0, 0, 0, 0), cex = 0.8 * grScale)
plot(c(0, 1), c(0, 1), ann = F, bty = 'n', type = 'n', xaxt = 'n', yaxt = 'n')
legend(x = 0, y = 1,
legend = levels(yieldData$crop),
title = "Crop-cultivar",
fill = cropColours)
dev.off()
## png
## 2
knitr::include_graphics(plotName)
Calculate correlation and linear models fitness:
linearModels.table <- data.frame(
levels(yieldData$crop),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop))
)
names(linearModels.table) <- c("crop", "correlation_Pearson", "intercept", "intercept_p", "speed", "speed_p", "adjrsquared")
for (aCrop in levels(yieldData$crop))
{
linearModels.table$correlation_Pearson[linearModels.table$crop == aCrop] <-
cor(x = yieldData$precipitation_dailyCum_plateauValue_yearlyMean[yieldData$crop == aCrop], y = yieldData$yield[yieldData$crop == aCrop], use = "pairwise.complete.obs")
linearModel <- lm(yield ~ precipitation_dailyCum_plateauValue_yearlyMean, data = yieldData[yieldData$crop == aCrop,])
linearModels.table$intercept[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[1,1]
linearModels.table$intercept_p[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[1,4]
linearModels.table$speed[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[2,1]
linearModels.table$speed_p[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[2,4]
linearModels.table$adjrsquared[linearModels.table$crop == aCrop] <- summary(linearModel)$adj.r.squared
}
knitr::kable(linearModels.table)
| crop | correlation_Pearson | intercept | intercept_p | speed | speed_p | adjrsquared |
|---|---|---|---|---|---|---|
| ‘rice’ | -0.4483065 | 305.5986 | 0 | -209.38744 | 0 | 0.2008988 |
| ‘wheat 1’ | 0.0980642 | 264.4140 | 0 | 90.66534 | 0 | 0.0095175 |
| ‘wheat 2’ | 0.0924863 | 274.5531 | 0 | 87.59626 | 0 | 0.0084545 |
Plotting scaled values of yield vs precipitation yearly mean:
plotName = "plots/SIMPLE-crop-model/yield_scaledByCropVsprecipitation_dailyCum_plateauValue_yearlyMean_wheatVsRice.png"
grScale = 2
fontRescale = 0
fontRescaleDay = 0
png(plotName, width = grScale * 500, height = grScale * 300)
layout(matrix(c(1, 2), nrow = 1, ncol = 2, byrow = FALSE),
widths = c(10, 3))
par(mar = c(5,5,1,1), cex.lab = 0.8 * grScale)
plot(c(minPrecipitation_dailyCum_plateauValue_yearlyMean, maxPrecipitation_dailyCum_plateauValue_yearlyMean),
c(minYield_scaledByCrop, maxYield_scaledByCrop),
xlab = "precipitation plateau value (i.e. winter / summer) yearly mean (mm)",
ylab = expression(paste("scaled yield (", g/m^2, ")")))
for (aCrop in levels(yieldData$crop))
{
points(yieldData$precipitation_dailyCum_plateauValue_yearlyMean[yieldData$crop == aCrop],
yieldData$yield_scaledByCrop[yieldData$crop == aCrop],
col = cropColours[match(aCrop, levels(yieldData$crop))],
pch = 20
)
abline(lm(yield_scaledByCrop ~ precipitation_dailyCum_plateauValue_yearlyMean, data = yieldData[yieldData$crop == aCrop,]),
col = cropColours[match(aCrop, levels(yieldData$crop))],
lwd = 2)
}
par(mar = c(0, 0, 0, 0), cex = 0.8 * grScale)
plot(c(0, 1), c(0, 1), ann = F, bty = 'n', type = 'n', xaxt = 'n', yaxt = 'n')
legend(x = 0, y = 1,
legend = levels(yieldData$crop),
title = "Crop-cultivar",
fill = cropColours)
dev.off()
## png
## 2
knitr::include_graphics(plotName)
Calculate correlation and linear models fitness:
linearModels.table <- data.frame(
levels(yieldData$crop),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop)),
numeric(nlevels(yieldData$crop))
)
names(linearModels.table) <- c("crop", "correlation_Pearson", "intercept", "intercept_p", "speed", "speed_p", "adjrsquared")
for (aCrop in levels(yieldData$crop))
{
linearModels.table$correlation_Pearson[linearModels.table$crop == aCrop] <-
cor(x = yieldData$precipitation_dailyCum_plateauValue_yearlyMean[yieldData$crop == aCrop], y = yieldData$yield_scaledByCrop[yieldData$crop == aCrop], use = "pairwise.complete.obs")
linearModel <- lm(yield_scaledByCrop ~ precipitation_dailyCum_plateauValue_yearlyMean, data = yieldData[yieldData$crop == aCrop,])
linearModels.table$intercept[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[1,1]
linearModels.table$intercept_p[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[1,4]
linearModels.table$speed[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[2,1]
linearModels.table$speed_p[linearModels.table$crop == aCrop] <- summary(linearModel)$coefficients[2,4]
linearModels.table$adjrsquared[linearModels.table$crop == aCrop] <- summary(linearModel)$adj.r.squared
}
knitr::kable(linearModels.table)
| crop | correlation_Pearson | intercept | intercept_p | speed | speed_p | adjrsquared |
|---|---|---|---|---|---|---|
| ‘rice’ | -0.4483065 | 1.2928638 | 0 | -2.6082258 | 0 | 0.2008988 |
| ‘wheat 1’ | 0.0980642 | -0.2828058 | 0 | 0.5705330 | 0 | 0.0095175 |
| ‘wheat 2’ | 0.0924863 | -0.2667197 | 0 | 0.5380807 | 0 | 0.0084545 |