Title: | Soil Test Correlation and Calibration |
---|---|
Description: | A compilation of functions designed to assist users on the correlation analysis of crop yield and soil test values. Functions to estimate crop response patterns to soil nutrient availability and critical soil test values using various approaches such as: 1) the modified arcsine-log calibration curve (Correndo et al. (2017) <doi:10.1071/CP16444>); 2) the graphical Cate-Nelson quadrants analysis (Cate & Nelson (1965)), 3) the statistical Cate-Nelson quadrants analysis (Cate & Nelson (1971) <doi:10.2136/sssaj1971.03615995003500040048x>), 4) the linear-plateau regression (Anderson & Nelson (1975) <doi:10.2307/2529422>), 5) the quadratic-plateau regression (Bullock & Bullock (1994) <doi:10.2134/agronj1994.00021962008600010033x>), and 6) the Mitscherlich-type exponential regression (Melsted & Peck (1977) <doi:10.2134/asaspecpub29.c1>). The package development stemmed from ongoing work with the Fertilizer Recommendation Support Tool (FRST) and Feed the Future Innovation Lab for Collaborative Research on Sustainable Intensification (SIIL) projects. |
Authors: | Adrian A. Correndo [aut, cre, cph] , Austin Pearce [aut] , Fernando Miguez [ctb] , Deanna Osmond [aut] , Ignacio A. Ciampitti [aut] |
Maintainer: | Adrian A. Correndo <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.2.1 |
Built: | 2024-12-27 03:16:49 UTC |
Source: | https://github.com/adriancorrendo/soiltestcorr |
This function runs the quadrants analysis suggested by Cate and Nelson (1965)
cate_nelson_1965(data = NULL, stv, ry, target, tidy = TRUE, plot = FALSE) boot_cn_1965(data, ry, stv, target = 90, n = 5, ...)
cate_nelson_1965(data = NULL, stv, ry, target, tidy = TRUE, plot = FALSE) boot_cn_1965(data, ry, stv, target = 90, n = 5, ...)
data |
argument to call a data.frame or data.table containing the data |
stv |
argument to call the vector or column containing the soil test value (stv) data |
ry |
argument to call the vector or column containing the relative yield (ry) data |
target |
argument to specify the ry target (numeric) to estimate the critical stv for |
tidy |
logical operator (TRUE/FALSE) to decide the type of return. TRUE returns a tibble, FALSE returns a list. Default: TRUE. |
plot |
logical operator (TRUE/FALSE) to decide the type of return. TRUE returns a ggplot, FALSE returns either a list (tidy == FALSE) or a tibble (tidy == TRUE). |
n |
sample size for the bootstrapping Default: 500 |
... |
when running bootstrapped samples, the |
See online-documentation for additional details.
returns an object of type ggplot
if plot = TRUE.
returns an object of class data.frame
if tidy = TRUE,
returns an object of class list
if tidy = FALSE.
boot_cn_1965: bootstrapping function
This code was adapted from Mangiafico, S. S. (2013). Cate-Nelson Analysis for Bivariate Data Using R-project. The Journal of Extension, 51(5), Article 33. https://tigerprints.clemson.edu/joe/vol51/iss5/33/
Cate & Nelson (1965). A rapid method for correlation of soil test analysis with plant response data. North Carolina Agric. Exp. Stn., International soil Testing Series l. No. 1.
eval_tidy
,defusing-advanced
lm
,anova
ggplot
,aes
,geom_point
,labs
,geom_abline
,annotate
,theme
# Example 1 dataset dat <- data.frame("ry" = c(65,80,85,88,90,94,93,96,97,95,98,100,99,99,100), "stv" = c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)) # Run fit_example_cn_1965 <- cate_nelson_1965(data = dat, ry = ry, stv = stv, target = 90, tidy=FALSE, plot=FALSE) fit_example_cn_1965
# Example 1 dataset dat <- data.frame("ry" = c(65,80,85,88,90,94,93,96,97,95,98,100,99,99,100), "stv" = c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)) # Run fit_example_cn_1965 <- cate_nelson_1965(data = dat, ry = ry, stv = stv, target = 90, tidy=FALSE, plot=FALSE) fit_example_cn_1965
This function runs the quadrants analysis suggested by Cate and Nelson (1971)
cate_nelson_1971(data = NULL, stv, ry, tidy = TRUE, plot = FALSE) boot_cn_1971(data, ry, stv, n = 5, ...)
cate_nelson_1971(data = NULL, stv, ry, tidy = TRUE, plot = FALSE) boot_cn_1971(data, ry, stv, n = 5, ...)
data |
argument to call a data.frame or data.table containing the data |
stv |
argument to call the vector or column containing the soil test value (stv) data |
ry |
argument to call the vector or column containing the relative yield (ry) data |
tidy |
logical operator (TRUE/FALSE) to decide the type of return. TRUE returns a data.frame, FALSE returns a list. Default: TRUE. |
plot |
logical operator (TRUE/FALSE) to decide the type of return. TRUE returns a ggplot, FALSE returns either a list (tidy == FALSE) or a data.frame (tidy == TRUE). |
n |
sample size for the bootstrapping Default: 500 |
... |
when running bootstrapped samples, the |
See online-documentation for additional details.
returns an object of type ggplot
if plot = TRUE.
returns an object of class data.frame
if tidy = TRUE,
returns an object of class list
if tidy = FALSE.
boot_cn_1971: bootstrapping function
This code was adapted from Mangiafico, S. S. (2013). Cate-Nelson Analysis for Bivariate Data Using R-project. The Journal of Extension, 51(5), Article 33. https://tigerprints.clemson.edu/joe/vol51/iss5/33/
Cate & Nelson (1971). A simple statistical procedure for partitioning soil test correlation data into two classes. Soil Sci. Soc. Am. Proc. 35:658-660. doi:10.2136/sssaj1971.03615995003500040048x
eval_tidy
,defusing-advanced
lm
,anova
ggplot
,aes
,geom_point
,labs
,geom_abline
,annotate
,theme
# Example 1 dataset dat <- data.frame("ry" = c(65,80,85,88,90,94,93,96,97,95,98,100,99,99,100), "stv" = c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)) # Run fit_example_cn_1971 <- cate_nelson_1971(data = dat, ry = ry, stv = stv, tidy=FALSE, plot=FALSE) fit_example_cn_1971
# Example 1 dataset dat <- data.frame("ry" = c(65,80,85,88,90,94,93,96,97,95,98,100,99,99,100), "stv" = c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)) # Run fit_example_cn_1971 <- cate_nelson_1971(data = dat, ry = ry, stv = stv, tidy=FALSE, plot=FALSE) fit_example_cn_1971
Example dataset containing hypothetical pairs of soil test value (STV) and relative yield (RY).
data_test
data_test
this data frame has 137 rows and the following 2 columns:
soil test value
relative yield, %
Example dataset containing real data reported by Cate & Nelson (1971) from Freitas et al. (1966). Soil test potassium values (STK) and relative yield as percentage (RY).
freitas1966
freitas1966
this data frame has 24 rows and the following 2 columns:
relative yield, %
soil test potassium, ppm
Freitas et al. (1966) cited and used by Cate & Nelson (1971). Soil Sci. Soc. Am. Proc. 35:658-659
This function helps to fit a linear-plateau model in order to estimate critical soil test values (CSTV) above which yield response becomes flat.
SS_LP(x, a, b, xs) linear_plateau( data = NULL, stv, ry, target = NULL, tidy = TRUE, plot = FALSE, resid = FALSE ) boot_linear_plateau(data, stv, ry, n = 1000, target = NULL, ...)
SS_LP(x, a, b, xs) linear_plateau( data = NULL, stv, ry, target = NULL, tidy = TRUE, plot = FALSE, resid = FALSE ) boot_linear_plateau(data, stv, ry, n = 1000, target = NULL, ...)
x |
selfstart arg. for explanatory variable in SSlinp Default: NULL |
a |
selfstart arg. for intercept Default: NULL |
b |
selfstart arg. for slope Default: NULL |
xs |
selfstart arg. for break/join point in SSlinp Default: NULL |
data |
Optional argument to call and object of type data.frame or data.table containing the soil test value (STV) and relative yield (RY) data, Default: NULL |
stv |
name of the vector containing soil test values (-) of type |
ry |
name of the vector containing relative yield values (%) of type |
target |
|
tidy |
logical operator (TRUE/FALSE) to decide the type of return. TRUE returns a tidy data frame or tibble (default), FALSE returns a list. |
plot |
logical operator (TRUE/FALSE) to plot the linear-plateau model, Default: FALSE |
resid |
logical operator (TRUE/FALSE) to plot residuals analysis, Default: FALSE |
n |
sample size for the bootstrapping Default: 500 |
... |
when running bootstrapped samples, the |
See online-documentation for additional details.
returns an object of type ggplot
if plot = TRUE.
returns a residuals plot if resid = TRUE.
returns an object of class data.frame
if tidy = TRUE,
returns an object of class list
if tidy = FALSE.
SS_LP: selfStart function to pass into the linear_plateau fit
linear_plateau: function
boot_linear_plateau: bootstrapping function
For extended reference, we recommend to visit: https://gradcylinder.org/post/linear-plateau/ by Austin Pearce. Self-start function code adapted from nlraa package by F. Miguez https://github.com/femiguez/nlraa
Anderson, R. L., and Nelson, L. A. (1975). A Family of Models Involving Intersecting Straight Lines and Concomitant Experimental Designs Useful in Evaluating Response to Fertilizer Nutrients. Biometrics, 31(2), 303–318. doi:10.2307/2529422
eval_tidy
,defusing-advanced
nlsLM
SSlinp
AIC
,lm
,optim
,coef
,predict
AICc
model-quality
nlsResiduals
bind
ggplot
,aes
,geom_rug
,geom_point
,geom_abline
,geom_path
,annotate
,labs
,theme
annotate
# Example dataset dat <- data.frame("ry" = c(65,80,85,88,90,94,93,96,97,95,98,100,99,99,100), "stv" = c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)) # Run fit_example_lp <- linear_plateau(data = dat, ry = ry, stv = stv, resid = TRUE, plot = FALSE) fit_example_lp
# Example dataset dat <- data.frame("ry" = c(65,80,85,88,90,94,93,96,97,95,98,100,99,99,100), "stv" = c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)) # Run fit_example_lp <- linear_plateau(data = dat, ry = ry, stv = stv, resid = TRUE, plot = FALSE) fit_example_lp
This function helps to fit a Mitscherlich-style exponential response model for relative yield (ry) as a function of soil test values (stv).
mits_formula_1(x, a, b, c) mits_formula_2(x, b, c) mits_formula_3(x, c) mitscherlich( data = NULL, stv, ry, type = 1, target = 95, tidy = TRUE, plot = FALSE, resid = FALSE ) boot_mitscherlich(data, stv, ry, type = 1, n = 999, target = 95, ...)
mits_formula_1(x, a, b, c) mits_formula_2(x, b, c) mits_formula_3(x, c) mitscherlich( data = NULL, stv, ry, type = 1, target = 95, tidy = TRUE, plot = FALSE, resid = FALSE ) boot_mitscherlich(data, stv, ry, type = 1, n = 999, target = 95, ...)
x |
selfstart vector. for model fit Default: NULL |
a |
selfstart arg. for asymptote parameter, Default: NULL |
b |
selfstart arg. for b parameter (b = -X_intercept) Default: NULL |
c |
selfstart arg. for curvature parameter Default: NULL |
data |
Optional argument to call and object of type data.frame or data.table containing the stv and ry data, Default: NULL |
stv |
name of the vector containing soil test values (-) of type |
ry |
name of the vector containing relative yield values (%) of type |
type |
string or number that indicates the type of Mitscherlich model to fit. Default: 1.
For model with 'no restrictions' use |
target |
|
tidy |
logical operator (TRUE/FALSE) to decide the type of return. TRUE returns a tidy data frame or tibble (default), FALSE returns a list. |
plot |
logical operator (TRUE/FALSE) to plot the Mitscherlich model, Default: FALSE |
resid |
logical operator (TRUE/FALSE) to plot residuals analysis, Default: FALSE |
n |
sample size for the bootstrapping Default: 500 |
... |
when running bootstrapped samples, the |
See online-documentation for additional details.
returns an object of type ggplot
if plot = TRUE.
returns a residuals plot if resid = TRUE.
returns an object of class data.frame
if tidy = TRUE,
returns an object of class list
if tidy = FALSE.
Mitscherlich type 1 formula
Mitscherlich type 2 formula
Mitscherlich type 3 formula
mitscherlich: function
boot_mitscherlich: bootstrapping function
For extended reference, we recommend to visit: https://github.com/austinwpearce/SoilTestCocaCola by Austin Pearce.
Melsted, S.W. and Peck, T.R. (1977). The Mitscherlich-Bray Growth Function. In Soil Testing (eds T. Peck, J. Cope and D. Whitney). doi:10.2134/asaspecpub29.c1
eval_tidy
,defusing-advanced
nlsLM
AIC
,lm
,optim
,coef
,predict
AICc
model-quality
nlsResiduals
bind
ggplot
,aes
,geom_rug
,geom_point
,geom_abline
,geom_path
,annotate
,labs
,theme
# Example dataset dat <- data.frame("ry" = c(65,80,85,88,90,94,93,96,97,95,98,100,99,99,100), "stv" = c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)) # Run fit_example_mits <- mitscherlich(data = dat, type = 1, ry = ry, stv = stv, resid = TRUE, plot = FALSE) fit_example_mits
# Example dataset dat <- data.frame("ry" = c(65,80,85,88,90,94,93,96,97,95,98,100,99,99,100), "stv" = c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)) # Run fit_example_mits <- mitscherlich(data = dat, type = 1, ry = ry, stv = stv, resid = TRUE, plot = FALSE) fit_example_mits
This function runs the modified arcsine-log calibration curve to estimate critical soil test values (CSTV) following Correndo et al. (2017)
mod_alcc( data = NULL, ry, stv, target, confidence = 0.95, tidy = TRUE, plot = FALSE ) logLik_alcc(object, ...) boot_mod_alcc(data, ry, stv, n = 500, target = 90, confidence = 0.95, ...)
mod_alcc( data = NULL, ry, stv, target, confidence = 0.95, tidy = TRUE, plot = FALSE ) logLik_alcc(object, ...) boot_mod_alcc(data, ry, stv, n = 500, target = 90, confidence = 0.95, ...)
data |
Optional argument to call and object of type data.frame or data.table containing the stv and ry data, Default: NULL |
ry |
name of the vector containing relative yield values (%) of type |
stv |
name of the vector containing soil test values of type |
target |
|
confidence |
|
tidy |
logical operator (TRUE/FALSE) to decide the type of return. TRUE returns a tidy data frame or tibble (default), FALSE returns a list. |
plot |
logical operator (TRUE/FALSE) to decide the type of return. TRUE returns a ggplot, FALSE returns either a list (tidy == FALSE) or a data.frame (tidy == TRUE). |
object |
the "object" is the output data frame from approx with resid column |
... |
when running bootstrapped samples, the |
n |
sample size for the bootstrapping Default: 500 |
See online-documentation for additional details.
returns an object of type ggplot
if plot = TRUE.
returns an object of class data.frame
if tidy = TRUE,
returns an object of class list
if tidy = FALSE.
logLik_alcc: AIC on original scale function
boot_mod_alcc: bootstrapping function
For extended reference, we recommend to visit doi:10.7910/DVN/NABA57 and https://github.com/adriancorrendo/modified-ALCC by Adrian Correndo.
Correndo et al. (2017). A modification of the arcsine–log calibration curve for analysing soil test value–relative yield relationships. Crop and Pasture Science, 68(3), 297-304. doi:10.1071/CP16444
eval_tidy
,defusing-advanced
TDist
,cor
,cor.test
,sd
, approx
bind
,filter
nest
ggplot
,aes
,geom_point
,scale_manual
,geom_rug
,geom_abline
,geom_path
,annotate
,labs
,theme
annotate
# Example 1 dataset dat <- data.frame("ry" = c(65,80,85,88,90,94,93,96,97,95,98,100,99,99,100), "stv" = c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)) # Run fit_example <- mod_alcc(data = dat, ry = ry, stv = stv, target=90, confidence = 0.95) fit_example
# Example 1 dataset dat <- data.frame("ry" = c(65,80,85,88,90,94,93,96,97,95,98,100,99,99,100), "stv" = c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)) # Run fit_example <- mod_alcc(data = dat, ry = ry, stv = stv, target=90, confidence = 0.95) fit_example
This function helps to fit a quadratic-plateau response model and to estimate a critical soil test values (CSTV) above which yield response becomes flat.
SS_QP(x, a, b, xs) quadratic_plateau( data = NULL, stv, ry, target = NULL, tidy = TRUE, plot = FALSE, resid = FALSE ) boot_quadratic_plateau(data, stv, ry, n = 1000, target = NULL, ...)
SS_QP(x, a, b, xs) quadratic_plateau( data = NULL, stv, ry, target = NULL, tidy = TRUE, plot = FALSE, resid = FALSE ) boot_quadratic_plateau(data, stv, ry, n = 1000, target = NULL, ...)
x |
selfstart arg. for explanatory variable in SSquadp3xs Default: NULL |
a |
selfstart arg. for intercept Default: NULL |
b |
selfstart arg. for slope Default: NULL |
xs |
selfstart arg. for break/join point in SSquadp3xs Default: NULL |
data |
Optional argument to call and object of type data.frame or data.table containing the stv and ry data, Default: NULL |
stv |
name of the vector containing soil test values (-) of type |
ry |
name of the vector containing relative yield values (%) of type |
target |
|
tidy |
logical operator (TRUE/FALSE) to decide the type of return. TRUE returns a tidy data frame or tibble (default), FALSE returns a list. |
plot |
logical operator (TRUE/FALSE) to plot the quadratic-plateau model, Default: FALSE |
resid |
logical operator (TRUE/FALSE) to plot residuals analysis, Default: FALSE |
n |
sample size for the bootstrapping Default: 500 |
... |
when running bootstrapped samples, the |
See online-documentation for additional details.
returns an object of type ggplot
if plot = TRUE.
returns a residuals plot if resid = TRUE.
returns an object of class data.frame
if tidy = TRUE,
returns an object of class list
if tidy = FALSE.
SS_QP: selfStart function to pass into the quadratic_plateau fit
quadratic_plateau: function
boot_quadratic_plateau: bootstrapping function
For extended reference, we recommend to visit https://gradcylinder.org/post/quad-plateau/ by Austin Pearce. Self-start function code adapted from nlraa package by F. Miguez https://github.com/femiguez/nlraa
Bullock, D.G. and Bullock, D.S. (1994) Quadratic and Quadratic-Plus-Plateau Models for Predicting Optimal Nitrogen Rate of Corn: A Comparison. Agron. J., 86: 191-195. doi:10.2134/agronj1994.00021962008600010033x
eval_tidy
,defusing-advanced
nlsLM
SSlinp
AIC
,lm
,optim
,coef
,predict
AICc
model-quality
nlsResiduals
bind
ggplot
,aes
,geom_rug
,geom_point
,geom_abline
,geom_path
,annotate
,labs
,theme
annotate
# Example dataset df <- data.frame("ry" = c(65,80,85,88,90,94,93,96,97,95,98,100,99,99,100), "stv" = c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)) # Run fit_example_qp <- quadratic_plateau(data = df, stv = stv, ry = ry, resid = TRUE, plot = FALSE) fit_example_qp
# Example dataset df <- data.frame("ry" = c(65,80,85,88,90,94,93,96,97,95,98,100,99,99,100), "stv" = c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)) # Run fit_example_qp <- quadratic_plateau(data = df, stv = stv, ry = ry, resid = TRUE, plot = FALSE) fit_example_qp