Package 'soiltestcorr'

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-09-30 06:36:20 UTC
Source: CRAN

Help Index


Cate & Nelson quadrants analysis (graphical)

Description

This function runs the quadrants analysis suggested by Cate and Nelson (1965)

Usage

cate_nelson_1965(data = NULL, stv, ry, target, tidy = TRUE, plot = FALSE)

boot_cn_1965(data, ry, stv, target = 90, n = 5, ...)

Arguments

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 ... (open arguments) allows to add grouping variable/s (factor or character) Default: NULL

Details

See online-documentation for additional details.

Value

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

Note

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/

References

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.

See Also

eval_tidy,defusing-advanced lm,anova ggplot,aes,geom_point,labs,geom_abline,annotate,theme

Examples

# 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

Cate & Nelson quadrants analysis (statistical)

Description

This function runs the quadrants analysis suggested by Cate and Nelson (1971)

Usage

cate_nelson_1971(data = NULL, stv, ry, tidy = TRUE, plot = FALSE)

boot_cn_1971(data, ry, stv, n = 5, ...)

Arguments

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 ... (open arguments) allows to add grouping variable/s (factor or character) Default: NULL

Details

See online-documentation for additional details.

Value

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

Note

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/

References

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

See Also

eval_tidy,defusing-advanced lm,anova ggplot,aes,geom_point,labs,geom_abline,annotate,theme

Examples

# 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

Dataset 1

Description

Example dataset containing hypothetical pairs of soil test value (STV) and relative yield (RY).

Usage

data_test

Format

this data frame has 137 rows and the following 2 columns:

STV

soil test value

RY

relative yield, %

Source

doi:10.7910/DVN/NABA57


Dataset 2

Description

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).

Usage

freitas1966

Format

this data frame has 24 rows and the following 2 columns:

RY

relative yield, %

STK

soil test potassium, ppm

Source

Freitas et al. (1966) cited and used by Cate & Nelson (1971). Soil Sci. Soc. Am. Proc. 35:658-659


Linear-plateau response function

Description

This function helps to fit a linear-plateau model in order to estimate critical soil test values (CSTV) above which yield response becomes flat.

Usage

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, ...)

Arguments

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 numeric.

ry

name of the vector containing relative yield values (%) of type numeric.

target

numeric value of relative yield target (e.g. 90 for 90%) to estimate the CSTV. The target needs to be < plateau, otherwise, target = plateau.

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 ... (open arguments) allows to add grouping variable/s (factor or character) Default: NULL

Details

See online-documentation for additional details.

Value

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

Note

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

References

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

See Also

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

Examples

# 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

Mitscherlich response function

Description

This function helps to fit a Mitscherlich-style exponential response model for relative yield (ry) as a function of soil test values (stv).

Usage

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, ...)

Arguments

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 numeric.

ry

name of the vector containing relative yield values (%) of type numeric.

type

string or number that indicates the type of Mitscherlich model to fit. Default: 1. For model with 'no restrictions' use type = 1, type = "no restriction", or type = "free"; For model with 'asymptote = 100' use type = 2, type = "asymptote 100", or type = "100"; For model with 'asymptote = 100 and xintercept = 0'" type = 3, type = "asymptote 100 from 0", or type = "fixed".

target

numeric value of relative yield target (e.g. 90 for 90%) to estimate the CSTV. Default: NULL

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 ... (open arguments) allows to add grouping variable/s (factor or character) Default: NULL

Details

See online-documentation for additional details.

Value

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

Note

For extended reference, we recommend to visit: https://github.com/austinwpearce/SoilTestCocaCola by Austin Pearce.

References

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

See Also

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

Examples

# 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

Modified Arcsine-Log Calibration Curve

Description

This function runs the modified arcsine-log calibration curve to estimate critical soil test values (CSTV) following Correndo et al. (2017)

Usage

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, ...)

Arguments

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 numeric.

stv

name of the vector containing soil test values of type numeric.

target

numeric value of relative yield target (e.g. 90 for 90%) to estimate the CSTV.

confidence

numeric value of confidence level (e.g. 0.95 for significance = 0.05)

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 ... (open arguments) allows to add grouping variable/s (factor or character) Default: NULL

n

sample size for the bootstrapping Default: 500

Details

See online-documentation for additional details.

Value

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

Note

For extended reference, we recommend to visit doi:10.7910/DVN/NABA57 and https://github.com/adriancorrendo/modified-ALCC by Adrian Correndo.

References

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

See Also

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

Examples

# 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

Quadratic-plateau response function

Description

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.

Usage

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, ...)

Arguments

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 numeric.

ry

name of the vector containing relative yield values (%) of type numeric.

target

numeric value of relative yield target (e.g. 90 for 90%) to estimate the CSTV. The target needs to be < plateau, otherwise, target = plateau.

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 ... (open arguments) allows to add grouping variable/s (factor or character) Default: NULL

Details

See online-documentation for additional details.

Value

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

Note

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

References

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

See Also

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

Examples

# 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